From 496878826d638367c129b02e66f992202e0d36c9 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Sat, 17 May 2014 08:51:24 +0200 Subject: fix #3255: don't ask for list when storing from history --- main/src/cgeo/geocaching/CacheDetailActivity.java | 3 ++- main/src/cgeo/geocaching/CacheListActivity.java | 22 +++++++++++----------- main/src/cgeo/geocaching/CachePopup.java | 3 ++- main/src/cgeo/geocaching/Geocache.java | 8 ++++---- .../geocaching/connector/oc/OkapiClientTest.java | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 11fe672..7d231c9 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -56,6 +56,7 @@ import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; + import rx.Observable; import rx.Observable.OnSubscribe; import rx.Observer; @@ -1053,7 +1054,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity() { @Override public void call(final Integer selectedListId) { - refreshStored(caches, selectedListId); + // in case of online lists, set the list id to a concrete list now + for (Geocache geocache : caches) { + geocache.setListId(selectedListId); + } + refreshStoredInternal(caches); } }, true, StoredList.TEMPORARY_LIST_ID, newListName); } else { - refreshStored(caches, this.listId); + refreshStoredInternal(caches); } } - private void refreshStored(final List caches, final int storeListId) { + private void refreshStoredInternal(final List caches) { detailProgress = 0; showProgress(false); @@ -1051,7 +1055,7 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA detailProgressTime = System.currentTimeMillis(); - final LoadDetailsThread threadDetails = new LoadDetailsThread(loadDetailsHandler, caches, storeListId); + final LoadDetailsThread threadDetails = new LoadDetailsThread(loadDetailsHandler, caches); threadDetails.start(); } @@ -1124,15 +1128,11 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA private class LoadDetailsThread extends Thread { final private CancellableHandler handler; - final private int listIdLD; final private List caches; - public LoadDetailsThread(CancellableHandler handler, List caches, int listId) { + public LoadDetailsThread(CancellableHandler handler, List caches) { this.handler = handler; this.caches = caches; - - // in case of online lists, set the list id to the standard list - this.listIdLD = Math.max(listId, StoredList.STANDARD_LIST_ID); } @Override @@ -1167,7 +1167,7 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA throw new InterruptedException("Stopped storing process."); } detailProgress++; - cache.refreshSynchronous(listIdLD, null); + cache.refreshSynchronous(null); handler.sendEmptyMessage(cacheList.indexOf(cache)); } catch (final InterruptedException e) { Log.i(e.getMessage()); diff --git a/main/src/cgeo/geocaching/CachePopup.java b/main/src/cgeo/geocaching/CachePopup.java index f91d275..b72b67c 100644 --- a/main/src/cgeo/geocaching/CachePopup.java +++ b/main/src/cgeo/geocaching/CachePopup.java @@ -11,6 +11,7 @@ import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.StringUtils; + import rx.functions.Action0; import rx.functions.Action1; import rx.schedulers.Schedulers; @@ -151,7 +152,7 @@ public class CachePopup extends AbstractPopupActivity { final StoreCacheHandler refreshCacheHandler = new StoreCacheHandler(R.string.cache_dialog_offline_save_message); progress.show(CachePopup.this, res.getString(R.string.cache_dialog_refresh_title), res.getString(R.string.cache_dialog_refresh_message), true, refreshCacheHandler.cancelMessage()); - cache.refresh(cache.getListId(), refreshCacheHandler, Schedulers.io()); + cache.refresh(refreshCacheHandler, Schedulers.io()); } } diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index a88ceca..fdfdbb5 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -1496,19 +1496,19 @@ public class Geocache implements ICache, IWaypoint { } } - public Subscription refresh(final int newListId, final CancellableHandler handler, final Scheduler scheduler) { + public Subscription refresh(final CancellableHandler handler, final Scheduler scheduler) { return scheduler.createWorker().schedule(new Action0() { @Override public void call() { - refreshSynchronous(newListId, handler); + refreshSynchronous(handler); handler.sendEmptyMessage(CancellableHandler.DONE); } }); } - public void refreshSynchronous(final int newListId, final CancellableHandler handler) { + public void refreshSynchronous(final CancellableHandler handler) { DataStore.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); - storeCache(null, geocode, newListId, true, handler); + storeCache(null, geocode, listId, true, handler); } public static void storeCache(Geocache origCache, String geocode, int listId, boolean forceRedownload, CancellableHandler handler) { diff --git a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java index 2c1d06c..0c65d87 100644 --- a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java @@ -44,7 +44,7 @@ public class OkapiClientTest extends CGeoTestCase { assertThat(cache.getWaypoints()).hasSize(3); // load again - cache.refreshSynchronous(cache.getListId(), null); + cache.refreshSynchronous(null); assertThat(cache.getWaypoints()).hasSize(3); } -- cgit v1.1