Search in sources :

Example 1 with RouteOptionsBottomSheet

use of net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet in project Osmand by osmandapp.

the class ElevationDateBottomSheet method createReliefFactorButtons.

private void createReliefFactorButtons(Context context) {
    for (int i = 0; i < parameters.size(); i++) {
        RoutingParameter parameter = parameters.get(i);
        final BottomSheetItemWithCompoundButton[] preferenceItem = new BottomSheetItemWithCompoundButton[1];
        preferenceItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(i == selectedEntryIndex).setButtonTintList(createColorStateList(context, nightMode)).setTitle(getRoutingParameterTitle(app, parameter)).setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left).setTag(i).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                selectedEntryIndex = (int) preferenceItem[0].getTag();
                if (selectedEntryIndex >= 0) {
                    RoutingParameter parameter = parameters.get(selectedEntryIndex);
                    updateSelectedParameters(app, appMode, parameters, parameter.getId());
                }
                Fragment target = getTargetFragment();
                if (target instanceof BaseSettingsFragment) {
                    ((BaseSettingsFragment) target).updateSetting(useHeightPref.getId());
                }
                if (target instanceof RouteOptionsBottomSheet) {
                    ((RouteOptionsBottomSheet) target).updateMenuItems();
                }
                updateReliefButtons();
                app.runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        dismiss();
                    }
                }, 500);
            }
        }).create();
        items.add(preferenceItem[0]);
        reliefFactorButtons.add(preferenceItem[0]);
    }
}
Also used : RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) RouteOptionsBottomSheet(net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) View(android.view.View) BooleanPreferenceBottomSheet.updateCustomButtonView(net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView) TextView(android.widget.TextView) BooleanPreferenceBottomSheet.getCustomButtonView(net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView) Fragment(androidx.fragment.app.Fragment) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) MenuBottomSheetDialogFragment(net.osmand.plus.base.MenuBottomSheetDialogFragment) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)

Aggregations

View (android.view.View)1 TextView (android.widget.TextView)1 Fragment (androidx.fragment.app.Fragment)1 MenuBottomSheetDialogFragment (net.osmand.plus.base.MenuBottomSheetDialogFragment)1 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)1 RouteOptionsBottomSheet (net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet)1 BooleanPreferenceBottomSheet.getCustomButtonView (net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView)1 BooleanPreferenceBottomSheet.updateCustomButtonView (net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView)1 BaseSettingsFragment (net.osmand.plus.settings.fragments.BaseSettingsFragment)1 RoutingParameter (net.osmand.router.GeneralRouter.RoutingParameter)1