aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/CacheDetailActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/CacheDetailActivity.java')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 0fb9d14..1e1a707 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -66,10 +66,12 @@ import org.eclipse.jdt.annotation.Nullable;
import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
+import rx.Subscription;
import rx.android.observables.AndroidObservable;
import rx.functions.Action0;
import rx.functions.Action1;
import rx.subscriptions.CompositeSubscription;
+import rx.subscriptions.Subscriptions;
import android.R.color;
import android.app.AlertDialog;
@@ -170,6 +172,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
*/
private Waypoint selectedWaypoint;
+ private boolean requireGeodata;
+ private Subscription geoDataSubscription = Subscriptions.empty();
+
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState, R.layout.cachedetail_activity);
@@ -234,7 +239,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
finish();
return;
}
- } else if (uriHost.contains("opencaching.de")) {
+ } else if (uriHost.contains("opencaching.de") || uriHost.contains("opencaching.fr")) {
if (StringUtils.startsWith(uriPath, "/oc")) {
geocode = uriPath.substring(1).toUpperCase(Locale.US);
} else {
@@ -292,8 +297,11 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
if (getPage(position) == Page.IMAGES) {
loadCacheImages();
}
+ requireGeodata = getPage(position) == Page.DETAILS;
+ startOrStopGeoDataListener();
}
});
+ requireGeodata = pageToOpen == 1;
final String realGeocode = geocode;
final String realGuid = guid;
@@ -322,9 +330,17 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
outState.putInt(STATE_PAGE_INDEX, getCurrentItem());
}
+ private void startOrStopGeoDataListener() {
+ geoDataSubscription.unsubscribe();
+ if (requireGeodata) {
+ geoDataSubscription = locationUpdater.start(GeoDirHandler.UPDATE_GEODATA);
+ }
+ }
+
@Override
public void onResume() {
- super.onResume(locationUpdater.start(GeoDirHandler.UPDATE_GEODATA));
+ super.onResume();
+ startOrStopGeoDataListener();
if (refreshOnResume) {
notifyDataSetChanged();
@@ -333,6 +349,12 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
@Override
+ public void onPause() {
+ geoDataSubscription.unsubscribe();
+ super.onPause();
+ }
+
+ @Override
public void onDestroy() {
createSubscriptions.unsubscribe();
super.onDestroy();
@@ -909,9 +931,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
public void call(final Integer selectedListId) {
storeCache(selectedListId, new StoreCacheHandler(CacheDetailActivity.this, progress));
}
- }, true, StoredList.TEMPORARY_LIST_ID);
+ }, true, StoredList.TEMPORARY_LIST.id);
} else {
- storeCache(StoredList.TEMPORARY_LIST_ID, new StoreCacheHandler(this, progress));
+ storeCache(StoredList.TEMPORARY_LIST.id, new StoreCacheHandler(this, progress));
}
}