[Android] Fail ML init if context or folders aren't ready
Geoffrey Métais
git at videolan.org
Wed Jun 28 11:37:57 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jun 28 10:23:47 2017 +0200| [391e5619925e0b09fe58d709afc2ce35b4be4280] | committer: Geoffrey Métais
Fail ML init if context or folders aren't ready
> https://code.videolan.org/videolan/vlc-android/commit/391e5619925e0b09fe58d709afc2ce35b4be4280
---
medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 2c26ea9ce..3229a5147 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -74,7 +74,13 @@ public class Medialibrary {
}
public boolean init(Context context) {
- mIsInitiated = nativeInit(context.getCacheDir()+ VLC_MEDIA_DB_NAME, context.getExternalFilesDir(null).getAbsolutePath()+ THUMBS_FOLDER_NAME);
+ if (context == null)
+ return false;
+ File cacheDir = context.getCacheDir();
+ File extFilesDir = context.getExternalFilesDir(null);
+ if (extFilesDir == null || !cacheDir.exists() || !extFilesDir.exists())
+ return false;
+ mIsInitiated = nativeInit(cacheDir+ VLC_MEDIA_DB_NAME, extFilesDir.getAbsolutePath()+ THUMBS_FOLDER_NAME);
return mIsInitiated;
}
More information about the Android
mailing list