From 9b21feb441456a4946997069796bda288e1a49c1 Mon Sep 17 00:00:00 2001 From: Marco Jacob Date: Sun, 25 Mar 2012 21:44:07 +0200 Subject: no second dialog when skipping static maps on GPXImporter --- main/src/cgeo/geocaching/files/GPXImporter.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/files/GPXImporter.java b/main/src/cgeo/geocaching/files/GPXImporter.java index 8224437..7efda60 100644 --- a/main/src/cgeo/geocaching/files/GPXImporter.java +++ b/main/src/cgeo/geocaching/files/GPXImporter.java @@ -146,7 +146,11 @@ public class GPXImporter { if (Settings.isStoreOfflineMaps() || Settings.isStoreOfflineWpMaps()) { importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_STORE_STATIC_MAPS, R.string.gpx_import_store_static_maps, search.getCount())); - importStaticMaps(search); + boolean finishedWithoutCancel = importStaticMaps(search); + // Skip last message if static maps where canceled + if (!finishedWithoutCancel) { + return; + } } importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_FINISHED, search.getCount(), 0, search)); @@ -185,7 +189,7 @@ public class GPXImporter { return search; } - private void importStaticMaps(final SearchResult importedCaches) { + private boolean importStaticMaps(final SearchResult importedCaches) { final cgeoapplication app = cgeoapplication.getInstance(); int storedCacheMaps = 0; for (String geocode : importedCaches.getGeocodes()) { @@ -194,10 +198,11 @@ public class GPXImporter { StaticMapsProvider.downloadMaps(cache, app); storedCacheMaps++; if (progressHandler.isCancelled()) { - return; + return false; } progressHandler.sendMessage(progressHandler.obtainMessage(0, storedCacheMaps, 0)); } + return true; } } -- cgit v1.1 From 4b590dbb7acb120df2f85fc7ea9f165658299b3e Mon Sep 17 00:00:00 2001 From: Marco Jacob Date: Sun, 25 Mar 2012 22:19:32 +0200 Subject: Reset Progress internal var progress to 0 on reset --- main/src/cgeo/geocaching/activity/Progress.java | 1 + main/src/cgeo/geocaching/files/GPXImporter.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/activity/Progress.java b/main/src/cgeo/geocaching/activity/Progress.java index fc64c01..dbe4700 100644 --- a/main/src/cgeo/geocaching/activity/Progress.java +++ b/main/src/cgeo/geocaching/activity/Progress.java @@ -70,6 +70,7 @@ public class Progress { dialog.setMax(modMax); dialog.setProgress(0); } + this.progress = 0; } public synchronized void setProgress(final int progress) { diff --git a/main/src/cgeo/geocaching/files/GPXImporter.java b/main/src/cgeo/geocaching/files/GPXImporter.java index 7efda60..7d992ac 100644 --- a/main/src/cgeo/geocaching/files/GPXImporter.java +++ b/main/src/cgeo/geocaching/files/GPXImporter.java @@ -399,10 +399,10 @@ public class GPXImporter { break; case IMPORT_STEP_STORE_CACHES: - showProgressAfterCancel = true; progress.setProgressDivider(1); progress.setMessage(res.getString(msg.arg1)); progress.setMaxProgressAndReset(msg.arg2); + showProgressAfterCancel = true; break; case IMPORT_STEP_STORE_STATIC_MAPS: -- cgit v1.1