Merge pull request #10142 from osmandapp/fix_favorite_replace
Fix replacing a Favorite is faulty
This commit is contained in:
commit
12ae33ef8f
2 changed files with 14 additions and 7 deletions
|
@ -20,6 +20,7 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
|
@ -32,6 +33,8 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -83,16 +86,20 @@ public class FavoriteDialogs {
|
|||
dlgHolder[0].dismiss();
|
||||
}
|
||||
FavouritePoint point = (FavouritePoint) args.getSerializable(KEY_FAVORITE);
|
||||
if (helper.editFavourite(fp, point.getLatitude(), point.getLongitude())) {
|
||||
if (point != null && helper.editFavourite(fp, point.getLatitude(), point.getLongitude())) {
|
||||
helper.deleteFavourite(point);
|
||||
if (activity instanceof MapActivity) {
|
||||
((MapActivity) activity).getContextMenu()
|
||||
MapActivity mapActivity = (MapActivity) activity;
|
||||
Fragment fragment = mapActivity.getSupportFragmentManager()
|
||||
.findFragmentByTag(FavoritePointEditor.TAG);
|
||||
if (fragment instanceof FavoritePointEditorFragmentNew) {
|
||||
((FavoritePointEditorFragmentNew) fragment).exitEditing();
|
||||
}
|
||||
mapActivity.getContextMenu()
|
||||
.show(new LatLon(point.getLatitude(), point.getLongitude()), fp.getPointDescription(activity), fp);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
}
|
||||
}
|
||||
if (activity instanceof MapActivity) {
|
||||
((MapActivity) activity).getMapView().refreshMap();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
|
|
|
@ -942,7 +942,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
}
|
||||
}
|
||||
|
||||
private void exitEditing() {
|
||||
public void exitEditing() {
|
||||
cancelled = true;
|
||||
dismiss();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue