Register/unregister onSharedPreferenceChangeListener in onStart and on Stop

This commit is contained in:
Jimmy Shih
2012-10-31 14:43:35 -07:00
parent 620b6e09b5
commit c70e374219
10 changed files with 190 additions and 125 deletions
@@ -62,8 +62,10 @@ public class MapOverlay {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key == null
|| PreferencesUtils.getKey(context, R.string.track_color_mode_key).equals(key)) {
trackPath = TrackPathFactory.getTrackPath(context);
|| key.equals(PreferencesUtils.getKey(context, R.string.track_color_mode_key))) {
trackColorMode = PreferencesUtils.getString(
context, R.string.track_color_mode_key, PreferencesUtils.TRACK_COLOR_MODE_DEFAULT);
trackPath = TrackPathFactory.getTrackPath(context, trackColorMode);
}
}
};
@@ -73,6 +75,8 @@ public class MapOverlay {
private final BlockingQueue<CachedLocation> pendingLocations;
private final List<Waypoint> waypoints;
private String trackColorMode = PreferencesUtils.TRACK_COLOR_MODE_DEFAULT;
private boolean showEndMarker = true;
private TrackPath trackPath;