Fix weak listeners
This commit is contained in:
parent
c7167cc468
commit
a3b1a04cbd
2 changed files with 10 additions and 7 deletions
|
@ -154,6 +154,7 @@ public class ApplicationMode {
|
||||||
private int arrivalDistance = 90;
|
private int arrivalDistance = 90;
|
||||||
private int bearingIcon = R.drawable.map_pedestrian_bearing;
|
private int bearingIcon = R.drawable.map_pedestrian_bearing;
|
||||||
private int locationIcon = R.drawable.map_pedestrian_location;
|
private int locationIcon = R.drawable.map_pedestrian_location;
|
||||||
|
private static StateChangedListener<String> listener;
|
||||||
|
|
||||||
private ApplicationMode(int key, String stringKey) {
|
private ApplicationMode(int key, String stringKey) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
@ -162,14 +163,14 @@ public class ApplicationMode {
|
||||||
|
|
||||||
public static List<ApplicationMode> values(OsmandSettings settings) {
|
public static List<ApplicationMode> values(OsmandSettings settings) {
|
||||||
if (cachedFilteredValues.isEmpty()) {
|
if (cachedFilteredValues.isEmpty()) {
|
||||||
if (!listenerRegistered) {
|
if (listener == null) {
|
||||||
settings.AVAILABLE_APP_MODES.addListener(new StateChangedListener<String>() {
|
listener = new StateChangedListener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(String change) {
|
public void stateChanged(String change) {
|
||||||
cachedFilteredValues = new ArrayList<ApplicationMode>();
|
cachedFilteredValues = new ArrayList<ApplicationMode>();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
listenerRegistered = true;
|
settings.AVAILABLE_APP_MODES.addListener(listener);
|
||||||
}
|
}
|
||||||
String available = settings.AVAILABLE_APP_MODES.get();
|
String available = settings.AVAILABLE_APP_MODES.get();
|
||||||
cachedFilteredValues = new ArrayList<ApplicationMode>();
|
cachedFilteredValues = new ArrayList<ApplicationMode>();
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
private MapTileLayer overlayLayer;
|
private MapTileLayer overlayLayer;
|
||||||
private MapTileLayer underlayLayer;
|
private MapTileLayer underlayLayer;
|
||||||
|
private StateChangedListener<Integer> overlayLayerListener;
|
||||||
|
|
||||||
public OsmandRasterMapsPlugin(OsmandApplication app) {
|
public OsmandRasterMapsPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
@ -84,13 +85,14 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
underlayLayer = new MapTileLayer(false);
|
underlayLayer = new MapTileLayer(false);
|
||||||
// mapView.addLayer(underlayLayer, -0.5f);
|
// mapView.addLayer(underlayLayer, -0.5f);
|
||||||
overlayLayer = new MapTileLayer(false);
|
overlayLayer = new MapTileLayer(false);
|
||||||
// mapView.addLayer(overlayLayer, 0.7f);
|
overlayLayerListener = new StateChangedListener<Integer>() {
|
||||||
settings.MAP_OVERLAY_TRANSPARENCY.addListener(new StateChangedListener<Integer>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(Integer change) {
|
public void stateChanged(Integer change) {
|
||||||
overlayLayer.setAlpha(change);
|
overlayLayer.setAlpha(change);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
// mapView.addLayer(overlayLayer, 0.7f);
|
||||||
|
settings.MAP_OVERLAY_TRANSPARENCY.addListener(overlayLayerListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue