Search in sources :

Example 1 with SelectionUpdateListener

use of net.osmand.plus.base.MultipleSelectionBottomSheet.SelectionUpdateListener 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)

Aggregations

ArrayList (java.util.ArrayList)1 SelectionUpdateListener (net.osmand.plus.base.MultipleSelectionBottomSheet.SelectionUpdateListener)1 DialogStateListener (net.osmand.plus.base.SelectionBottomSheet.DialogStateListener)1 SelectableItem (net.osmand.plus.base.SelectionBottomSheet.SelectableItem)1 RadioItem (net.osmand.plus.widgets.multistatetoggle.RadioItem)1 TextRadioItem (net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem)1