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.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder; import android.support.v7.app.AlertDialog.Builder;
@ -214,7 +215,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public MapContextMenu() { 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); 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 (init(latLon, pointDescription, object)) {
if (!MapContextMenuFragment.showInstance(this, mapActivity, centerMarker)) { if (!MapContextMenuFragment.showInstance(this, mapActivity, centerMarker)) {
active = false; 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) { if (object != null) {
for (OsmandMapLayer l : mapActivity.getMapView().getLayers()) { for (OsmandMapLayer l : mapActivity.getMapView().getLayers()) {
if (l instanceof ContextMenuLayer.IContextMenuProvider) { 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) { public void applyMovedObject(Object o, LatLon position, ApplyMovedObjectCallback callback) {
if (selectedObjectContextMenuProvider != null if (selectedObjectContextMenuProvider != null) {
&& selectedObjectContextMenuProvider instanceof ContextMenuLayer.IMoveObjectProvider) { if (selectedObjectContextMenuProvider instanceof IMoveObjectProvider) {
final IMoveObjectProvider l = (ContextMenuLayer.IMoveObjectProvider) selectedObjectContextMenuProvider; final IMoveObjectProvider l = (IMoveObjectProvider) selectedObjectContextMenuProvider;
if (l.isObjectMovable(o)) { if (l.isObjectMovable(o)) {
l.applyNewObjectPosition(o, position, callback); l.applyNewObjectPosition(o, position, callback);
}
} }
} else if (mInChangeMarkerPositionMode) {
callback.onApplyMovedObject(true, null);
} }
} }
@ -235,7 +238,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
mMoveMarkerBottomSheetHelper.enterApplyPositionMode(); mMoveMarkerBottomSheetHelper.enterApplyPositionMode();
applyMovedObject(obj, ll, new ApplyMovedObjectCallback() { applyMovedObject(obj, ll, new ApplyMovedObjectCallback() {
@Override @Override
public void onApplyMovedObject(boolean success, Object newObject) { public void onApplyMovedObject(boolean success, @Nullable Object newObject) {
mMoveMarkerBottomSheetHelper.exitApplyPositionMode(); mMoveMarkerBottomSheetHelper.exitApplyPositionMode();
if (success && !cancelApplyingNewMarkerPosition) { if (success && !cancelApplyingNewMarkerPosition) {
mMoveMarkerBottomSheetHelper.hide(); mMoveMarkerBottomSheetHelper.hide();
@ -540,7 +543,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
public interface ApplyMovedObjectCallback { public interface ApplyMovedObjectCallback {
void onApplyMovedObject(boolean success, Object newObject); void onApplyMovedObject(boolean success, @Nullable Object newObject);
boolean isCancelled(); boolean isCancelled();
} }