<NME> CachePopup.java
<BEF> package cgeo.geocaching;

import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.utils.Log;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.AndroidRuntimeException;

import org.apache.commons.lang3.StringUtils;
import rx.functions.Action1;

import android.content.Context;
import android.content.Intent;

public class CachePopup extends AbstractActivity {

    protected String geocode = null;


    void showDialog() {
        // DialogFragment.show() will take care of adding the fragment
        // in a transaction.  We also want to remove any currently showing
        // dialog, so make our own transaction and take care of that here.
        final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        final Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);

        // Create and show the dialog.
        final DialogFragment newFragment = CachePopupFragment.newInstance(geocode);
        newFragment.show(ft, "dialog");
    }

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        } catch (final AndroidRuntimeException ex) {
            Log.e("Error requesting no title feature", ex);
        }
        this.setTheme(ActivityMixin.getDialogTheme());


        final Bundle extras = getIntent().getExtras();
        if (extras != null) {
            geocode = extras.getString(Intents.EXTRA_GEOCODE);
        }

        if (StringUtils.isBlank(geocode)) {
            showToast(res.getString(R.string.err_detail_cache_find));

            finish();
            return;
        }
        showDialog();
    }

    public static void startActivity(final Context context, final String geocode) {
        final Intent popupIntent = new Intent(context, CachePopup.class);
        popupIntent.putExtra(Intents.EXTRA_GEOCODE, geocode);

        context.startActivity(popupIntent);
    }

    public static void startActivityAllowTarget(final Activity activity, final String geocode) {
        final Intent popupIntent = new Intent(activity, CachePopup.class);
        popupIntent.putExtra(Intents.EXTRA_GEOCODE, geocode);

        activity.startActivityForResult(popupIntent, AbstractDialogFragment.REQUEST_CODE_TARGET_INFO);
    }
}

            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());
            new RefreshCacheThread(refreshCacheHandler).start();
        }
    }

    private class RefreshCacheThread extends Thread {
        final private CancellableHandler handler;

        public RefreshCacheThread(final CancellableHandler handler) {
            this.handler = handler;
        }

        @Override
        public void run() {
            cache.refresh(cache.getListId(), handler);
            handler.sendEmptyMessage(0);
        }
    }


<MSG> refactoring: factor out code for cache refreshing

<DFF> @@ -12,6 +12,7 @@ import cgeo.geocaching.utils.Log;
 
 import org.apache.commons.lang3.StringUtils;
 import rx.functions.Action1;
+import rx.schedulers.Schedulers;
 
 import android.content.Context;
 import android.content.Intent;
@@ -159,21 +160,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());
-            new RefreshCacheThread(refreshCacheHandler).start();
-        }
-    }
-
-    private class RefreshCacheThread extends Thread {
-        final private CancellableHandler handler;
-
-        public RefreshCacheThread(final CancellableHandler handler) {
-            this.handler = handler;
-        }
-
-        @Override
-        public void run() {
-            cache.refresh(cache.getListId(), handler);
-            handler.sendEmptyMessage(0);
+            cache.refresh(cache.getListId(), refreshCacheHandler, Schedulers.io());
         }
     }
 

refactoring: factor out code for cache refreshing