Restored replace existing favorite feature
This commit is contained in:
parent
d6acfc67f5
commit
a13498f794
2 changed files with 29 additions and 3 deletions
|
@ -22,6 +22,7 @@ import android.widget.Toast;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
|
@ -57,8 +58,10 @@ public class FavoriteDialogs {
|
|||
}
|
||||
FavouritePoint point = (FavouritePoint) args.getSerializable(KEY_FAVORITE);
|
||||
if (helper.editFavourite(fp, point.getLatitude(), point.getLongitude())) {
|
||||
AccessibleToast.makeText(activity, activity.getString(R.string.fav_points_edited),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
if (activity instanceof MapActivity) {
|
||||
((MapActivity) activity).getContextMenu()
|
||||
.show(new LatLon(point.getLatitude(), point.getLongitude()), fp.getPointDescription(), fp);
|
||||
}
|
||||
}
|
||||
if (activity instanceof MapActivity) {
|
||||
((MapActivity) activity).getMapView().refreshMap();
|
||||
|
|
|
@ -7,6 +7,10 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -17,6 +21,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -38,7 +43,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
boolean light = getMyApplication().getSettings().isLightContent();
|
||||
|
@ -48,6 +53,24 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
group = helper.getGroup(favorite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view != null && editor.isNew()) {
|
||||
Button btnReplace = (Button) view.findViewById(R.id.button_replace);
|
||||
btnReplace.setVisibility(View.VISIBLE);
|
||||
btnReplace.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(FavoriteDialogs.KEY_FAVORITE, favorite);
|
||||
FavoriteDialogs.createReplaceFavouriteDialog(getActivity(), args);
|
||||
}
|
||||
});
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointEditor getEditor() {
|
||||
return editor;
|
||||
|
|
Loading…
Reference in a new issue