diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-04-27 12:25:03 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-04-27 12:33:19 +0300 |
commit | 8f3c104ada9b28e987d04a53c67c2eed1ac4ef90 (patch) | |
tree | 6af77ecf73d2959b79bea48b0b1f421ddf8bc430 /app/src/main/java/it/niedermann/nextcloud/deck/ui/stack | |
parent | be49f8ef24f3198a5c0216e0e3e44d78c75e4a47 (diff) |
#421 "Delete list": Tell user how many card will be deleted
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/stack')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java index 8be166e70..066fb82d8 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java @@ -14,9 +14,11 @@ import it.niedermann.nextcloud.deck.ui.branding.BrandedDeleteAlertDialogBuilder; public class DeleteStackDialogFragment extends DialogFragment { private static final String KEY_STACK_ID = "stack_id"; + private static final String KEY_NUMBER_CARDS = "number_cards"; private DeleteStackListener deleteStackListener; - private Long stackId; + private long stackId; + private int numberCards; @Override public void onAttach(@NonNull Context context) { @@ -27,10 +29,13 @@ public class DeleteStackDialogFragment extends DialogFragment { throw new ClassCastException("Caller must implement " + DeleteStackListener.class.getCanonicalName()); } - if (getArguments() == null || !getArguments().containsKey(KEY_STACK_ID)) { - throw new IllegalArgumentException("Please provide at least stack id as an argument"); + final Bundle args = getArguments(); + + if (args == null || !args.containsKey(KEY_STACK_ID) || !args.containsKey(KEY_NUMBER_CARDS)) { + throw new IllegalArgumentException("Please provide at least " + KEY_STACK_ID + " and " + KEY_NUMBER_CARDS + " as arguments"); } else { - this.stackId = getArguments().getLong(KEY_STACK_ID); + this.stackId = args.getLong(KEY_STACK_ID); + this.numberCards = args.getInt(KEY_NUMBER_CARDS); } } @@ -39,17 +44,18 @@ public class DeleteStackDialogFragment extends DialogFragment { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new BrandedDeleteAlertDialogBuilder(requireContext()) .setTitle(R.string.delete_list) - .setMessage(R.string.do_you_want_to_delete_the_current_list) + .setMessage(getResources().getQuantityString(R.plurals.do_you_want_to_delete_the_current_list, numberCards, numberCards)) .setPositiveButton(R.string.simple_delete, (dialog, whichButton) -> deleteStackListener.onStackDeleted(stackId)) .setNeutralButton(android.R.string.cancel, null); return builder.create(); } - public static DialogFragment newInstance(long stackId) { + public static DialogFragment newInstance(long stackId, int numberCards) { DeleteStackDialogFragment dialog = new DeleteStackDialogFragment(); Bundle args = new Bundle(); args.putLong(KEY_STACK_ID, stackId); + args.putInt(KEY_NUMBER_CARDS, numberCards); dialog.setArguments(args); return dialog; |