use of net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener in project Osmand by osmandapp.
the class MapMarkersDialogFragment method createOptionsFragmentListener.
private MarkerOptionsFragmentListener createOptionsFragmentListener() {
return new MarkerOptionsFragmentListener() {
final MapActivity mapActivity = getMapActivity();
@Override
public void sortByOnClick() {
if (mapActivity != null) {
OrderByBottomSheetDialogFragment fragment = new OrderByBottomSheetDialogFragment();
fragment.setUsedOnMap(false);
fragment.setListener(createOrderByFragmentListener());
fragment.show(getChildFragmentManager(), OrderByBottomSheetDialogFragment.TAG);
}
}
@Override
public void showDirectionOnClick() {
if (mapActivity != null) {
DirectionIndicationDialogFragment fragment = new DirectionIndicationDialogFragment();
fragment.setListener(createShowDirectionFragmentListener());
fragment.show(getChildFragmentManager(), DirectionIndicationDialogFragment.TAG);
}
}
@Override
public void coordinateInputOnClick() {
if (mapActivity != null) {
CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment();
fragment.setRetainInstance(true);
fragment.setListener(createOnMapMarkersSavedListener());
fragment.show(getChildFragmentManager(), CoordinateInputDialogFragment.TAG);
}
}
@Override
public void buildRouteOnClick() {
if (mapActivity != null) {
if (mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers().isEmpty()) {
Toast.makeText(mapActivity, getString(R.string.plan_route_no_markers_toast), Toast.LENGTH_SHORT).show();
} else {
PlanRouteFragment.showInstance(mapActivity);
MapMarkersDialogFragment.this.dismiss();
}
}
}
@Override
public void saveAsNewTrackOnClick() {
if (mapActivity != null) {
if (mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers().isEmpty()) {
Toast.makeText(mapActivity, getString(R.string.plan_route_no_markers_toast), Toast.LENGTH_SHORT).show();
} else {
SaveAsTrackBottomSheetDialogFragment fragment = new SaveAsTrackBottomSheetDialogFragment();
fragment.setListener(createSaveAsTrackFragmentListener());
fragment.show(getChildFragmentManager(), SaveAsTrackBottomSheetDialogFragment.TAG);
}
}
}
@Override
public void moveAllToHistoryOnClick() {
if (mapActivity != null) {
final MapMarkersHelper helper = mapActivity.getMyApplication().getMapMarkersHelper();
final List<MapMarkersHelper.MapMarker> markers = new ArrayList<>(helper.getMapMarkers());
helper.moveAllActiveMarkersToHistory();
if (viewPager.getCurrentItem() == ACTIVE_MARKERS_POSITION) {
activeFragment.updateAdapter();
} else {
groupsFragment.updateAdapter();
}
snackbar = Snackbar.make(viewPager, R.string.all_markers_moved_to_history, Snackbar.LENGTH_LONG).setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override
public void onClick(View view) {
helper.restoreMarkersFromHistory(markers);
if (viewPager.getCurrentItem() == ACTIVE_MARKERS_POSITION) {
activeFragment.updateAdapter();
} else {
groupsFragment.updateAdapter();
}
}
});
AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark);
snackbar.show();
}
}
@Override
public void dismiss() {
restoreSelectedNavItem();
}
};
}
Aggregations