Add time spend and found object on dog trace.
This commit is contained in:
parent
49a9fc685d
commit
d9380203d5
|
|
@ -41,7 +41,9 @@ import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider;
|
|||
import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
|
@ -172,7 +174,6 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
this.add_object.setVisibility(View.VISIBLE);
|
||||
this.add_object.setText(R.string.trail_object);
|
||||
this.start_stop_dog_trace.setVisibility(View.GONE);
|
||||
this.textViewCurrentLocation.setVisibility(View.VISIBLE);
|
||||
updateDistance();
|
||||
} else {
|
||||
this.start_stop_trace.setText(R.string.trail_start);
|
||||
|
|
@ -189,11 +190,11 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
this.add_object.setText(R.string.dog_object);
|
||||
this.start_stop_trace.setVisibility(View.GONE);
|
||||
this.textViewCurrentLocation.setVisibility(View.GONE);
|
||||
updateDistance();
|
||||
} else {
|
||||
this.start_stop_dog_trace.setText(R.string.dog_start);
|
||||
this.add_object.setVisibility(View.GONE);
|
||||
this.start_stop_trace.setVisibility(View.VISIBLE);
|
||||
this.textViewCurrentLocation.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -504,6 +505,11 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
lastLocation = loc;
|
||||
} else if (serviceGps.isDogActivated()) {
|
||||
updateDogTrace();
|
||||
if (lastLocation != null) {
|
||||
distance += loc.distanceTo(lastLocation);
|
||||
updateDistance();
|
||||
}
|
||||
lastLocation = loc;
|
||||
}
|
||||
|
||||
float orientation = serviceGps.getOrientation(deviceOrientation);
|
||||
|
|
@ -532,7 +538,35 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
}
|
||||
|
||||
private void updateDistance() {
|
||||
this.textViewCurrentLocation.setText(String.format("Distance: %,dm", ((int) distance)));
|
||||
this.textViewCurrentLocation.setVisibility(View.VISIBLE);
|
||||
String text = null;
|
||||
if (serviceGps.isTraceurActivated()) {
|
||||
text = String.format("Distance: %,dm", ((int) distance));
|
||||
} else if (serviceGps.isDogActivated()) {
|
||||
MyLocation firstLoc = serviceGps.getListGeoPointDog().getFirstLocation();
|
||||
MyLocation lastLoc = serviceGps.getListGeoPointDog().getLastLocation();
|
||||
if (firstLoc != null) {
|
||||
long time = lastLoc.getTime() - firstLoc.getTime();
|
||||
time /= 1_000;
|
||||
long s = (time % 60);
|
||||
time /= 60;
|
||||
long m = (time % 60);
|
||||
time /= 60;
|
||||
long h = (time % 60);
|
||||
text = String.format("%02d:%02d:%02d", h, m, s);
|
||||
|
||||
int nbFoundObject = 0;
|
||||
for (MyLocation loc: serviceGps.getListGeoPointObjects()) {
|
||||
if (loc instanceof WayPointLocation && ((WayPointLocation) loc).isFound()) {
|
||||
nbFoundObject++;
|
||||
}
|
||||
}
|
||||
text += "\t\t\t\t\t\t\t\t"+nbFoundObject+"/"+serviceGps.getListGeoPointObjects().size();
|
||||
}
|
||||
}
|
||||
|
||||
if (text != null) {
|
||||
this.textViewCurrentLocation.setText(text);
|
||||
this.textViewCurrentLocation.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue