[Android] src: Use the pre-made delete dialog in VideoListFragment

Edward Wang git at videolan.org
Fri Jul 13 02:21:35 CEST 2012


android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Jul 12 20:18:20 2012 -0400| [3d2477a3fc69797f5c07395bc838f92dbe11bf8e] | committer: Edward Wang

src: Use the pre-made delete dialog in VideoListFragment

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=3d2477a3fc69797f5c07395bc838f92dbe11bf8e
---

 .../videolan/vlc/gui/video/VideoListFragment.java  |   29 ++++++++------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java
index 8bb8224..7d34761 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java
@@ -32,7 +32,9 @@ import org.videolan.vlc.Media;
 import org.videolan.vlc.MediaLibrary;
 import org.videolan.vlc.R;
 import org.videolan.vlc.ThumbnailerManager;
+import org.videolan.vlc.VLCCallbackTask;
 import org.videolan.vlc.WeakHandler;
+import org.videolan.vlc.gui.CommonDialogs;
 import org.videolan.vlc.gui.PreferencesActivity;
 import org.videolan.vlc.interfaces.ISortable;
 
@@ -164,27 +166,18 @@ public class VideoListFragment extends SherlockListFragment implements ISortable
                 return true;
             case R.id.video_list_delete:
                 final int positionDelete = info.position;
-                AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
-                .setTitle(R.string.confirm_delete)
-                .setMessage(R.string.validation)
-                .setIcon(android.R.drawable.ic_dialog_alert)
-                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
+                AlertDialog alertDialog = CommonDialogs.deleteMedia(
+                        getActivity(),
+                        mVideoAdapter.getItem(positionDelete).getLocation(),
+                        new VLCCallbackTask(new VLCCallbackTask.CallbackListener() {
                     @Override
-                    public void onClick(DialogInterface dialog, int whichButton) {
-                        URI adressMediaUri = null;
-                        try {
-                            adressMediaUri = new URI (mVideoAdapter.
-                            		getItem(positionDelete).getLocation());
-                        } catch (URISyntaxException e) {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
-                        }
-                        File fileMedia =  new File(adressMediaUri);
-                        fileMedia.delete();
+                    public void callback() {
                         mVideoAdapter.remove(mVideoAdapter.getItem(positionDelete));
                     }
-                })
-                .setNegativeButton(android.R.string.cancel, null).create();
+
+                    @Override
+                    public void callback_object(Object o) { }
+                }));
                 alertDialog.show();
                 return true;
         }



More information about the Android mailing list