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

Small changes

parent c08a827f
No related branches found
No related tags found
No related merge requests found
......@@ -76,13 +76,14 @@ public class DataAnalysis {
}
static void placeAnalysis(Context context){
SharedPreferences preferences = context.getSharedPreferences(context.getString(R.string.preference_file_key), Context.MODE_PRIVATE);
int acknowledged = preferences.getInt(context.getString(R.string.store_last_ack), 0);
List<Place> places = SaveFile.getPlaces(context);
Object[] sortedPlaces = (quicksort(places.toArray(), 0, places.size()-1));
int popularType = getPopularElement(sortedPlaces);
SaveFile.writePopularType(context, popularType);
SaveFile.writePopularType(context, popularType, acknowledged);
int mostPopular = SaveFile.findMostPopularType(context);
Toast.makeText(context, String.valueOf(mostPopular), Toast.LENGTH_LONG).show();
SharedPreferences preferences = context.getSharedPreferences(context.getString(R.string.preference_file_key), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt(context.getString(R.string.store_mcp), mostPopular);
editor.commit();
......
......@@ -76,6 +76,10 @@ public class SaveFile {
String line;
String prevLine = null;
String[] items;
SharedPreferences shared = context.getSharedPreferences(context.getString(R.string.preference_file_key), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = shared.edit();
editor.putInt(context.getString(R.string.store_last_ack), acknowledged);
editor.commit();
//Checks for external storage
if (isExternalStorageMounted()) {
File dir = getDirectory(context);
......@@ -358,7 +362,6 @@ public class SaveFile {
}
}
DataAnalysis.placeAnalysis(context);
}
......@@ -467,7 +470,7 @@ public class SaveFile {
return places;
}
static void writePopularType(Context context, int popularType) {
static void writePopularType(Context context, int popularType, int acknowledged) {
String line = "";
ArrayList<String> contents = new ArrayList<String>();
boolean matched = false;
......@@ -497,14 +500,16 @@ public class SaveFile {
if (items[0].equals(String.valueOf(popularType))) {
int no = Integer.parseInt(items[1].trim());
no++;
bw.write(items[0] + " " + String.valueOf(no));
int ack = Integer.parseInt(items[2].trim());
ack += acknowledged;
bw.write(items[0] + " " + String.valueOf(no) + " " + ack);
matched = true;
}else{
bw.write(s);
}
}
if(!matched){
bw.write(String.valueOf(popularType) + " " + String.valueOf(1));
bw.write(String.valueOf(popularType) + " " + String.valueOf(1) + " " + acknowledged);
}
bw.close();
}
......@@ -516,7 +521,6 @@ public class SaveFile {
static int findMostPopularType(Context context) {
String line = "";
ArrayList<String> contents = new ArrayList<String>();
boolean matched = false;
if (isExternalStorageMounted()) {
File dir = getDirectory(context);
File file = new File(dir, "POPLOG.txt");
......
......@@ -55,4 +55,5 @@
<string name="store_place_type">Place Type</string>
<string name="store_place_like">Place Likelihood</string>
<string name="store_mcp">Most Common Place</string>
<string name="store_last_ack">Last Acknowledgement</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