[Android] Save init success, and always check it
Geoffrey Métais
git at videolan.org
Fri Dec 23 16:38:32 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Dec 23 14:24:19 2016 +0100| [682d5395ca1c8d773d989a6d382ad7b64761b036] | committer: Geoffrey Métais
Save init success, and always check it
> https://code.videolan.org/videolan/vlc-android/commit/682d5395ca1c8d773d989a6d382ad7b64761b036
---
.../src/org/videolan/medialibrary/Medialibrary.java | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index ab4e3e7..8da645e 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -80,9 +80,9 @@ public class Medialibrary {
nativeSetup();
}
- public void init(Context context) {
- nativeInit(context.getCacheDir()+"/vlc_media.db", context.getExternalFilesDir(null).getAbsolutePath()+"/thumbs");
- mIsInitiated = true;
+ public boolean init(Context context) {
+ mIsInitiated = nativeInit(context.getCacheDir()+"/vlc_media.db", context.getExternalFilesDir(null).getAbsolutePath()+"/thumbs");
+ return mIsInitiated;
}
public void banFolder(String path) {
@@ -172,10 +172,11 @@ public class Medialibrary {
}
public Playlist getPlaylist(long playlistId) {
- return nativeGetPlaylist(playlistId);
+ return mIsInitiated ? nativeGetPlaylist(playlistId) : null;
}
+
public Playlist createPlaylist(String name) {
- return nativePlaylistCreate(name);
+ return mIsInitiated ? nativePlaylistCreate(name) : null;
}
public void pauseBackgroundOperations() {
@@ -215,10 +216,10 @@ public class Medialibrary {
}
public MediaWrapper getMedia(long id) {
- return nativeGetMedia(id);
+ return mIsInitiated ? nativeGetMedia(id) : null;
}
public MediaWrapper getMedia(String mrl) {
- return nativeGetMediaFromMrl(mrl);
+ return mIsInitiated ? nativeGetMediaFromMrl(mrl) : null;
}
public long getId() {
@@ -374,10 +375,12 @@ public class Medialibrary {
}
public SearchAggregate search(String query) {
- return nativeSearch(query);
+ return mIsInitiated ? nativeSearch(query) : null;
}
public void addDeviceDiscoveryCb(DevicesDiscoveryCb cb) {
+ if (!mIsInitiated)
+ return;
devicesDiscoveryCbList.add(cb);
}
@@ -402,7 +405,7 @@ public class Medialibrary {
// Native methods
private native void nativeSetup();
- private native void nativeInit(String dbPath, String thumbsPath);
+ private native boolean nativeInit(String dbPath, String thumbsPath);
private native void nativeRelease();
private native void nativeBanFolder(String path);
private native void nativeAddDevice(String uuid, String path, boolean removable);
More information about the Android
mailing list