Skip to content
Snippets Groups Projects
Commit 71467553 authored by Peter Joseph De Jonckheere CESM2014's avatar Peter Joseph De Jonckheere CESM2014
Browse files

Fixed errors? Changed to top 3 places

parent 31dbb4e1
No related branches found
No related tags found
No related merge requests found
......@@ -68,4 +68,8 @@ public class DataAnalysis {
editor.commit();
}
private void placeAnalysis(){
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import com.google.android.gms.awareness.snapshot.PlacesResponse;
import com.google.android.gms.awareness.snapshot.WeatherResponse;
import com.google.android.gms.awareness.state.Weather;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.PlaceLikelihood;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.RuntimeExecutionException;
......@@ -297,22 +298,14 @@ public class SaveFile {
Context.MODE_PRIVATE);
double latitude = Double.longBitsToDouble(preferences.getLong(context.getString(R.string.store_lat), 0));
double longitude = Double.longBitsToDouble(preferences.getLong(context.getString(R.string.store_long), 0));
Type type = new TypeToken<List<PlaceLikelihood>>(){}.getType();
Gson gson = new Gson();
String placelikelihood = preferences.getString(context.getString(R.string.store_place), "");
List<PlaceLikelihood> placeLikelihoods = gson.fromJson(placelikelihood, type);
String place = preferences.getString(context.getString(R.string.store_place), "");
String placeType = String.valueOf(preferences.getInt(context.getString(R.string.store_place_type), 0));
float temperature = preferences.getFloat(context.getString(R.string.store_temp), 0);
String places = "";
String line;
ArrayList<String> contents = new ArrayList<String>();
if(placeLikelihoods != null) {
for (PlaceLikelihood p : placeLikelihoods) {
places = places + " " + String.valueOf(p.getPlace().getName()) + " "
+ String.valueOf(p.getLikelihood() + "\n");
}
}
String writeLine = String.valueOf(latitude) + " " + String.valueOf(longitude) + " " + places
+ String.valueOf(temperature);
String writeLine = String.valueOf(latitude) + " " + String.valueOf(longitude) + " " + place
+ " " + placeType + " " + String.valueOf(temperature);
if (isExternalStorageMounted()) {
File dir = getDirectory(context);
File file = new File(dir, "DATALOG.txt");
......@@ -384,9 +377,20 @@ public class SaveFile {
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
List<PlaceLikelihood> placeLikelihoods = task.getResult().getPlaceLikelihoods();
Gson gson = new Gson();
editor.putString(context.getString(R.string.store_place),
gson.toJson(placeLikelihoods));
for(int i = 0; i < 3; i++) {
try {
PlaceLikelihood placeLikelihood = placeLikelihoods.get(i);
Place place = placeLikelihood.getPlace();
editor.putFloat(context.getString(R.string.store_place_like) +
String.valueOf(i), placeLikelihood.getLikelihood());
editor.putString(context.getString(R.string.store_place)
+ String.valueOf(i), String.valueOf(place.getName()));
editor.putInt(context.getString(R.string.store_place_type)
+ String.valueOf(i), place.getPlaceTypes().get(i));
} catch (NullPointerException e) {
}
}
editor.commit();
}
});
......
......@@ -51,6 +51,7 @@
<string name="store_lat">Latitude</string>
<string name="store_long">Longitude</string>
<string name="store_place">Place</string>
<string name="store_placelike">Place Likelihood</string>
<string name="store_temp">Temperature</string>
<string name="store_place_type">Place Type</string>
<string name="store_place_like">Place Likelihood</string>
</resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment