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 android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
@ -32,6 +33,8 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
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.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -79,20 +82,24 @@ public class FavoriteDialogs {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if(dlgHolder != null && dlgHolder.length > 0 && dlgHolder[0] != null) {
|
if (dlgHolder != null && dlgHolder.length > 0 && dlgHolder[0] != null) {
|
||||||
dlgHolder[0].dismiss();
|
dlgHolder[0].dismiss();
|
||||||
}
|
}
|
||||||
FavouritePoint point = (FavouritePoint) args.getSerializable(KEY_FAVORITE);
|
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);
|
helper.deleteFavourite(point);
|
||||||
if (activity instanceof MapActivity) {
|
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);
|
.show(new LatLon(point.getLatitude(), point.getLongitude()), fp.getPointDescription(activity), fp);
|
||||||
|
mapActivity.getMapView().refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (activity instanceof MapActivity) {
|
|
||||||
((MapActivity) activity).getMapView().refreshMap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.show();
|
builder.show();
|
||||||
|
|
|
@ -942,7 +942,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exitEditing() {
|
public void exitEditing() {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue