+ sauvegarde des résultats

This commit is contained in:
nicobo 2012-11-10 13:44:44 +01:00
parent c377cfe4dd
commit 2e1ad141d1
29 changed files with 125 additions and 4 deletions

View file

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="groomservice.dataprovence"
package="bma.groomservice.dataprovence"
android:versionCode="1"
android:versionName="1.0">

View file

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="groomservice.dataprovence"
package="bma.groomservice.dataprovence"
android:versionCode="1"
android:versionName="1.0">

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,6 @@
/** Automatically generated file. DO NOT MODIFY */
package bma.groomservice.dataprovence;
public final class BuildConfig {
public final static boolean DEBUG = true;
}

View file

@ -0,0 +1,47 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package bma.groomservice.dataprovence;
public final class R {
public static final class attr {
}
public static final class drawable {
public static int ic_launcher=0x7f020000;
}
public static final class string {
public static int app_name=0x7f030000;
}
public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
API 11 theme customizations can go here.
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
API 14 theme customizations can go here.
*/
public static int AppBaseTheme=0x7f040000;
/** Application theme.
All customizations that are NOT specific to a particular API-level can go here.
*/
public static int AppTheme=0x7f040001;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
src/LocationDeVelo.json Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
src/Musees.json Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
src/ParcsEtJardins.json Normal file

File diff suppressed because one or more lines are too long

1
src/Plages.json Normal file

File diff suppressed because one or more lines are too long

1
src/Restaurants.json Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
src/SportNautique.json Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,7 @@
package bma.groomservice.data.dataprovence;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@ -15,9 +17,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.os.AsyncTask;
import android.os.Environment;
import bma.groomservice.data.Poi;
import bma.groomservice.data.PoiListener;
import com.google.gson.Gson;
public class DataprovenceManager implements PoiListener {
Logger logger = LoggerFactory.getLogger(DataprovenceManager.class);
@ -54,12 +59,16 @@ public class DataprovenceManager implements PoiListener {
"MonumentsEtStesCulturels" });
}
private final TreeSet<Poi> pois = new TreeSet<Poi>();
private TreeSet<Poi> pois;
private final PoiListener listener;
private int count = 0;
// false -> lit les données en local (fichiers *.json)
// true -> lit les données depuis le net
public static final boolean online = false;
private class LoadDataTask extends
AsyncTask<DataprovenceHelper, Integer, Long> {
List<Poi> taskPois;
@ -101,7 +110,12 @@ public class DataprovenceManager implements PoiListener {
for (String tag : tags) {
String[] datasets = DATASETS.get(tag);
for (int d = 0; d < datasets.length; d++) {
if (online) {
helpers.add(new DataprovenceHelper(datasets[d]));
} else {
helpers.add(new DataprovenceFileHelper(datasets[d]
+ ".json"));
}
}
}
return helpers;
@ -122,6 +136,11 @@ public class DataprovenceManager implements PoiListener {
public void findAll(Collection<String> tags) throws IOException {
synchronized (this) {
count = 0;
pois = new TreeSet<Poi>();
}
Set<DataprovenceHelper> helpers = new HashSet<DataprovenceHelper>();
helpers.addAll(findHelpers(tags));
@ -137,4 +156,38 @@ public class DataprovenceManager implements PoiListener {
public void findAll(String[] tags) throws IOException {
findAll(Arrays.asList(tags));
}
/** Sauvegarde la lise de POIs donnés */
public void save(String filename, List<Poi> pois) throws IOException {
// boolean mExternalStorageAvailable = false;
// boolean mExternalStorageWriteable = false;
// String state = Environment.getExternalStorageState();
//
// if (Environment.MEDIA_MOUNTED.equals(state)) {
// // We can read and write the media
// mExternalStorageAvailable = mExternalStorageWriteable = true;
// } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// // We can only read the media
// mExternalStorageAvailable = true;
// mExternalStorageWriteable = false;
// } else {
// // Something else is wrong. It may be one of many other states, but
// all we need
// // to know is we can neither read nor write
// mExternalStorageAvailable = mExternalStorageWriteable = false;
// }
Gson gson = new Gson();
String out = gson.toJson(pois);
File dir = Environment.getExternalStorageDirectory();
FileOutputStream fos = new FileOutputStream(new File(dir, filename));
fos.write(out.getBytes());
fos.close();
}
/** Sauvegarde l'état courant */
public void save(String filename) throws IOException {
save(filename, new ArrayList<Poi>(pois));
}
}