mirror of
https://github.com/nicobo/dataprovence.git
synced 2026-04-10 07:55:35 +02:00
+ sauvegarde des résultats
This commit is contained in:
parent
c377cfe4dd
commit
2e1ad141d1
|
|
@ -1,5 +1,5 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="groomservice.dataprovence"
|
package="bma.groomservice.dataprovence"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="groomservice.dataprovence"
|
package="bma.groomservice.dataprovence"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
BIN
bin/classes/bma/groomservice/dataprovence/BuildConfig.class
Normal file
BIN
bin/classes/bma/groomservice/dataprovence/BuildConfig.class
Normal file
Binary file not shown.
BIN
bin/classes/bma/groomservice/dataprovence/R$attr.class
Normal file
BIN
bin/classes/bma/groomservice/dataprovence/R$attr.class
Normal file
Binary file not shown.
BIN
bin/classes/bma/groomservice/dataprovence/R$drawable.class
Normal file
BIN
bin/classes/bma/groomservice/dataprovence/R$drawable.class
Normal file
Binary file not shown.
BIN
bin/classes/bma/groomservice/dataprovence/R$string.class
Normal file
BIN
bin/classes/bma/groomservice/dataprovence/R$string.class
Normal file
Binary file not shown.
BIN
bin/classes/bma/groomservice/dataprovence/R$style.class
Normal file
BIN
bin/classes/bma/groomservice/dataprovence/R$style.class
Normal file
Binary file not shown.
BIN
bin/classes/bma/groomservice/dataprovence/R.class
Normal file
BIN
bin/classes/bma/groomservice/dataprovence/R.class
Normal file
Binary file not shown.
Binary file not shown.
6
gen/bma/groomservice/dataprovence/BuildConfig.java
Normal file
6
gen/bma/groomservice/dataprovence/BuildConfig.java
Normal 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;
|
||||||
|
}
|
||||||
47
gen/bma/groomservice/dataprovence/R.java
Normal file
47
gen/bma/groomservice/dataprovence/R.java
Normal 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
1
src/CentresEquestres.json
Normal file
1
src/CentresEquestres.json
Normal file
File diff suppressed because one or more lines are too long
1
src/GolfsEtMinigolfs.json
Normal file
1
src/GolfsEtMinigolfs.json
Normal file
File diff suppressed because one or more lines are too long
1
src/LocationDeVelo.json
Normal file
1
src/LocationDeVelo.json
Normal file
File diff suppressed because one or more lines are too long
1
src/MonumentsEtStesCulturels.json
Normal file
1
src/MonumentsEtStesCulturels.json
Normal file
File diff suppressed because one or more lines are too long
1
src/Musees.json
Normal file
1
src/Musees.json
Normal file
File diff suppressed because one or more lines are too long
1
src/ParcsAThemesEtAnimaliers.json
Normal file
1
src/ParcsAThemesEtAnimaliers.json
Normal file
File diff suppressed because one or more lines are too long
1
src/ParcsAcrobatiquesForestiers.json
Normal file
1
src/ParcsAcrobatiquesForestiers.json
Normal file
File diff suppressed because one or more lines are too long
1
src/ParcsEtJardins.json
Normal file
1
src/ParcsEtJardins.json
Normal file
File diff suppressed because one or more lines are too long
1
src/Plages.json
Normal file
1
src/Plages.json
Normal file
File diff suppressed because one or more lines are too long
1
src/Restaurants.json
Normal file
1
src/Restaurants.json
Normal file
File diff suppressed because one or more lines are too long
1
src/RestaurantsGastronomiques.json
Normal file
1
src/RestaurantsGastronomiques.json
Normal file
File diff suppressed because one or more lines are too long
1
src/ServicesDeGuides.json
Normal file
1
src/ServicesDeGuides.json
Normal file
File diff suppressed because one or more lines are too long
1
src/SitesNaturelsIncontournables.json
Normal file
1
src/SitesNaturelsIncontournables.json
Normal file
File diff suppressed because one or more lines are too long
1
src/SportNautique.json
Normal file
1
src/SportNautique.json
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,7 @@
|
||||||
package bma.groomservice.data.dataprovence;
|
package bma.groomservice.data.dataprovence;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -15,9 +17,12 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Environment;
|
||||||
import bma.groomservice.data.Poi;
|
import bma.groomservice.data.Poi;
|
||||||
import bma.groomservice.data.PoiListener;
|
import bma.groomservice.data.PoiListener;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
public class DataprovenceManager implements PoiListener {
|
public class DataprovenceManager implements PoiListener {
|
||||||
|
|
||||||
Logger logger = LoggerFactory.getLogger(DataprovenceManager.class);
|
Logger logger = LoggerFactory.getLogger(DataprovenceManager.class);
|
||||||
|
|
@ -54,12 +59,16 @@ public class DataprovenceManager implements PoiListener {
|
||||||
"MonumentsEtStesCulturels" });
|
"MonumentsEtStesCulturels" });
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TreeSet<Poi> pois = new TreeSet<Poi>();
|
private TreeSet<Poi> pois;
|
||||||
|
|
||||||
private final PoiListener listener;
|
private final PoiListener listener;
|
||||||
|
|
||||||
private int count = 0;
|
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
|
private class LoadDataTask extends
|
||||||
AsyncTask<DataprovenceHelper, Integer, Long> {
|
AsyncTask<DataprovenceHelper, Integer, Long> {
|
||||||
List<Poi> taskPois;
|
List<Poi> taskPois;
|
||||||
|
|
@ -101,7 +110,12 @@ public class DataprovenceManager implements PoiListener {
|
||||||
for (String tag : tags) {
|
for (String tag : tags) {
|
||||||
String[] datasets = DATASETS.get(tag);
|
String[] datasets = DATASETS.get(tag);
|
||||||
for (int d = 0; d < datasets.length; d++) {
|
for (int d = 0; d < datasets.length; d++) {
|
||||||
helpers.add(new DataprovenceHelper(datasets[d]));
|
if (online) {
|
||||||
|
helpers.add(new DataprovenceHelper(datasets[d]));
|
||||||
|
} else {
|
||||||
|
helpers.add(new DataprovenceFileHelper(datasets[d]
|
||||||
|
+ ".json"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return helpers;
|
return helpers;
|
||||||
|
|
@ -122,6 +136,11 @@ public class DataprovenceManager implements PoiListener {
|
||||||
|
|
||||||
public void findAll(Collection<String> tags) throws IOException {
|
public void findAll(Collection<String> tags) throws IOException {
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
|
count = 0;
|
||||||
|
pois = new TreeSet<Poi>();
|
||||||
|
}
|
||||||
|
|
||||||
Set<DataprovenceHelper> helpers = new HashSet<DataprovenceHelper>();
|
Set<DataprovenceHelper> helpers = new HashSet<DataprovenceHelper>();
|
||||||
helpers.addAll(findHelpers(tags));
|
helpers.addAll(findHelpers(tags));
|
||||||
|
|
||||||
|
|
@ -137,4 +156,38 @@ public class DataprovenceManager implements PoiListener {
|
||||||
public void findAll(String[] tags) throws IOException {
|
public void findAll(String[] tags) throws IOException {
|
||||||
findAll(Arrays.asList(tags));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue