added route calculating time

This commit is contained in:
Sem van der Hoeven
2021-01-06 20:48:45 +01:00
parent 023647d418
commit f3e636f586
2 changed files with 6 additions and 43 deletions

View File

@@ -65,46 +65,4 @@ public class FileIO<T> {
}
return res;
}
// public void writeFileData(T objectToWrite, Context context) {
// //TODO make
// //object naar jsonobject
// //jsonarray toevoegen/maken
// //filewriter naar file
//
// String filename = "";
// if (objectToWrite instanceof Coupon){
// filename = "coupons.json";
// }
//
// if (objectToWrite instanceof Route){
// filename = "routes.json";
// }
//
// if (objectToWrite instanceof Location){
// filename = "locations.json";
// }
//
// try (FileOutputStream fileOutputStream = context.openFileOutput(filename, Context.MODE_PRIVATE)){
// String json = new Gson().toJson(objectToWrite);
//
// fileOutputStream.write(json.getBytes(StandardCharsets.UTF_8));
//
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// /*try (FileWriter fileWriter = new FileWriter(filename)){
//
// String json = new Gson().toJson(objectToWrite);
//
// fileWriter.append(json);
// fileWriter.flush();
//
// } catch (IOException e) {
// e.printStackTrace();
// }*/
// }
}

View File

@@ -74,9 +74,14 @@ public class Route implements Parcelable {
return this.imageURL;
}
public int calculateTotalTimeMinutes() {
// 5 km / h walking speed
return (int) ((totalDistance / 1000) / 5) * 60;
}
public int getTotalTime() {
//TODO calculate total time according to all locations in list
return totalTime;
}