diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-03-11 05:33:54 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-03-11 05:33:54 +0100 |
| commit | a614e570900e5decc36290a6aa99d055e4ef77c5 (patch) | |
| tree | da6e0cc419873d9aebf830cab4a988edbee9501b /main/src/cgeo/geocaching/Geocache.java | |
| parent | 28696373b58e664d2f14d015698de42ac6eec8f0 (diff) | |
| download | cgeo-a614e570900e5decc36290a6aa99d055e4ef77c5.zip cgeo-a614e570900e5decc36290a6aa99d055e4ef77c5.tar.gz cgeo-a614e570900e5decc36290a6aa99d055e4ef77c5.tar.bz2 | |
refactoring: factor out code for cache refreshing
Diffstat (limited to 'main/src/cgeo/geocaching/Geocache.java')
| -rw-r--r-- | main/src/cgeo/geocaching/Geocache.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 79b4425..f3c2ecd 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -33,13 +33,16 @@ import cgeo.geocaching.utils.MatcherWrapper; import cgeo.geocaching.utils.UncertainProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.Nullable; +import rx.Scheduler; +import rx.Scheduler.Inner; +import rx.Subscription; +import rx.functions.Action1; import android.app.Activity; import android.content.Intent; @@ -1495,7 +1498,17 @@ public class Geocache implements ICache, IWaypoint { } } - public void refresh(int newListId, CancellableHandler handler) { + public Subscription refresh(final int newListId, final CancellableHandler handler, final Scheduler scheduler) { + return scheduler.schedule(new Action1<Inner>() { + @Override + public void call(final Inner inner) { + refreshSynchronous(newListId, handler); + handler.sendEmptyMessage(CancellableHandler.DONE); + } + }); + } + + public void refreshSynchronous(final int newListId, final CancellableHandler handler) { DataStore.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); storeCache(null, geocode, newListId, true, handler); } |
