stuffff
This commit is contained in:
@@ -12,6 +12,7 @@ public enum RouteHandler {
|
|||||||
private Route currentRoute;
|
private Route currentRoute;
|
||||||
private int stepCount = 0;
|
private int stepCount = 0;
|
||||||
private RouteFinishedListener routeFinishedListener;
|
private RouteFinishedListener routeFinishedListener;
|
||||||
|
private long startedTime;
|
||||||
|
|
||||||
private Polyline currentRouteLine;
|
private Polyline currentRouteLine;
|
||||||
|
|
||||||
@@ -40,11 +41,14 @@ public enum RouteHandler {
|
|||||||
isFollowingRoute = false;
|
isFollowingRoute = false;
|
||||||
currentRoute = null;
|
currentRoute = null;
|
||||||
currentRouteLine = null;
|
currentRouteLine = null;
|
||||||
|
StaticData.INSTANCE.addTimeWalked(System.currentTimeMillis()-startedTime);
|
||||||
|
startedTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void followRoute(Route route) {
|
public void followRoute(Route route) {
|
||||||
this.currentRoute = route;
|
this.currentRoute = route;
|
||||||
setFollowingRoute(true);
|
setFollowingRoute(true);
|
||||||
|
startedTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFollowingRoute(Route route) {
|
public boolean isFollowingRoute(Route route) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public enum StaticData {
|
|||||||
INSTANCE;
|
INSTANCE;
|
||||||
private double distanceTraveled = 0;
|
private double distanceTraveled = 0;
|
||||||
private int locationsVisited = 0;
|
private int locationsVisited = 0;
|
||||||
|
private long timeWalkedRoute = 0;
|
||||||
|
|
||||||
private ArrayList<String> visitedNames = new ArrayList<>();
|
private ArrayList<String> visitedNames = new ArrayList<>();
|
||||||
|
|
||||||
@@ -18,6 +19,14 @@ public enum StaticData {
|
|||||||
distanceTraveled += d;
|
distanceTraveled += d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getTimeWalkedRoute() {
|
||||||
|
return timeWalkedRoute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTimeWalked(long time) {
|
||||||
|
timeWalkedRoute += time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getDistanceTraveled() {
|
public double getDistanceTraveled() {
|
||||||
return distanceTraveled;
|
return distanceTraveled;
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ public class HomeFragment extends Fragment implements LocationListener {
|
|||||||
private void displayRoute() {
|
private void displayRoute() {
|
||||||
|
|
||||||
if (RouteHandler.INSTANCE.isFollowingRoute()) {
|
if (RouteHandler.INSTANCE.isFollowingRoute()) {
|
||||||
|
Log.d(TAG, "displayRoute: WE ARE FOLLOWING A ROUTE");
|
||||||
if (roadOverlay == null) {
|
if (roadOverlay == null) {
|
||||||
if (RouteHandler.INSTANCE.getCurrentRouteLine() != null) {
|
if (RouteHandler.INSTANCE.getCurrentRouteLine() != null) {
|
||||||
roadOverlay = RouteHandler.INSTANCE.getCurrentRouteLine();
|
roadOverlay = RouteHandler.INSTANCE.getCurrentRouteLine();
|
||||||
@@ -318,10 +319,12 @@ public class HomeFragment extends Fragment implements LocationListener {
|
|||||||
public void onLocationChanged(@NonNull Location location) {
|
public void onLocationChanged(@NonNull Location location) {
|
||||||
// calculate the distance walked
|
// calculate the distance walked
|
||||||
|
|
||||||
double distance = currentLocation.distanceTo(location); // in meters
|
if (currentLocation != null) {
|
||||||
// can't walk 100 meters in a few seconds
|
double distance = currentLocation.distanceTo(location); // in meters
|
||||||
if (distance < 100)
|
// can't walk 100 meters in a few seconds
|
||||||
StaticData.INSTANCE.addDistance(distance);
|
if (distance < 100)
|
||||||
|
StaticData.INSTANCE.addDistance(distance);
|
||||||
|
}
|
||||||
currentLocation = location;
|
currentLocation = location;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,11 @@ public class StatisticFragment extends Fragment {
|
|||||||
|
|
||||||
TextView distance = view.findViewById(R.id.statistics_km);
|
TextView distance = view.findViewById(R.id.statistics_km);
|
||||||
TextView locs = view.findViewById(R.id.statistics_locations_visited);
|
TextView locs = view.findViewById(R.id.statistics_locations_visited);
|
||||||
|
TextView timeText = view.findViewById(R.id.statistics_time_value);
|
||||||
double dist = StaticData.INSTANCE.getDistanceTraveled()/1000;
|
double dist = StaticData.INSTANCE.getDistanceTraveled()/1000;
|
||||||
distance.setText("" + String.format("%.1f",dist) + " km");
|
distance.setText("" + String.format("%.1f",dist) + " km");
|
||||||
locs.setText("" + StaticData.INSTANCE.getLocationsVisited());
|
locs.setText("" + StaticData.INSTANCE.getLocationsVisited());
|
||||||
|
timeText.setText("" + StaticData.INSTANCE.getTimeWalkedRoute());
|
||||||
|
|
||||||
|
|
||||||
this.couponList = CouponListManager.INSTANCE.getCouponList();
|
this.couponList = CouponListManager.INSTANCE.getCouponList();
|
||||||
|
|||||||
@@ -171,12 +171,12 @@ public enum ApiHandler {
|
|||||||
|
|
||||||
t.start();
|
t.start();
|
||||||
|
|
||||||
//
|
// wait for when we have a result from the api until we can continue, otherwise the route will be drawn before we get the result
|
||||||
// try {
|
try {
|
||||||
// t.join();
|
t.join();
|
||||||
// } catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,7 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/statistics_time_value"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=""
|
android:text=""
|
||||||
|
|||||||
Reference in New Issue
Block a user