[Android] Prevent ClassCastException

Geoffrey Métais git at videolan.org
Tue Jan 15 15:32:08 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 15 14:23:14 2019 +0100| [af94197820428dc8e0943a324f9cf5811cd5c204] | committer: Geoffrey Métais

Prevent ClassCastException

> https://code.videolan.org/videolan/vlc-android/commit/af94197820428dc8e0943a324f9cf5811cd5c204
---

 vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
index c2fa6d033..f3c5f30c5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
@@ -158,7 +158,7 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb {
     }
 
     override fun onClick(v: View, position: Int, item: MediaLibraryItem) {
-        val mw = MediaWrapper((item as Storage).uri)
+        val mw = (item as? Storage)?.let { MediaWrapper(it.uri) } ?: return
         mw.type = MediaWrapper.TYPE_DIR
         browse(mw, position, (DataBindingUtil.findBinding<BrowserItemBinding>(v))?.browserCheckbox?.state == ThreeStatesCheckbox.STATE_CHECKED)
     }



More information about the Android mailing list