add listener for updating TrackPointFragment

This commit is contained in:
Chumva 2018-06-25 12:01:53 +03:00
parent fef53c2322
commit c8a76c3de2
3 changed files with 23 additions and 13 deletions

View file

@ -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();
}
}

View file

@ -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);
}
}

View file

@ -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();