From 56b6b5bc0714a4c9ebdbf7e9dd3315877d4e1cd4 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 11 Mar 2014 05:47:12 +0100 Subject: refactoring: remove cache thread operations --- main/src/cgeo/geocaching/CachePopup.java | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'main/src/cgeo/geocaching/CachePopup.java') diff --git a/main/src/cgeo/geocaching/CachePopup.java b/main/src/cgeo/geocaching/CachePopup.java index 700b81c..543be22 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.Scheduler.Inner; import rx.functions.Action1; import rx.schedulers.Schedulers; @@ -125,23 +126,13 @@ public class CachePopup extends AbstractPopupActivity { protected void storeCache(final int listId) { final StoreCacheHandler storeCacheHandler = new StoreCacheHandler(R.string.cache_dialog_offline_save_message); progress.show(CachePopup.this, res.getString(R.string.cache_dialog_offline_save_title), res.getString(R.string.cache_dialog_offline_save_message), true, storeCacheHandler.cancelMessage()); - new StoreCacheThread(listId, storeCacheHandler).start(); - } - } - - private class StoreCacheThread extends Thread { - final private int listId; - final private CancellableHandler handler; - - public StoreCacheThread(final int listId, final CancellableHandler handler) { - this.listId = listId; - this.handler = handler; - } - - @Override - public void run() { - cache.store(listId, handler); - invalidateOptionsMenuCompatible(); + Schedulers.io().schedule(new Action1() { + @Override + public void call(final Inner inner) { + cache.store(listId, storeCacheHandler); + invalidateOptionsMenuCompatible(); + } + }); } } -- cgit v1.1