use of net.osmand.plus.measurementtool.MeasurementToolFragment in project Osmand by osmandapp.
the class NavigationFragment method setupOnBackPressedCallback.
private void setupOnBackPressedCallback() {
OnBackPressedCallback callback = new OnBackPressedCallback(true) {
public void handleOnBackPressed() {
MapActivity mapActivity = getMapActivity();
Bundle args = getArguments();
if (mapActivity != null && args != null) {
String dialogModeName = args.getString(DIALOG_MODE_KEY, null);
if (DialogMode.getModeByName(dialogModeName) == DialogMode.PLAN_ROUTE) {
FragmentManager fm = mapActivity.getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(MeasurementToolFragment.TAG);
if (fragment != null) {
RouteOptionsBottomSheet.showInstance(mapActivity, fragment, DialogMode.PLAN_ROUTE, getSelectedAppMode().getStringKey());
((MeasurementToolFragment) fragment).getOnBackPressedCallback().setEnabled(true);
}
}
}
dismiss();
}
};
requireMyActivity().getOnBackPressedDispatcher().addCallback(this, callback);
}
use of net.osmand.plus.measurementtool.MeasurementToolFragment in project Osmand by osmandapp.
the class RouteOptionsBottomSheet method createOtherSettingsRoutingItem.
private BaseBottomSheetItem createOtherSettingsRoutingItem(final LocalRoutingParameter optionsItem) {
return new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(optionsItem.getActiveIconId())).setTitle(getString(R.string.routing_settings_2)).setLayoutId(R.layout.bottom_sheet_item_simple_56dp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
if (dialogMode == DialogMode.PLAN_ROUTE) {
Fragment fragment = getTargetFragment();
if (fragment instanceof MeasurementToolFragment) {
((MeasurementToolFragment) fragment).getOnBackPressedCallback().setEnabled(false);
}
}
Bundle args = new Bundle();
args.putString(DIALOG_MODE_KEY, dialogMode.name());
BaseSettingsFragment.showInstance(mapActivity, SettingsScreenType.NAVIGATION, applicationMode, args, null);
}
}).create();
}
Aggregations