Print beginning trail horodate.

This commit is contained in:
Chteufleur 2018-08-16 07:48:35 +02:00
parent 259f12ac3f
commit d4c99b4a59
5 changed files with 56 additions and 12 deletions

View File

@ -47,6 +47,7 @@ import java.util.Observer;
import fr.chteufleur.mytrackingdog.models.Gpx;
import fr.chteufleur.mytrackingdog.models.beans.MyLocation;
import fr.chteufleur.mytrackingdog.models.beans.MyLocationArray;
import fr.chteufleur.mytrackingdog.services.ServiceGps;
public class MainActivity extends AppCompatActivity implements IOrientationConsumer, Observer {
@ -410,10 +411,12 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
}
private void updateDogTrace() {
MyLocationArray listLoc = serviceGps.getListGeoPointDog();
Polyline line = new Polyline(map);
line.setTitle(Gpx.DOG_TRACE_NAME);
line.setSubDescription("Départ: "+listLoc.getFirstLocation().getDatePrint());
line.setColor(Color.BLUE);
line.setPoints(convertListLocation(serviceGps.getListGeoPointDog()));
line.setPoints(convertListLocation(listLoc));
line.setWidth(LINE_WIDTH_BIG);
line.setGeodesic(true);
line.setInfoWindow(new BasicInfoWindow(R.layout.bonuspack_bubble, map));
@ -422,10 +425,12 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
}
private void updateTrailTrace() {
MyLocationArray listLoc = serviceGps.getListGeoPointTraceur();
Polyline line = new Polyline(map);
line.setTitle(Gpx.TRAIL_TRACE_NAME);
line.setSubDescription("Départ: "+listLoc.getFirstLocation().getDatePrint());
line.setColor(Color.RED);
line.setPoints(convertListLocation(serviceGps.getListGeoPointTraceur()));
line.setPoints(convertListLocation(listLoc));
line.setWidth(LINE_WIDTH_BIG);
line.setGeodesic(true);
line.setInfoWindow(new BasicInfoWindow(R.layout.bonuspack_bubble, map));
@ -461,7 +466,7 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
}
}
private List<GeoPoint> convertListLocation(List<MyLocation> list) {
private List<GeoPoint> convertListLocation(MyLocationArray list) {
List<GeoPoint> ret = new ArrayList<>();
if (list != null) {
for (MyLocation loc : list) {

View File

@ -6,14 +6,15 @@ import java.util.ArrayList;
import java.util.List;
import fr.chteufleur.mytrackingdog.models.beans.MyLocation;
import fr.chteufleur.mytrackingdog.models.beans.MyLocationArray;
public class Traces {
private static final String TAG = Traces.class.getName();
private List<MyLocation> listPointTraceur = new ArrayList<>();
private List<MyLocation> listPointDog = new ArrayList<>();
private List<MyLocation> listPointObjects = new ArrayList<>();
private MyLocationArray listPointTraceur = new MyLocationArray();
private MyLocationArray listPointDog = new MyLocationArray();
private MyLocationArray listPointObjects = new MyLocationArray();
private boolean traceurActivated = false;
private boolean dogActivated = false;
@ -38,13 +39,13 @@ public class Traces {
addPointDog(point);
}
}
public List<MyLocation> getListPointTraceur() {
public MyLocationArray getListPointTraceur() {
return listPointTraceur;
}
public List<MyLocation> getListPointDog() {
public MyLocationArray getListPointDog() {
return listPointDog;
}
public List<MyLocation> getListPointObjects() {
public MyLocationArray getListPointObjects() {
return listPointObjects;
}

View File

@ -56,6 +56,13 @@ public class MyLocation {
return formaterDate.format(date)+"T"+formaterTime.format(date)+"Z";
}
public String getDatePrint() {
Date date = new Date(this.time);
SimpleDateFormat formaterDate = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formaterTime = new SimpleDateFormat("HH:mm:ss");
return formaterDate.format(date)+" "+formaterTime.format(date);
}
public double getAltitude() {
return this.altitude;
}

View File

@ -0,0 +1,30 @@
package fr.chteufleur.mytrackingdog.models.beans;
import java.util.ArrayList;
public class MyLocationArray extends ArrayList<MyLocation> {
private MyLocation firstLocation = null;
private MyLocation lastLocation = null;
@Override
public boolean add(MyLocation loc) {
if (firstLocation == null || loc.getTime() < firstLocation.getTime()) {
firstLocation = loc;
}
if (lastLocation == null || loc.getTime() > lastLocation.getTime()) {
lastLocation = loc;
}
return super.add(loc);
}
public MyLocation getFirstLocation() {
return firstLocation;
}
public MyLocation getLastLocation() {
return lastLocation;
}
}

View File

@ -22,6 +22,7 @@ import fr.chteufleur.mytrackingdog.models.Gpx;
import fr.chteufleur.mytrackingdog.models.ImportGpx;
import fr.chteufleur.mytrackingdog.models.Traces;
import fr.chteufleur.mytrackingdog.models.beans.MyLocation;
import fr.chteufleur.mytrackingdog.models.beans.MyLocationArray;
import fr.chteufleur.mytrackingdog.models.beans.TraceLocation;
import fr.chteufleur.mytrackingdog.models.beans.WayPointLocation;
@ -152,13 +153,13 @@ public class ServiceGps extends Observable implements IServiceGps, LocationListe
return currentLocation;
}
public List<MyLocation> getListGeoPointTraceur() {
public MyLocationArray getListGeoPointTraceur() {
return traces.getListPointTraceur();
}
public List<MyLocation> getListGeoPointDog() {
public MyLocationArray getListGeoPointDog() {
return traces.getListPointDog();
}
public List<MyLocation> getListGeoPointObjects() {
public MyLocationArray getListGeoPointObjects() {
return traces.getListPointObjects();
}