Small refactoring

This commit is contained in:
Victor Shcherb 2014-11-24 10:39:54 +01:00
parent 1fd9841ea6
commit 73a631decf
6 changed files with 15 additions and 12 deletions

View file

@ -68,7 +68,6 @@ import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
@ -755,7 +754,11 @@ public class MapActivity extends AccessibleActivity implements
return mapView;
}
public static MapViewTrackingUtilities getMapViewTrackingUtilities() {
public MapViewTrackingUtilities getMapViewTrackingUtilities() {
return mapViewTrackingUtilities;
}
public static MapViewTrackingUtilities getSingleMapViewTrackingUtilities() {
return mapViewTrackingUtilities;
}

View file

@ -129,7 +129,7 @@ public class MapActivityLayers {
mapView.addLayer(transportInfoLayer, 5.5f);
// 5.95 all text labels
// 6. point location layer
locationLayer = new PointLocationLayer(MapActivity.getMapViewTrackingUtilities());
locationLayer = new PointLocationLayer(activity.getMapViewTrackingUtilities());
mapView.addLayer(locationLayer, 6);
// 7. point navigation layer
navigationLayer = new PointNavigationLayer(activity);
@ -197,7 +197,7 @@ public class MapActivityLayers {
// mapView.addLayer(transportInfoLayer, 5.5f);
// 5.95 all text labels
// 6. point location layer
locationLayer = new PointLocationLayer(MapActivity.getMapViewTrackingUtilities());
locationLayer = new PointLocationLayer(activity.getMapViewTrackingUtilities());
// mapView.addLayer(locationLayer, 6);
// 7. point navigation layer
navigationLayer = new PointNavigationLayer(activity);

View file

@ -514,7 +514,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
} else if(item.getItemId() == SHOW_ON_MAP_ID) {
if(device != null) {
Location location = device.getLastLocation();
MapActivity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
MapActivity.getSingleMapViewTrackingUtilities().setMapLinkedToLocation(false);
if (location != null){
app.getSettings().setMapLocationToShow(location.getLatitude(), location.getLongitude(), app.getSettings().getLastKnownMapZoom(),
null, device.getVisibleName(), device);
@ -1296,7 +1296,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
@Override
public void updateLocation(Location location) {
MapViewTrackingUtilities mv = MapActivity.getMapViewTrackingUtilities();
MapViewTrackingUtilities mv = MapActivity.getSingleMapViewTrackingUtilities();
if(mv != null && mv.isMapLinkedToLocation() && location != null) {
Location lt = mapLocation;
mapLocation = location;

View file

@ -143,7 +143,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
double lat = o.getLastLocation() == null ? latitude : o.getLastLocation().getLatitude();
double lon = o.getLastLocation() == null ? longitude : o.getLastLocation().getLongitude();
mapActivity.getMapView().setLatLon(lat, lon);
MapActivity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
MapActivity.getSingleMapViewTrackingUtilities().setMapLinkedToLocation(false);
OsMoPositionLayer.setFollowTrackerId(o);
return true;
}

View file

@ -84,17 +84,17 @@ public class MapNavigateControl extends MapControls {
RoutingHelper routingHelper = app.getRoutingHelper();
if(routingHelper.isFollowingMode()) {
routingHelper.setRoutePlanningMode(false);
MapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
} else {
OsmandApplication ctx = mapActivity.getMyApplication();
if(!ctx.getTargetPointsHelper().checkPointToNavigateShort()) {
ri.showDialog();
} else {
MapActivity.getMapViewTrackingUtilities().backToLocationImpl();
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
app.getSettings().FOLLOW_THE_ROUTE.set(true);
routingHelper.setFollowingMode(true);
routingHelper.setRoutePlanningMode(false);
MapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false);
app.getRoutingHelper().notifyIfRouteIsCalculated();
}

View file

@ -162,7 +162,7 @@ public class MapInfoWidgetsFactory {
public boolean updateInfo(DrawSettings drawSettings) {
boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode();
boolean enabled = map.getMyApplication().getLocationProvider().getLastKnownLocation() != null;
boolean tracked = MapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
boolean tracked = map.getMapViewTrackingUtilities().isMapLinkedToLocation();
Drawable d;
if(!enabled) {
d = nightMode ? backToLocDisabledWhite : backToLocDisabled;
@ -183,7 +183,7 @@ public class MapInfoWidgetsFactory {
backToLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity.getMapViewTrackingUtilities().backToLocationImpl();
map.getMapViewTrackingUtilities().backToLocationImpl();
}
});
return backToLocation;