[Android] Move URItoFileName to LibVlcUtil
Edward Wang
git at videolan.org
Mon Nov 4 04:55:17 CET 2013
vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Nov 3 22:54:44 2013 -0500| [664eec380a8a188941b5ad005a6cc91f85aa91ae] | committer: Edward Wang
Move URItoFileName to LibVlcUtil
URItoFileName does not depend on anything in VLC proper. Reduce another Util call.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=664eec380a8a188941b5ad005a6cc91f85aa91ae
---
vlc-android/src/org/videolan/libvlc/LibVlcUtil.java | 9 +++++++++
vlc-android/src/org/videolan/vlc/Media.java | 3 ++-
vlc-android/src/org/videolan/vlc/Util.java | 10 ----------
vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java | 5 +++--
4 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/vlc-android/src/org/videolan/libvlc/LibVlcUtil.java b/vlc-android/src/org/videolan/libvlc/LibVlcUtil.java
index d38300a..e941ac8 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVlcUtil.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVlcUtil.java
@@ -31,6 +31,7 @@ import java.nio.ByteOrder;
import java.util.Locale;
import android.content.Context;
+import android.net.Uri;
import android.os.Build;
import android.util.Log;
@@ -68,6 +69,14 @@ public class LibVlcUtil {
return errorMsg;
}
+ public static File URItoFile(String URI) {
+ return new File(Uri.decode(URI).replace("file://",""));
+ }
+
+ public static String URItoFileName(String URI) {
+ return URItoFile(URI).getName();
+ }
+
public static boolean hasCompatibleCPU(Context context)
{
// If already checked return cached result
diff --git a/vlc-android/src/org/videolan/vlc/Media.java b/vlc-android/src/org/videolan/vlc/Media.java
index 6454e23..0be3864 100644
--- a/vlc-android/src/org/videolan/vlc/Media.java
+++ b/vlc-android/src/org/videolan/vlc/Media.java
@@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.Locale;
import org.videolan.libvlc.LibVLC;
+import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.TrackInfo;
import android.content.Context;
@@ -237,7 +238,7 @@ public class Media implements Comparable<Media> {
public String getFileName() {
if (mFilename == null) {
- mFilename = Util.URItoFileName(mLocation);
+ mFilename = LibVlcUtil.URItoFileName(mLocation);
}
return mFilename;
}
diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index 7ca400c..cbc5266 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -21,7 +21,6 @@
package org.videolan.vlc;
import java.io.BufferedReader;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@@ -44,7 +43,6 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
-import android.net.Uri;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.telephony.TelephonyManager;
@@ -157,14 +155,6 @@ public class Util {
toaster(context, stringId, Toast.LENGTH_SHORT);
}
- public static File URItoFile(String URI) {
- return new File(Uri.decode(URI).replace("file://",""));
- }
-
- public static String URItoFileName(String URI) {
- return URItoFile(URI).getName();
- }
-
public static String stripTrailingSlash(String s) {
if( s.endsWith("/") && s.length() > 1 )
return s.substring(0, s.length() - 1);
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
index 5554ade..cc4116f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
@@ -30,6 +30,7 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
+import org.videolan.libvlc.LibVlcUtil;
import org.videolan.vlc.BitmapCache;
import org.videolan.vlc.Media;
import org.videolan.vlc.MurmurHash;
@@ -61,7 +62,7 @@ public class AudioUtil {
public static String PLAYLIST_DIR = null;
public static void setRingtone( Media song, Activity activity){
- File newringtone = Util.URItoFile(song.getLocation());
+ File newringtone = LibVlcUtil.URItoFile(song.getLocation());
if(!newringtone.exists()) {
Toast.makeText(activity.getApplicationContext(),activity.getString(R.string.ringtone_error), Toast.LENGTH_SHORT).show();
return;
@@ -176,7 +177,7 @@ public class AudioUtil {
}
private static String getCoverFromFolder(Context context, Media media) {
- File f = Util.URItoFile(media.getLocation());
+ File f = LibVlcUtil.URItoFile(media.getLocation());
if (f != null && f.getParentFile() != null && f.getParentFile().listFiles() != null)
for (File s : f.getParentFile().listFiles()) {
if (s.getAbsolutePath().endsWith("png")
More information about the Android
mailing list