From 9b0ce3c75a69148aa35bd121c7f0c221b7bebb31 Mon Sep 17 00:00:00 2001 From: Fiouz Date: Tue, 7 Jun 2011 01:25:38 +0200 Subject: [PATCH] Remove no longer used references on confirmation dialog disapproval --- .../fsck/k9/activity/ConfirmationDialog.java | 27 +++++++++++++++++-- src/com/fsck/k9/activity/MessageList.java | 6 +++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/com/fsck/k9/activity/ConfirmationDialog.java b/src/com/fsck/k9/activity/ConfirmationDialog.java index 73e9bf81c..6b22b7746 100644 --- a/src/com/fsck/k9/activity/ConfirmationDialog.java +++ b/src/com/fsck/k9/activity/ConfirmationDialog.java @@ -22,6 +22,26 @@ public class ConfirmationDialog { public static Dialog create(final Activity activity, final int dialogId, final int title, final String message, final int confirmButton, final int cancelButton, final Runnable action) { + return create(activity, dialogId, title, message, confirmButton, cancelButton, + action, null); + } + + /** + * Creates a customized confirmation dialog ({@link AlertDialog}). + * + * @param activity The activity this dialog is created for. + * @param dialogId The id that was used with {@link Activity#showDialog(int)} + * @param title The resource id of the text to display in the dialog title + * @param message The text to display in the main dialog area + * @param confirmButton The resource id of the text to display in the confirm button + * @param cancelButton The resource id of the text to display in the cancel button + * @param action The action to perform if the user presses the confirm button + * @param negativeAction The action to perform if the user presses the cancel button. Can be {@code null}. + * @return A confirmation dialog with the supplied arguments + */ + public static Dialog create(final Activity activity, final int dialogId, final int title, + final String message, final int confirmButton, final int cancelButton, + final Runnable action, final Runnable negativeAction) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(title); @@ -39,6 +59,9 @@ public class ConfirmationDialog { @Override public void onClick(DialogInterface dialog, int which) { activity.dismissDialog(dialogId); + if (negativeAction != null) { + negativeAction.run(); + } } }); return builder.create(); @@ -55,13 +78,13 @@ public class ConfirmationDialog { * @param cancelButton The resource id of the text to display in the cancel button * @param action The action to perform if the user presses the confirm button * @return A confirmation dialog with the supplied arguments - * @see #create(Activity,int,int,String,int,int,Runnable) + * @see #create(Activity,int,int,String,int,int,Runnable, Runnable) */ public static Dialog create(final Activity activity, final int dialogId, final int title, final int message, final int confirmButton, final int cancelButton, final Runnable action) { return create(activity, dialogId, title, activity.getString(message), confirmButton, - cancelButton, action); + cancelButton, action, null); } } diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index b69c191aa..2557d99b9 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -1287,6 +1287,12 @@ public class MessageList // No further need for this reference mActiveMessages = null; } + }, new Runnable() { + @Override + public void run() { + // event for cancel, we don't need this reference any more + mActiveMessages = null; + } }); }