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 org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
@ -172,7 +174,6 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
||||||
this.add_object.setVisibility(View.VISIBLE);
|
this.add_object.setVisibility(View.VISIBLE);
|
||||||
this.add_object.setText(R.string.trail_object);
|
this.add_object.setText(R.string.trail_object);
|
||||||
this.start_stop_dog_trace.setVisibility(View.GONE);
|
this.start_stop_dog_trace.setVisibility(View.GONE);
|
||||||
this.textViewCurrentLocation.setVisibility(View.VISIBLE);
|
|
||||||
updateDistance();
|
updateDistance();
|
||||||
} else {
|
} else {
|
||||||
this.start_stop_trace.setText(R.string.trail_start);
|
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.add_object.setText(R.string.dog_object);
|
||||||
this.start_stop_trace.setVisibility(View.GONE);
|
this.start_stop_trace.setVisibility(View.GONE);
|
||||||
this.textViewCurrentLocation.setVisibility(View.GONE);
|
this.textViewCurrentLocation.setVisibility(View.GONE);
|
||||||
|
updateDistance();
|
||||||
} else {
|
} else {
|
||||||
this.start_stop_dog_trace.setText(R.string.dog_start);
|
this.start_stop_dog_trace.setText(R.string.dog_start);
|
||||||
this.add_object.setVisibility(View.GONE);
|
this.add_object.setVisibility(View.GONE);
|
||||||
this.start_stop_trace.setVisibility(View.VISIBLE);
|
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;
|
lastLocation = loc;
|
||||||
} else if (serviceGps.isDogActivated()) {
|
} else if (serviceGps.isDogActivated()) {
|
||||||
updateDogTrace();
|
updateDogTrace();
|
||||||
|
if (lastLocation != null) {
|
||||||
|
distance += loc.distanceTo(lastLocation);
|
||||||
|
updateDistance();
|
||||||
|
}
|
||||||
|
lastLocation = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
float orientation = serviceGps.getOrientation(deviceOrientation);
|
float orientation = serviceGps.getOrientation(deviceOrientation);
|
||||||
|
|
@ -532,7 +538,35 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDistance() {
|
private void updateDistance() {
|
||||||
this.textViewCurrentLocation.setText(String.format("Distance: %,dm", ((int) distance)));
|
String text = null;
|
||||||
this.textViewCurrentLocation.setVisibility(View.VISIBLE);
|
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