Merge branch 'master' of github.com:osmandapp/Osmand

This commit is contained in:
Victor Shcherb 2018-05-15 09:35:12 +02:00
commit bf1954de39

View file

@ -455,15 +455,19 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
if (activity == null) { if (activity == null) {
return; return;
} }
GPXFile gpxFile = getGpx(); final GPXFile gpxFile = getGpx();
MapMarkersGroup markersSearch = markersHelper.getMarkersGroup(gpxFile); MapMarkersGroup markersSearch = markersHelper.getMarkersGroup(gpxFile);
final MapMarkersGroup markersGr; final MapMarkersGroup markersGr;
final boolean markersRemoved;
if (markersSearch != null) { if (markersSearch != null) {
markersGr = markersSearch; markersGr = markersSearch;
markersHelper.removeMarkersGroup(markersGr); markersHelper.removeMarkersGroup(markersGr);
markersRemoved = true;
} else if (gpxFile != null) { } else if (gpxFile != null) {
markersGr = markersHelper.addOrEnableGroup(gpxFile); markersGr = markersHelper.addOrEnableGroup(gpxFile);
markersRemoved = false;
} else { } else {
markersRemoved = false;
markersGr = null; markersGr = null;
} }
if (markersGr != null) { if (markersGr != null) {
@ -476,14 +480,24 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
fragmentAdapter.closeFabMenu(activity); fragmentAdapter.closeFabMenu(activity);
fragmentAdapter.updateMenuFabVisibility(false); fragmentAdapter.updateMenuFabVisibility(false);
} }
Snackbar snackbar = Snackbar.make(mainView, R.string.waypoints_removed_from_map_markers, Snackbar snackbar = Snackbar.make(mainView, markersRemoved ?
R.string.waypoints_removed_from_map_markers : R.string.waypoints_added_to_map_markers,
Snackbar.LENGTH_LONG) Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_undo, new View.OnClickListener() { .setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
TrackActivity trackActivity = getTrackActivity(); TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null) { if (trackActivity != null) {
markersHelper.removeMarkersGroup(markersGr); if (markersRemoved) {
if (gpxFile != null) {
markersHelper.addOrEnableGroup(gpxFile);
}
} else {
MapMarkersGroup group = markersHelper.getMarkersGroup(gpxFile);
if (group != null) {
markersHelper.removeMarkersGroup(group);
}
}
trackActivity.invalidateOptionsMenu(); trackActivity.invalidateOptionsMenu();
} }
} }