Search in sources :

Example 6 with RadioItem

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

the class SelectIndexesHelper method showSrtmMultipleSelectionDialog.

private void showSrtmMultipleSelectionDialog() {
    MultipleDownloadItem mdi = (MultipleDownloadItem) downloadItem;
    List<SelectableItem<DownloadItem>> allItems = new ArrayList<>();
    List<SelectableItem<DownloadItem>> selectedItems = new ArrayList<>();
    for (DownloadItem di : mdi.getAllItems()) {
        SelectableItem<DownloadItem> si = createSrtmSelectableItem((SrtmDownloadItem) di);
        allItems.add(si);
        if (itemsToDownload.contains(di)) {
            selectedItems.add(si);
        }
    }
    final RadioItem meterBtn = createSrtmRadioBtn(true);
    final RadioItem feetBtn = createSrtmRadioBtn(false);
    List<RadioItem> radioItems = new ArrayList<>();
    radioItems.add(meterBtn);
    radioItems.add(feetBtn);
    MultipleSelectionBottomSheet<DownloadItem> msDialog = MultipleSelectionWithModeBottomSheet.showInstance(activity, allItems, selectedItems, radioItems, true);
    this.dialog = msDialog;
    msDialog.setDialogStateListener(new DialogStateListener() {

        @Override
        public void onDialogCreated() {
            dialog.setTitle(app.getString(R.string.welmode_download_maps));
            dialog.setSelectedMode(useMetricByDefault ? meterBtn : feetBtn);
            dialog.setSecondaryDescription(app.getString(R.string.srtm_download_list_help_message));
        }

        @Override
        public void onCloseDialog() {
            resetUseMeters();
        }
    });
    msDialog.setSelectionUpdateListener(new SelectionUpdateListener() {

        @Override
        public void onSelectionUpdate() {
            updateSize();
        }
    });
    msDialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
}
Also used : DialogStateListener(net.osmand.plus.base.SelectionBottomSheet.DialogStateListener) SelectionUpdateListener(net.osmand.plus.base.MultipleSelectionBottomSheet.SelectionUpdateListener) RadioItem(net.osmand.plus.widgets.multistatetoggle.RadioItem) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) SelectableItem(net.osmand.plus.base.SelectionBottomSheet.SelectableItem) ArrayList(java.util.ArrayList)

Example 7 with RadioItem

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

the class SelectIndexesHelper method createSrtmRadioBtn.

private RadioItem createSrtmRadioBtn(final boolean useMeters) {
    int titleId = useMeters ? R.string.shared_string_meters : R.string.shared_string_feet;
    String title = Algorithms.capitalizeFirstLetter(app.getString(titleId));
    RadioItem radioItem = new TextRadioItem(title);
    radioItem.setOnClickListener(new OnRadioItemClickListener() {

        @Override
        public boolean onRadioItemClick(RadioItem radioItem, View view) {
            setUseMetersForAllItems(useMeters);
            updateListItems();
            updateSize();
            return true;
        }
    });
    return radioItem;
}
Also used : RadioItem(net.osmand.plus.widgets.multistatetoggle.RadioItem) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) OnRadioItemClickListener(net.osmand.plus.widgets.multistatetoggle.RadioItem.OnRadioItemClickListener) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) View(android.view.View)

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