diff options
Diffstat (limited to 'main/src/cgeo/geocaching/files/GPXImporter.java')
| -rw-r--r-- | main/src/cgeo/geocaching/files/GPXImporter.java | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/main/src/cgeo/geocaching/files/GPXImporter.java b/main/src/cgeo/geocaching/files/GPXImporter.java index fb78360..b8dcbb3 100644 --- a/main/src/cgeo/geocaching/files/GPXImporter.java +++ b/main/src/cgeo/geocaching/files/GPXImporter.java @@ -1,11 +1,11 @@ package cgeo.geocaching.files;
+import cgeo.geocaching.Geocache;
import cgeo.geocaching.R;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.StaticMapsProvider;
-import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.cgData;
import cgeo.geocaching.activity.IAbstractActivity;
import cgeo.geocaching.activity.Progress;
import cgeo.geocaching.enumerations.LoadFlags;
@@ -124,7 +124,7 @@ public class GPXImporter { final Handler importStepHandler;
final CancellableHandler progressHandler;
- public ImportThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
+ protected ImportThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
this.listId = listId;
this.importStepHandler = importStepHandler;
this.progressHandler = progressHandler;
@@ -132,14 +132,13 @@ public class GPXImporter { @Override
public void run() {
- final Collection<cgCache> caches;
try {
importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_START));
- caches = doImport();
+ final Collection<Geocache> caches = doImport();
Log.i("Imported successfully " + caches.size() + " caches.");
final SearchResult search = new SearchResult();
- for (cgCache cache : caches) {
+ for (Geocache cache : caches) {
search.addCache(cache);
}
@@ -168,13 +167,12 @@ public class GPXImporter { }
}
- protected abstract Collection<cgCache> doImport() throws IOException, ParserException;
+ protected abstract Collection<Geocache> doImport() throws IOException, ParserException;
private boolean importStaticMaps(final SearchResult importedCaches) {
- final cgeoapplication app = cgeoapplication.getInstance();
int storedCacheMaps = 0;
for (String geocode : importedCaches.getGeocodes()) {
- cgCache cache = app.loadCache(geocode, LoadFlags.LOAD_WAYPOINTS);
+ Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_WAYPOINTS);
Log.d("GPXImporter.ImportThread.importStaticMaps start downloadMaps for cache " + geocode);
StaticMapsProvider.downloadMaps(cache);
storedCacheMaps++;
@@ -196,7 +194,7 @@ public class GPXImporter { }
@Override
- protected Collection<cgCache> doImport() throws IOException, ParserException {
+ protected Collection<Geocache> doImport() throws IOException, ParserException {
Log.i("Import LOC file: " + file.getAbsolutePath());
importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_READ_FILE, R.string.gpx_import_loading_caches, (int) file.length()));
LocParser parser = new LocParser(listId);
@@ -206,12 +204,12 @@ public class GPXImporter { static abstract class ImportGpxThread extends ImportThread {
- public ImportGpxThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
+ protected ImportGpxThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
super(listId, importStepHandler, progressHandler);
}
@Override
- protected Collection<cgCache> doImport() throws IOException, ParserException {
+ protected Collection<Geocache> doImport() throws IOException, ParserException {
try {
// try to parse cache file as GPX 10
return doImport(new GPX10Parser(listId));
@@ -221,7 +219,7 @@ public class GPXImporter { }
}
- protected abstract Collection<cgCache> doImport(GPXParser parser) throws IOException, ParserException;
+ protected abstract Collection<Geocache> doImport(GPXParser parser) throws IOException, ParserException;
}
static class ImportGpxFileThread extends ImportGpxThread {
@@ -233,10 +231,10 @@ public class GPXImporter { }
@Override
- protected Collection<cgCache> doImport(GPXParser parser) throws IOException, ParserException {
+ protected Collection<Geocache> doImport(GPXParser parser) throws IOException, ParserException {
Log.i("Import GPX file: " + cacheFile.getAbsolutePath());
importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_READ_FILE, R.string.gpx_import_loading_caches, (int) cacheFile.length()));
- Collection<cgCache> caches = parser.parse(cacheFile, progressHandler);
+ Collection<Geocache> caches = parser.parse(cacheFile, progressHandler);
final String wptsFilename = getWaypointsFileNameForGpxFile(cacheFile);
if (wptsFilename != null) {
@@ -262,7 +260,7 @@ public class GPXImporter { }
@Override
- protected Collection<cgCache> doImport(GPXParser parser) throws IOException, ParserException {
+ protected Collection<Geocache> doImport(GPXParser parser) throws IOException, ParserException {
Log.i("Import GPX from uri: " + uri);
importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_READ_FILE, R.string.gpx_import_loading_caches, -1));
InputStream is = contentResolver.openInputStream(uri);
@@ -276,13 +274,13 @@ public class GPXImporter { static abstract class ImportGpxZipThread extends ImportGpxThread {
- public ImportGpxZipThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
+ protected ImportGpxZipThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
super(listId, importStepHandler, progressHandler);
}
@Override
- protected Collection<cgCache> doImport(GPXParser parser) throws IOException, ParserException {
- Collection<cgCache> caches = Collections.emptySet();
+ protected Collection<Geocache> doImport(GPXParser parser) throws IOException, ParserException {
+ Collection<Geocache> caches = Collections.emptySet();
// can't assume that GPX file comes before waypoint file in zip -> so we need two passes
// 1. parse GPX files
ZipInputStream zis = new ZipInputStream(getInputStream());
|
