Search in sources :

Example 1 with MeasurementToolFragment

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);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) Bundle(android.os.Bundle) Fragment(androidx.fragment.app.Fragment) MeasurementToolFragment(net.osmand.plus.measurementtool.MeasurementToolFragment) MapActivity(net.osmand.plus.activities.MapActivity)

Example 2 with MeasurementToolFragment

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();
}
Also used : SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) Bundle(android.os.Bundle) MeasurementToolFragment(net.osmand.plus.measurementtool.MeasurementToolFragment) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Fragment(androidx.fragment.app.Fragment) MenuBottomSheetDialogFragment(net.osmand.plus.base.MenuBottomSheetDialogFragment) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) VoiceLanguageBottomSheetFragment(net.osmand.plus.settings.fragments.VoiceLanguageBottomSheetFragment) MeasurementToolFragment(net.osmand.plus.measurementtool.MeasurementToolFragment)

Aggregations

Bundle (android.os.Bundle)2 Fragment (androidx.fragment.app.Fragment)2 MeasurementToolFragment (net.osmand.plus.measurementtool.MeasurementToolFragment)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 OnBackPressedCallback (androidx.activity.OnBackPressedCallback)1 FragmentManager (androidx.fragment.app.FragmentManager)1 MapActivity (net.osmand.plus.activities.MapActivity)1 MenuBottomSheetDialogFragment (net.osmand.plus.base.MenuBottomSheetDialogFragment)1 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)1 BaseSettingsFragment (net.osmand.plus.settings.fragments.BaseSettingsFragment)1 VoiceLanguageBottomSheetFragment (net.osmand.plus.settings.fragments.VoiceLanguageBottomSheetFragment)1