From c8a76c3de248bc9b3d2efa965edb20e69c1ea646 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 25 Jun 2018 12:01:53 +0300 Subject: [PATCH] add listener for updating TrackPointFragment --- .../mapmarkers/CoordinateInputDialogFragment.java | 14 +++++++------- .../plus/mapmarkers/MapMarkersDialogFragment.java | 12 ++++++------ .../osmand/plus/myplaces/TrackPointFragment.java | 10 ++++++++++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index b5f00e89ec..e3fdc1bd75 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -92,7 +92,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm public static final String ADDED_POINTS_NUMBER_KEY = "added_points_number_key"; private GPXUtilities.GPXFile newGpxFile; - private OnMapMarkersSavedListener listener; + private OnPointsSavedListener listener; protected GPXUtilities.WptPt selectedWpt; private SavingTrackHelper savingTrackHelper; private GpxSelectionHelper selectedGpxHelper; @@ -117,7 +117,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm private boolean compassUpdateAllowed = true; - public void setListener(OnMapMarkersSavedListener listener) { + public void setListener(OnPointsSavedListener listener) { this.listener = listener; } @@ -189,7 +189,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm new SaveGpxAsyncTask(getMyApplication(), gpx,null, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); syncGpx(gpx); if (listener != null) { - listener.onMapMarkersSaved(); + listener.onPointsSaved(); } dismiss(); } @@ -1006,7 +1006,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm hasUnsavedChanges = false; app.getMapMarkersHelper().addOrEnableGroup(getGpx()); if (listener != null) { - listener.onMapMarkersSaved(); + listener.onPointsSaved(); } snackbar = Snackbar.make(mainView, fileName + " " + getString(R.string.is_saved) + ".", Snackbar.LENGTH_LONG) .setAction(R.string.shared_string_show, new View.OnClickListener() { @@ -1041,7 +1041,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm .setAction(R.string.shared_string_undo, new View.OnClickListener() { @Override public void onClick(View view) { - getGpx().addPoint(position, selectedWpt); + getGpx().addPoint(position, wpt); adapter.notifyDataSetChanged(); } }); @@ -1422,7 +1422,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm } } - interface OnMapMarkersSavedListener { - void onMapMarkersSaved(); + public interface OnPointsSavedListener { + void onPointsSaved(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index bfae0e8886..773862659d 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -33,7 +33,7 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TrackActivity; -import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnMapMarkersSavedListener; +import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnPointsSavedListener; import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment.DirectionIndicationFragmentListener; import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener; import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener; @@ -141,7 +141,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm } Fragment coordinateInputDialog = fragmentManager.findFragmentByTag(CoordinateInputDialogFragment.TAG); if (coordinateInputDialog != null) { - ((CoordinateInputDialogFragment) coordinateInputDialog).setListener(createOnMapMarkersSavedListener()); + ((CoordinateInputDialogFragment) coordinateInputDialog).setListener(createOnPointsSavedListener()); } View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container); @@ -293,10 +293,10 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm return (OsmandApplication) getActivity().getApplication(); } - private OnMapMarkersSavedListener createOnMapMarkersSavedListener() { - return new OnMapMarkersSavedListener() { + private OnPointsSavedListener createOnPointsSavedListener() { + return new OnPointsSavedListener() { @Override - public void onMapMarkersSaved() { + public void onPointsSaved() { updateAdapters(); } }; @@ -392,7 +392,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm if (mapActivity != null) { CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment(); fragment.setRetainInstance(true); - fragment.setListener(createOnMapMarkersSavedListener()); + fragment.setListener(createOnPointsSavedListener()); fragment.show(getChildFragmentManager(), CoordinateInputDialogFragment.TAG); } } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index ce70542333..65e9f6e204 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -313,10 +313,20 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements if (fm != null) { CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment(); fragment.setRetainInstance(true); + fragment.setListener(createOnPointsSavedListener()); fragment.show(fm, CoordinateInputDialogFragment.TAG); } } + private CoordinateInputDialogFragment.OnPointsSavedListener createOnPointsSavedListener() { + return new CoordinateInputDialogFragment.OnPointsSavedListener() { + @Override + public void onPointsSaved() { + setContent(); + } + }; + } + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear();