Search in sources :

Example 1 with RadioItem

use of net.osmand.plus.widgets.multistatetoggle.RadioItem in project Osmand by osmandapp.

the class SelectIndexesHelper method showSrtmTypeSelectionDialog.

private void showSrtmTypeSelectionDialog() {
    SrtmDownloadItem srtmItem = (SrtmDownloadItem) downloadItem;
    final RadioItem meterBtn = createSrtmRadioBtn(true);
    final RadioItem feetBtn = createSrtmRadioBtn(false);
    List<RadioItem> radioItems = new ArrayList<>();
    radioItems.add(meterBtn);
    radioItems.add(feetBtn);
    SelectableItem<DownloadItem> preview = createSrtmSelectableItem(srtmItem);
    dialog = ModeSelectionBottomSheet.showInstance(activity, preview, radioItems, true);
    dialog.setDialogStateListener(new DialogStateListener() {

        @Override
        public void onDialogCreated() {
            dialog.setTitle(app.getString(R.string.srtm_unit_format));
            dialog.setPrimaryDescription(app.getString(R.string.srtm_download_single_help_message));
            updateSize();
            dialog.setSelectedMode(useMetricByDefault ? meterBtn : feetBtn);
        }

        @Override
        public void onCloseDialog() {
            resetUseMeters();
        }
    });
    dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
}
Also used : DialogStateListener(net.osmand.plus.base.SelectionBottomSheet.DialogStateListener) RadioItem(net.osmand.plus.widgets.multistatetoggle.RadioItem) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) ArrayList(java.util.ArrayList)

Example 2 with RadioItem

use of net.osmand.plus.widgets.multistatetoggle.RadioItem in project Osmand by osmandapp.

the class HikingRoutesFragment method createRadioButton.

private TextRadioItem createRadioButton(@NonNull String value) {
    String name = AndroidUtils.getRenderingStringPropertyValue(app, value);
    TextRadioItem item = new TextRadioItem(name);
    item.setOnClickListener(new OnRadioItemClickListener() {

        @Override
        public boolean onRadioItemClick(RadioItem radioItem, View v) {
            pref.set(value);
            previousValue = value;
            View view = getView();
            if (view != null) {
                setupHeader(view);
                setupTypesCard(view);
            }
            refreshMap();
            return true;
        }
    });
    return item;
}
Also used : OnRadioItemClickListener(net.osmand.plus.widgets.multistatetoggle.RadioItem.OnRadioItemClickListener) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) RadioItem(net.osmand.plus.widgets.multistatetoggle.RadioItem) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 3 with RadioItem

use of net.osmand.plus.widgets.multistatetoggle.RadioItem in project Osmand by osmandapp.

the class CycleRoutesFragment method createRadioButton.

private TextRadioItem createRadioButton(@NonNull CommonPreference<Boolean> pref, boolean enabled, int titleId) {
    TextRadioItem item = new TextRadioItem(getString(titleId));
    item.setOnClickListener(new OnRadioItemClickListener() {

        @Override
        public boolean onRadioItemClick(RadioItem radioItem, View view) {
            pref.set(enabled);
            View mainView = getView();
            if (mainView != null) {
                setupTypesCard(mainView);
            }
            MapActivity mapActivity = (MapActivity) getMyActivity();
            if (mapActivity != null) {
                mapActivity.refreshMapComplete();
                mapActivity.getMapLayers().updateLayers(mapActivity);
            }
            return true;
        }
    });
    return item;
}
Also used : OnRadioItemClickListener(net.osmand.plus.widgets.multistatetoggle.RadioItem.OnRadioItemClickListener) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) RadioItem(net.osmand.plus.widgets.multistatetoggle.RadioItem) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 4 with RadioItem

use of net.osmand.plus.widgets.multistatetoggle.RadioItem in project Osmand by osmandapp.

the class RouteLineColorCard method createMapThemeButton.

private TextRadioItem createMapThemeButton(final boolean isNight) {
    TextRadioItem item = new TextRadioItem(app.getString(!isNight ? DAY_TITLE_ID : NIGHT_TITLE_ID));
    item.setOnClickListener(new OnRadioItemClickListener() {

        @Override
        public boolean onRadioItemClick(RadioItem radioItem, View view) {
            selectedMapTheme = isNight ? DayNightMode.NIGHT : DayNightMode.DAY;
            changeMapTheme(selectedMapTheme);
            updateDescription();
            return true;
        }
    });
    return item;
}
Also used : OnRadioItemClickListener(net.osmand.plus.widgets.multistatetoggle.RadioItem.OnRadioItemClickListener) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) RadioItem(net.osmand.plus.widgets.multistatetoggle.RadioItem) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView)

Example 5 with RadioItem

use of net.osmand.plus.widgets.multistatetoggle.RadioItem in project Osmand by osmandapp.

the class SplitIntervalBottomSheet method createRadioButton.

private TextRadioItem createRadioButton(final GpxSplitType splitType, int titleId) {
    String title = app.getString(titleId);
    TextRadioItem item = new TextRadioItem(title);
    item.setOnClickListener(new OnRadioItemClickListener() {

        @Override
        public boolean onRadioItemClick(RadioItem radioItem, View view) {
            selectedSplitType = splitType;
            updateSlider();
            return true;
        }
    });
    return item;
}
Also used : OnRadioItemClickListener(net.osmand.plus.widgets.multistatetoggle.RadioItem.OnRadioItemClickListener) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) RadioItem(net.osmand.plus.widgets.multistatetoggle.RadioItem) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) View(android.view.View) TextView(android.widget.TextView)

Aggregations

RadioItem (net.osmand.plus.widgets.multistatetoggle.RadioItem)7 TextRadioItem (net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem)7 View (android.view.View)5 OnRadioItemClickListener (net.osmand.plus.widgets.multistatetoggle.RadioItem.OnRadioItemClickListener)5 TextView (android.widget.TextView)4 ImageView (android.widget.ImageView)2 ArrayList (java.util.ArrayList)2 DialogStateListener (net.osmand.plus.base.SelectionBottomSheet.DialogStateListener)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 MapActivity (net.osmand.plus.activities.MapActivity)1 SelectionUpdateListener (net.osmand.plus.base.MultipleSelectionBottomSheet.SelectionUpdateListener)1 SelectableItem (net.osmand.plus.base.SelectionBottomSheet.SelectableItem)1