small refactoring
This commit is contained in:
parent
eb2fb10386
commit
bdea91f755
1 changed files with 7 additions and 7 deletions
|
@ -405,7 +405,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
backToLocation.setOnClickListener(new View.OnClickListener() {
|
backToLocation.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
onBackToLocationClick(false);
|
onBackToLocation(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
backToLocation.setOnLongClickListener(new View.OnLongClickListener() {
|
backToLocation.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
onBackToLocationClick(true);
|
onBackToLocation(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -424,9 +424,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
return backToLocationButton;
|
return backToLocationButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBackToLocationClick(boolean longClick) {
|
private void onBackToLocation(boolean showLocationMenu) {
|
||||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
||||||
if (longClick) {
|
if (showLocationMenu) {
|
||||||
showContextMenuForMyLocation();
|
showContextMenuForMyLocation();
|
||||||
} else if (!mapActivity.getContextMenu().isVisible()) {
|
} else if (!mapActivity.getContextMenu().isVisible()) {
|
||||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||||
|
@ -440,9 +440,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private void showContextMenuForMyLocation() {
|
private void showContextMenuForMyLocation() {
|
||||||
OsmAndLocationProvider lp = app.getLocationProvider();
|
OsmAndLocationProvider lp = app.getLocationProvider();
|
||||||
net.osmand.Location lastKnownLocation = lp.getLastKnownLocation();
|
Location lastKnownLocation = lp.getLastKnownLocation();
|
||||||
net.osmand.Location lastStaleKnownLocation = lp.getLastStaleKnownLocation();
|
Location lastStaleKnownLocation = lp.getLastStaleKnownLocation();
|
||||||
net.osmand.Location location = lastKnownLocation != null ? lastKnownLocation : lastStaleKnownLocation;
|
Location location = lastKnownLocation != null ? lastKnownLocation : lastStaleKnownLocation;
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
ContextMenuLayer cml = mapActivity.getMapView().getLayerByClass(ContextMenuLayer.class);
|
ContextMenuLayer cml = mapActivity.getMapView().getLayerByClass(ContextMenuLayer.class);
|
||||||
if (cml != null) {
|
if (cml != null) {
|
||||||
|
|
Loading…
Reference in a new issue