[Android] remove URL usage & duplicated code
Sébastien Toque
git at videolan.org
Wed Apr 4 22:14:53 CEST 2012
android | branch: master | Sébastien Toque <xilasz at gmail.com> | Wed Apr 4 22:07:24 2012 +0200| [73f1bdfb0825bae60c072a68d06ecfe42780d091] | committer: Sébastien Toque
remove URL usage & duplicated code
(java.net.URL doesn't even recognize rtsp for instance)
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=73f1bdfb0825bae60c072a68d06ecfe42780d091
---
vlc-android/src/org/videolan/vlc/Media.java | 30 ++------------------
vlc-android/src/org/videolan/vlc/MediaLibrary.java | 2 +-
2 files changed, 4 insertions(+), 28 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/Media.java b/vlc-android/src/org/videolan/vlc/Media.java
index 880f3bf..2d639eb 100644
--- a/vlc-android/src/org/videolan/vlc/Media.java
+++ b/vlc-android/src/org/videolan/vlc/Media.java
@@ -20,9 +20,6 @@
package org.videolan.vlc;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.HashSet;
import android.content.Context;
@@ -99,21 +96,11 @@ public class Media implements Comparable<Media> {
/**
* Create a new Media
* @param context Application context of the caller
- * @param MRL the file's MRL (media resource locator)
+ * @param media URI
* @param addToDb Should it be added to the file database?
*/
- public Media(Context context, String MRL, Boolean addToDb) {
- mLocation = MRL;
- try {
- URL urlobj = new URL(MRL);
- mFilename = urlobj.getFile().substring(urlobj.getFile().lastIndexOf('/') + 1);
- /* empty filenames are awkward */
- if (mFilename.equals("")) {
- mFilename = urlobj.getHost();
- }
- } catch (MalformedURLException e1) {
- mFilename = "";
- }
+ public Media(Context context, String URI, Boolean addToDb) {
+ mLocation = URI;
LibVLC mLibVlc = null;
try {
@@ -153,17 +140,6 @@ public class Media implements Comparable<Media> {
}
}
- /**
- * Create from file
- *
- * @param context Context of the caller
- * @param file File object of the file to be added
- */
- public Media(Context context, File file) {
- this(context, Util.PathToURI(file.getPath()), true);
- mFilename = file.getName().substring(0, file.getName().lastIndexOf('.'));
- }
-
public Media(Context context, String location, long time, long length, int type,
Bitmap picture, String title, String artist, String genre, String album) {
mLocation = location;
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index ce2784b..d4b8c46 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -234,7 +234,7 @@ public class MediaLibrary {
}
} else {
// create new media item
- mItemList.add(new Media(mContext, file));
+ mItemList.add(new Media(mContext, fileURI, true));
}
} else if (file.isDirectory()) {
directorys.push(file);
More information about the Android
mailing list