[Android] Medialibrary: minor optimization in media check
Geoffrey Métais
git at videolan.org
Tue Nov 20 17:36:06 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov 20 17:35:23 2018 +0100| [2dd47e711fca31edce5b51bca913addf71f49a5b] | committer: Geoffrey Métais
Medialibrary: minor optimization in media check
> https://code.videolan.org/videolan/vlc-android/commit/2dd47e711fca31edce5b51bca913addf71f49a5b
---
.../src/org/videolan/medialibrary/Medialibrary.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index ddee424af..ed38599bd 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -451,15 +451,14 @@ public class Medialibrary {
// If media is not in ML, find it with its path
public MediaWrapper findMedia(MediaWrapper mw) {
if (mIsInitiated && mw != null && mw.getId() == 0L) {
- Uri uri = mw.getUri();
- MediaWrapper libraryMedia = getMedia(uri);
- if (libraryMedia == null && TextUtils.equals("file", uri.getScheme()) &&
+ final Uri uri = mw.getUri();
+ final MediaWrapper libraryMedia = getMedia(uri);
+ if (libraryMedia != null) return libraryMedia;
+ if (TextUtils.equals("file", uri.getScheme()) &&
uri.getPath() != null && uri.getPath().startsWith("/sdcard")) {
- uri = Tools.convertLocalUri(uri);
- libraryMedia = getMedia(uri);
+ final MediaWrapper alternateMedia = getMedia(Tools.convertLocalUri(uri));
+ if (alternateMedia != null) return alternateMedia;
}
- if (libraryMedia != null)
- return libraryMedia;
}
return mw;
}
More information about the Android
mailing list