[Android] Prevent some NPEs
Geoffrey Métais
git at videolan.org
Wed Mar 20 15:34:02 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 20 15:04:05 2019 +0100| [a76832339a08b512da0ccb82f1e989a179e0cb27] | committer: Geoffrey Métais
Prevent some NPEs
> https://code.videolan.org/videolan/vlc-android/commit/a76832339a08b512da0ccb82f1e989a179e0cb27
---
vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt | 9 +++++----
vlc-android/src/org/videolan/vlc/media/MediaUtils.kt | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
index 84606f33b..e596a6e2c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
@@ -219,7 +219,7 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
}
private val showInternalStorage = AndroidDevices.showInternalStorage()
- suspend fun updateBrowsers() {
+ private suspend fun updateBrowsers() {
val list = mutableListOf<MediaLibraryItem>()
val directories = DirectoryRepository.getInstance(requireContext()).getMediaDirectoriesList(requireContext().applicationContext).toMutableList()
if (!showInternalStorage && !directories.isEmpty()) directories.removeAt(0)
@@ -227,10 +227,11 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
if (directory.location.scanAllowed()) list.add(directory)
}
+ val ctx = context ?: return
if (ExternalMonitor.isLan) {
- list.add(DummyItem(HEADER_NETWORK, getString(R.string.network_browsing), null))
- list.add(DummyItem(HEADER_STREAM, getString(R.string.open_mrl), null))
- list.add(DummyItem(HEADER_SERVER, getString(R.string.server_add_title), null))
+ list.add(DummyItem(HEADER_NETWORK, ctx.getString(R.string.network_browsing), null))
+ list.add(DummyItem(HEADER_STREAM, ctx.getString(R.string.open_mrl), null))
+ list.add(DummyItem(HEADER_SERVER, ctx.getString(R.string.server_add_title), null))
updatedFavoritList.forEach{
it.description = it.uri.scheme
diff --git a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
index 3630911fe..7793509fe 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
+++ b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
@@ -413,6 +413,7 @@ object MediaUtils : CoroutineScope {
}
} catch (ignored: UnsupportedOperationException) {
} catch (ignored: IllegalArgumentException) {
+ } catch (ignored: NullPointerException) {
} catch (ignored: SecurityException) {}
fun deletePlaylist(playlist: Playlist) = launch(Dispatchers.IO) { playlist.delete() }
More information about the Android
mailing list