ctrl alt L

This commit is contained in:
Sem van der Hoeven
2021-01-06 21:19:06 +01:00
parent c778ab2de8
commit c68bbd4062
27 changed files with 142 additions and 165 deletions

View File

@@ -20,7 +20,7 @@ public enum Data {
this.zoom = zoom;
}
private ArrayList<String> visitedNames = new ArrayList<>();
private final ArrayList<String> visitedNames = new ArrayList<>();
public void addDistance(double d) {
distanceTraveled += d;
@@ -51,5 +51,4 @@ public enum Data {
}
}

View File

@@ -2,28 +2,15 @@ package com.a1.nextlocation.data;
import android.content.Context;
import android.content.res.AssetManager;
import android.os.Environment;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.json.JSONArray;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
public class FileIO<T> {
@@ -46,13 +33,13 @@ public class FileIO<T> {
InputStreamReader inputStreamReader = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(inputStreamReader);
String line;
while ((line = reader.readLine())!= null) {
while ((line = reader.readLine()) != null) {
sb.append(line);
}
Log.d(TAG, "readFileData: got string: " + sb.toString());
res = gson.fromJson(sb.toString(),typeOf);
res = gson.fromJson(sb.toString(), typeOf);
Log.d(TAG, "readFileData: got object: " + res);
reader.close();

View File

@@ -33,11 +33,11 @@ public class Location implements Parcelable {
}
public Location(@NotNull String name, double latCoord, double longCoord, String description, @Nullable String imageUrl) {
this(name,getStringFromCoordinates(latCoord,longCoord),description,imageUrl);
this(name, getStringFromCoordinates(latCoord, longCoord), description, imageUrl);
}
public Location(String name, android.location.Location loc, String description, String imageUrl) {
this(name,getStringFromCoordinates(loc.getLatitude(),loc.getLongitude()),description,imageUrl);
this(name, getStringFromCoordinates(loc.getLatitude(), loc.getLongitude()), description, imageUrl);
}
protected Location(Parcel in) {
@@ -89,7 +89,7 @@ public class Location implements Parcelable {
return imageUrl;
}
public String getIconUrl(){
public String getIconUrl() {
return iconUrl;
}
@@ -119,6 +119,7 @@ public class Location implements Parcelable {
/**
* calculates the distance between two coordinates
*
* @param lat1 the first latitude
* @param lon1 the first longitude
* @param lat2 the second latitude
@@ -135,7 +136,7 @@ public class Location implements Parcelable {
double dlat = lat2 - lat1;
double a = Math.pow(Math.sin(dlat / 2), 2)
+ Math.cos(lat1) * Math.cos(lat2)
* Math.pow(Math.sin(dlon / 2),2);
* Math.pow(Math.sin(dlon / 2), 2);
double c = 2 * Math.asin(Math.sqrt(a));
@@ -147,15 +148,15 @@ public class Location implements Parcelable {
// distance = c * r;
// }
// else {
double r = 6371;
distance = c * r;
distance *= 1000;
double r = 6371;
distance = c * r;
distance *= 1000;
// }
return Math.floor(distance);
}
public GeoPoint convertToGeoPoint() {
return new GeoPoint(this.getLat(),this.getLong());
return new GeoPoint(this.getLat(), this.getLong());
}
@Override

View File

@@ -70,7 +70,7 @@ public class Route implements Parcelable {
return totalDistance;
}
public String getImageURL(){
public String getImageURL() {
return this.imageURL;
}

View File

@@ -45,13 +45,13 @@ public enum RouteHandler {
isFollowingRoute = false;
currentRoute = null;
currentRouteLine = null;
Data.INSTANCE.addTimeWalked(System.currentTimeMillis()-startedTime);
Data.INSTANCE.addTimeWalked(System.currentTimeMillis() - startedTime);
startedTime = 0;
}
public void followRoute(Route route) {
if (isFollowingRoute) {
Data.INSTANCE.addTimeWalked(System.currentTimeMillis()-startedTime);
Data.INSTANCE.addTimeWalked(System.currentTimeMillis() - startedTime);
}
this.currentRoute = route;
setFollowingRoute(true);
@@ -61,6 +61,7 @@ public enum RouteHandler {
public boolean isFollowingRoute(Route route) {
return isFollowingRoute && route.equals(currentRoute);
}
public void setFollowingRoute(boolean followingRoute) {
isFollowingRoute = followingRoute;
}