[Android] CommonDialogs: add confirmDialog

Edward Wang git at videolan.org
Tue Sep 2 10:12:25 CEST 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Mon Sep  1 16:40:21 2014 -0700| [a8ed63c9c2fb99a7ecb377f2089b115c730eed4a] | committer: Edward Wang

CommonDialogs: add confirmDialog

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a8ed63c9c2fb99a7ecb377f2089b115c730eed4a
---

 .../src/org/videolan/vlc/gui/CommonDialogs.java    |   33 +++++++++++++-------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java b/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
index c118a09..6f6466b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
+++ b/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
@@ -67,19 +67,28 @@ public class CommonDialogs {
         }
         final File fileMedia = new File(adressMediaUri);
 
+        return confirmDialog(
+                context,
+                context.getResources().getString(R.string.confirm_delete,
+                        fileMedia.getName()),
+                new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int whichButton) {
+                        fileMedia.delete();
+                        if (runnable != null)
+                            runnable.run();
+                    }
+                });
+    }
+
+    public static AlertDialog confirmDialog(final Context context,
+            final String confirmationString,
+            final DialogInterface.OnClickListener callback) {
         AlertDialog alertDialog = new AlertDialog.Builder(context)
-        .setTitle(R.string.validation)
-        .setMessage(context.getResources().getString(R.string.confirm_delete, fileMedia.getName()))
-        .setIcon(android.R.drawable.ic_dialog_alert)
-        .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
-            @Override
-            public void onClick(DialogInterface dialog, int whichButton) {
-                fileMedia.delete();
-                if(runnable != null)
-                    runnable.run();
-            }
-        })
-        .setNegativeButton(android.R.string.cancel, null).create();
+                .setTitle(R.string.validation).setMessage(confirmationString)
+                .setIcon(android.R.drawable.ic_dialog_alert)
+                .setPositiveButton(android.R.string.yes, callback)
+                .setNegativeButton(android.R.string.cancel, null).create();
 
         return alertDialog;
     }



More information about the Android mailing list