This commit is contained in:
PavelRatushny 2017-11-10 10:15:00 +02:00
parent e462afc10e
commit 61035e2a83

View file

@ -587,7 +587,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
private void enterMapMarkersMode() {
if (getSettings().USE_MAP_MARKERS.get()) {
addMapMarkersSyncGroup();
if (getGpxDataItem() != null) {
addMapMarkersSyncGroup();
}
} else {
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {
@ -629,39 +631,36 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
private void addMapMarkersSyncGroup() {
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
GpxDataItem gpxDataItem = getGpxDataItem();
if (gpxDataItem != null) {
File gpx = gpxDataItem.getFile();
MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpx.getAbsolutePath(),
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE);
markersHelper.addMarkersSyncGroup(syncGroup);
markersHelper.syncGroup(syncGroup);
GPXFile gpxFile = getTrackActivity().getGpx();
if (gpxFile != null) {
app.getSelectedGpxHelper().selectGpxFile(gpxFile, true, false);
}
hideTransparentOverlay();
closeMenu();
updateMenuFabVisibility(false);
Snackbar snackbar = Snackbar.make(mainView, getResources().getString(R.string.waypoints_added_to_map_markers), Snackbar.LENGTH_LONG)
.setAction(getResources().getString(R.string.view), new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity.launchMapActivityMoveToTop(getTrackActivity(), MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS);
}
});
snackbar.addCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar transientBottomBar, int event) {
updateMenuFabVisibility(true);
super.onDismissed(transientBottomBar, event);
}
});
View snackBarView = snackbar.getView();
TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action);
tv.setTextColor(ContextCompat.getColor(getContext(), R.color.color_dialog_buttons_dark));
snackbar.show();
File gpx = getGpxDataItem().getFile();
MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpx.getAbsolutePath(),
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE);
markersHelper.addMarkersSyncGroup(syncGroup);
markersHelper.syncGroup(syncGroup);
GPXFile gpxFile = getTrackActivity().getGpx();
if (gpxFile != null) {
app.getSelectedGpxHelper().selectGpxFile(gpxFile, true, false);
}
hideTransparentOverlay();
closeMenu();
updateMenuFabVisibility(false);
Snackbar snackbar = Snackbar.make(mainView, getResources().getString(R.string.waypoints_added_to_map_markers), Snackbar.LENGTH_LONG)
.setAction(getResources().getString(R.string.view), new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity.launchMapActivityMoveToTop(getTrackActivity(), MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS);
}
});
snackbar.addCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar transientBottomBar, int event) {
updateMenuFabVisibility(true);
super.onDismissed(transientBottomBar, event);
}
});
View snackBarView = snackbar.getView();
TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action);
tv.setTextColor(ContextCompat.getColor(getContext(), R.color.color_dialog_buttons_dark));
snackbar.show();
}
private void updateMenuFabVisibility(boolean visible) {