[Android] libvlc: move PathToURI to AndroidUtil

Thomas Guillem git at videolan.org
Thu May 28 15:34:10 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu May 28 15:24:10 2015 +0200| [bf4461d7c0da031156c93660ade7b511ae1234ec] | committer: Thomas Guillem

libvlc: move PathToURI to AndroidUtil

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

 libvlc/src/org/videolan/libvlc/LibVLC.java            |   17 +----------------
 libvlc/src/org/videolan/libvlc/util/AndroidUtil.java  |   16 ++++++++++++++++
 vlc-android/src/org/videolan/vlc/MediaLibrary.java    |    3 ++-
 .../videolan/vlc/gui/video/VideoPlayerActivity.java   |    4 ++--
 4 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index e5fd5e8..80459d4 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -24,6 +24,7 @@ import java.io.File;
 import java.util.ArrayList;
 
 import android.content.Context;
+import android.net.Uri;
 import android.os.Build;
 import android.util.Log;
 import android.view.Surface;
@@ -196,22 +197,6 @@ public class LibVLC {
 
     public native static void sendMouseEvent( int action, int button, int x, int y);
 
-    /**
-     * Quickly converts path to URIs, which are mandatory in libVLC.
-     *
-     * @param path
-     *            The path to be converted.
-     * @return A URI representation of path
-     */
-    public static String PathToURI(String path) {
-        if(path == null) {
-            throw new NullPointerException("Cannot convert null path!");
-        }
-
-        File f = new File(path);
-        return f.toURI().toString();
-    }
-
     private native void setEventHandler(EventHandler eventHandler);
 
     private native void detachEventHandler();
diff --git a/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java b/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
index 54e92b0..91935d1 100644
--- a/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
+++ b/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
@@ -73,4 +73,20 @@ public class AndroidUtil {
         if (URI == null) return null;
         return new File(Uri.decode(URI).replaceFirst("file://", ""));
     }
+
+    /**
+     * Quickly converts path to URIs, which are mandatory in libVLC.
+     *
+     * @param path
+     *            The path to be converted.
+     * @return A URI representation of path
+     */
+    public static String PathToURI(String path) {
+        if (path == null) {
+            throw new NullPointerException("Cannot convert null path!");
+        }
+
+        File f = new File(path);
+        return f.toURI().toString();
+    }
 }
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index cbf51e1..85e555f 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -29,6 +29,7 @@ import android.util.Log;
 
 import org.videolan.libvlc.LibVLC;
 import org.videolan.libvlc.Media;
+import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.libvlc.util.Extensions;
 import org.videolan.vlc.gui.audio.AudioBrowserListAdapter;
 import org.videolan.vlc.interfaces.IBrowser;
@@ -354,7 +355,7 @@ public class MediaLibrary {
 
                 // Process the stacked items
                 for (File file : mediaToScan) {
-                    String fileURI = LibVLC.PathToURI(file.getPath());
+                    String fileURI = AndroidUtil.PathToURI(file.getPath());
                     if (mBrowser != null && mBrowser.get() != null)
                         mBrowser.get().sendTextInfo(file.getName(), count,
                                 mediaToScan.size());
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 12d7de4..e7c7b5d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2695,7 +2695,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
                             while((bytesRead = is.read(buffer)) >= 0) {
                                 os.write(buffer, 0, bytesRead);
                             }
-                            mLocation = LibVLC.PathToURI(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Download/" + filename);
+                            mLocation = AndroidUtil.PathToURI(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Download/" + filename);
                         }
                     } catch (Exception e) {
                         Log.e(TAG, "Couldn't download file from mail URI");
@@ -2714,7 +2714,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
                         if (cursor != null) {
                             int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
                             if (cursor.moveToFirst())
-                                mLocation = LibVLC.PathToURI(cursor.getString(column_index));
+                                mLocation = AndroidUtil.PathToURI(cursor.getString(column_index));
                             cursor.close();
                         }
                         // other content-based URI (probably file pickers)



More information about the Android mailing list