diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2012-08-14 06:11:40 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2012-08-14 06:11:40 +0200 |
| commit | d91935d5896dc62f8365f749505f8c039dee4e28 (patch) | |
| tree | f2b541139c5711125f274e86c2607c90428a41c0 | |
| parent | ff507a18d017a6ae27bea2c5faf76fa3832162ee (diff) | |
| download | cgeo-d91935d5896dc62f8365f749505f8c039dee4e28.zip cgeo-d91935d5896dc62f8365f749505f8c039dee4e28.tar.gz cgeo-d91935d5896dc62f8365f749505f8c039dee4e28.tar.bz2 | |
bugfix: don't store caches from second loop when interrupted
| -rw-r--r-- | main/src/cgeo/geocaching/cgeocaches.java | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index d735327..50a0d72 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -1386,24 +1386,22 @@ public class cgeocaches extends AbstractListActivity { public void run() { removeGeoAndDir(); - final List<cgCache> weHaveStaticMaps = new ArrayList<cgCache>(selected.size()); + final List<cgCache> cachesWithStaticMaps = new ArrayList<cgCache>(selected.size()); for (cgCache cache : selected) { if (Settings.isStoreOfflineMaps() && StaticMapsProvider.hasStaticMapForCache(cache.getGeocode())) { - weHaveStaticMaps.add(cache); + cachesWithStaticMaps.add(cache); continue; } - try { - refreshCache(cache); - } catch (InterruptedException e) { - Log.i(e.getMessage()); + if (!refreshCache(cache)) { + // in case of interruption avoid the second loop + cachesWithStaticMaps.clear(); + break; } } - for (cgCache cache : weHaveStaticMaps) { - try { - refreshCache(cache); - } catch (InterruptedException e) { - Log.i(e.getMessage()); + for (cgCache cache : cachesWithStaticMaps) { + if (!refreshCache(cache)) { + break; } } @@ -1413,13 +1411,13 @@ public class cgeocaches extends AbstractListActivity { /** * Refreshes the cache information. - * + * * @param cache * The cache to refresh - * @throws InterruptedException - * Interrupted + * @return + * <code>false</code> if the storing was interrupted, <code>true</code> otherwise */ - private void refreshCache(cgCache cache) throws InterruptedException { + private boolean refreshCache(cgCache cache) { try { if (needToStop) { throw new InterruptedException("Stopped storing process."); @@ -1449,12 +1447,14 @@ public class cgeocaches extends AbstractListActivity { yield(); } catch (InterruptedException e) { - throw e; + Log.i(e.getMessage()); + return false; } catch (Exception e) { Log.e("cgeocaches.LoadDetailsThread: " + e.toString()); } last = System.currentTimeMillis(); + return true; } } |
