[Android] Integrate Subs downloader in MediaUtils

Geoffrey Métais git at videolan.org
Fri Apr 15 12:01:09 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 14 16:37:33 2016 +0200| [b397996a21fb4b99e022d1e473441a8cc7a7e1de] | committer: Geoffrey Métais

Integrate Subs downloader in MediaUtils

> https://code.videolan.org/videolan/vlc-android/commit/b397996a21fb4b99e022d1e473441a8cc7a7e1de
---

 .../src/org/videolan/vlc/media/MediaUtils.java     | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/media/MediaUtils.java b/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
index bf2418e..ca88321 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
@@ -1,5 +1,6 @@
 package org.videolan.vlc.media;
 
+import android.app.Activity;
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -16,19 +17,41 @@ import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.video.VideoPlayerActivity;
 import org.videolan.vlc.util.FileUtils;
 import org.videolan.vlc.util.Strings;
+import org.videolan.vlc.util.SubtitlesDownloader;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class MediaUtils {
     public static final String ACTION_SCAN_START = Strings.buildPkgString("gui.ScanStart");
     public static final String ACTION_SCAN_STOP = Strings.buildPkgString("gui.ScanStop");
 
+    private static SubtitlesDownloader sSubtitlesDownloader;
+
     public static void actionScanStart() {
         Intent intent = new Intent();
         intent.setAction(ACTION_SCAN_START);
         LocalBroadcastManager.getInstance(VLCApplication.getAppContext()).sendBroadcast(intent);
     }
 
+    public static void getSubs(Activity activity, ArrayList<MediaWrapper> mediaList) {
+        if (sSubtitlesDownloader == null)
+            sSubtitlesDownloader = new SubtitlesDownloader();
+        sSubtitlesDownloader.setActivity(activity);
+        sSubtitlesDownloader.downloadSubs(mediaList);
+    }
+
+    public static void getSubs(Activity activity, MediaWrapper media) {
+        ArrayList<MediaWrapper> mediaList = new ArrayList<>();
+        mediaList.add(media);
+        getSubs(activity, mediaList);
+    }
+
+    public static void updateSubsDownloaderActivity(Activity activity) {
+        if (sSubtitlesDownloader != null)
+            sSubtitlesDownloader.setActivity(activity);
+    }
+
     public static void actionScanStop() {
         Intent intent = new Intent();
         intent.setAction(ACTION_SCAN_STOP);



More information about the Android mailing list