Total time walked gets saved and loaded

This commit is contained in:
Bart
2021-01-12 15:03:46 +01:00
parent 5587c318d0
commit 6edcd7b74f

View File

@@ -63,6 +63,9 @@ public enum Data {
public void addTimeWalked(long time) {
totalTime += time;
editor.putLong("timeWalked", totalTime);
editor.apply();
}
public double getDistanceTraveled() {
@@ -105,8 +108,9 @@ public enum Data {
public void load(){
SharedPreferences prefs = context.getSharedPreferences("Data", Context.MODE_PRIVATE);
this.editor = prefs.edit();
Data.INSTANCE.addDistance(Double.parseDouble(prefs.getString("distanceTraveled", "0")));
this.addDistance(Double.parseDouble(prefs.getString("distanceTraveled", "0")));
this.locationsVisited = loadAndGetVisitedNamesList().size();
this.totalTime = prefs.getLong("timeWalked", 0);
}
public android.location.Location getLocation() {