use of net.osmand.plus.plugins.osmedit.dialogs.UploadMultipleGPXBottomSheet in project Osmand by osmandapp.
the class AvailableGPXFragment method showUploadConfirmationDialog.
private void showUploadConfirmationDialog(@NonNull FragmentActivity activity, @NonNull String actionButton, @Nullable SelectionModeListener listener) {
long[] size = new long[1];
List<SelectableItem<GpxInfo>> items = new ArrayList<>();
for (GpxInfo gpxInfo : selectedItems) {
SelectableItem<GpxInfo> item = new SelectableItem<>();
item.setObject(gpxInfo);
item.setTitle(gpxInfo.getName());
item.setIconId(R.drawable.ic_notification_track);
items.add(item);
size[0] += gpxInfo.getSize();
}
List<SelectableItem<GpxInfo>> selectedItems = new ArrayList<>(items);
FragmentManager manager = activity.getSupportFragmentManager();
UploadMultipleGPXBottomSheet dialog = UploadMultipleGPXBottomSheet.showInstance(manager, items, selectedItems);
if (dialog != null) {
dialog.setDialogStateListener(new DialogStateListener() {
@Override
public void onDialogCreated() {
dialog.setTitle(actionButton);
dialog.setApplyButtonTitle(getString(R.string.shared_string_continue));
String total = getString(R.string.shared_string_total);
dialog.setTitleDescription(getString(R.string.ltr_or_rtl_combine_via_colon, total, AndroidUtils.formatSize(app, size[0])));
}
@Override
public void onCloseDialog() {
}
});
dialog.setOnApplySelectionListener(selItems -> {
List<GpxInfo> gpxInfos = new ArrayList<>();
for (SelectableItem<GpxInfo> item : selItems) {
gpxInfos.add(item.getObject());
}
if (listener != null) {
listener.onItemsSelected(gpxInfos);
}
});
}
}
Aggregations