From 7ea5d005dad8d478fd015efe35cee557968ad1b4 Mon Sep 17 00:00:00 2001 From: vng Date: Tue, 23 Oct 2012 13:15:11 +0300 Subject: [PATCH] [android] Stop location observing if there is no current location ("Question mark") and we pressed "My Position" button. --- .../src/com/mapswithme/maps/MWMActivity.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java index c26ef1c058..f9265a23c2 100644 --- a/android/src/com/mapswithme/maps/MWMActivity.java +++ b/android/src/com/mapswithme/maps/MWMActivity.java @@ -250,16 +250,23 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService if (!state.hasPosition()) { - // first set the button state to "searching" ... - v.setBackgroundResource(R.drawable.myposition_button_normal); - v.setSelected(true); + if (!state.isFirstPosition()) + { + // If first time pressed - start location observing: - // ... and then startLocation, as there could be my_position button - // state changes in the startLocation. - startLocation(); + // Set the button state to "searching" first ... + v.setBackgroundResource(R.drawable.myposition_button_normal); + v.setSelected(true); + + // ... and then call startLocation, as there could be my_position button + // state changes in the startLocation. + startLocation(); + return; + } } else { + // Check if we need to start compass following. if (state.hasCompass()) { if (state.getCompassProcessMode() != LocationState.COMPASS_FOLLOW) @@ -273,14 +280,16 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService else state.stopCompassFollowing(); } - - // first stop location observing ... - stopLocation(); - - // ... and then set button state to default - v.setBackgroundResource(R.drawable.myposition_button_normal); - v.setSelected(false); } + + // Turn off location search: + + // Stop location observing first ... + stopLocation(); + + // ... and then set button state to default. + v.setBackgroundResource(R.drawable.myposition_button_normal); + v.setSelected(false); } private void checkProVersionAvailable()