From df523e8a6c019efe419b96d434a7ed73400393aa Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Mon, 6 Jan 2014 17:34:38 +0100 Subject: fix #3521: GPS would stay on after a cache list refresh The previous fix for #3521 was incomplete and only reduced the time window during which the GPS could be turned on in a race condition (4c5ef68f45a2b35537b89f857c1aa9fcb117ae83). This one prevents the GPS from being turned on again when the activity is paused (which includes a dead activity as well if the user has left). --- .../geocaching/activity/AbstractListActivity.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'main/src/cgeo/geocaching/activity') diff --git a/main/src/cgeo/geocaching/activity/AbstractListActivity.java b/main/src/cgeo/geocaching/activity/AbstractListActivity.java index a5d5c14..2adae7a 100644 --- a/main/src/cgeo/geocaching/activity/AbstractListActivity.java +++ b/main/src/cgeo/geocaching/activity/AbstractListActivity.java @@ -11,6 +11,7 @@ public abstract class AbstractListActivity extends FragmentListActivity implemen IAbstractActivity { private boolean keepScreenOn = false; + private boolean paused = true; protected CgeoApplication app = null; protected Resources res = null; @@ -84,4 +85,26 @@ public abstract class AbstractListActivity extends FragmentListActivity implemen // initialize action bar title with activity title ActivityMixin.setTitle(this, getTitle()); } + + @Override + public void onResume() { + paused = false; + super.onResume(); + } + + @Override + public void onPause() { + super.onPause(); + paused = true; + } + + /** + * Check if the current activity is paused. This must be called and acted + * upon only from the UI thread. + * + * @return true if the current activity is paused + */ + protected boolean isPaused() { + return paused; + } } -- cgit v1.1