Fixed moving marker.

This commit is contained in:
GaidamakUA 2016-05-20 17:53:55 +03:00
parent 30f1516a6b
commit 26e6c16a08
2 changed files with 14 additions and 10 deletions

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder;
@ -214,7 +215,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public MapContextMenu() {
}
public boolean init(LatLon latLon, PointDescription pointDescription, Object object) {
public boolean init(LatLon latLon, PointDescription pointDescription, @Nullable Object object) {
return init(latLon, pointDescription, object, false);
}
@ -295,7 +296,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public void show(LatLon latLon, PointDescription pointDescription, Object object) {
public void show(LatLon latLon, PointDescription pointDescription, @Nullable Object object) {
if (init(latLon, pointDescription, object)) {
if (!MapContextMenuFragment.showInstance(this, mapActivity, centerMarker)) {
active = false;
@ -406,7 +407,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
private void setSelectedObject(Object object) {
private void setSelectedObject(@Nullable Object object) {
if (object != null) {
for (OsmandMapLayer l : mapActivity.getMapView().getLayers()) {
if (l instanceof ContextMenuLayer.IContextMenuProvider) {

View file

@ -211,12 +211,15 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
public void applyMovedObject(Object o, LatLon position, ApplyMovedObjectCallback callback) {
if (selectedObjectContextMenuProvider != null
&& selectedObjectContextMenuProvider instanceof ContextMenuLayer.IMoveObjectProvider) {
final IMoveObjectProvider l = (ContextMenuLayer.IMoveObjectProvider) selectedObjectContextMenuProvider;
if (l.isObjectMovable(o)) {
l.applyNewObjectPosition(o, position, callback);
if (selectedObjectContextMenuProvider != null) {
if (selectedObjectContextMenuProvider instanceof IMoveObjectProvider) {
final IMoveObjectProvider l = (IMoveObjectProvider) selectedObjectContextMenuProvider;
if (l.isObjectMovable(o)) {
l.applyNewObjectPosition(o, position, callback);
}
}
} else if (mInChangeMarkerPositionMode) {
callback.onApplyMovedObject(true, null);
}
}
@ -235,7 +238,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
mMoveMarkerBottomSheetHelper.enterApplyPositionMode();
applyMovedObject(obj, ll, new ApplyMovedObjectCallback() {
@Override
public void onApplyMovedObject(boolean success, Object newObject) {
public void onApplyMovedObject(boolean success, @Nullable Object newObject) {
mMoveMarkerBottomSheetHelper.exitApplyPositionMode();
if (success && !cancelApplyingNewMarkerPosition) {
mMoveMarkerBottomSheetHelper.hide();
@ -540,7 +543,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
public interface ApplyMovedObjectCallback {
void onApplyMovedObject(boolean success, Object newObject);
void onApplyMovedObject(boolean success, @Nullable Object newObject);
boolean isCancelled();
}