[Android] Catch Exception when getting title

Geoffrey Métais git at videolan.org
Tue Jul 31 14:04:48 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jul 27 16:00:41 2018 +0200| [91b8ec26111685e105d0c71926f98af2fd7c03c5] | committer: Geoffrey Métais

Catch Exception when getting title

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

 vlc-android/src/org/videolan/vlc/media/MediaUtils.kt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
index 1ffb02c0a..4d23a8a7a 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
+++ b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
@@ -239,7 +239,7 @@ object MediaUtils {
         }
     }
 
-    fun retrieveMediaTitle(mw: MediaWrapper) {
+    fun retrieveMediaTitle(mw: MediaWrapper) = try {
         VLCApplication.getAppContext().contentResolver.query(mw.uri, null, null, null, null)?.use {
             val nameIndex = it.getColumnIndex(OpenableColumns.DISPLAY_NAME)
             if (nameIndex > -1 && it.count > 0) {
@@ -247,7 +247,7 @@ object MediaUtils {
                 if (!it.isNull(nameIndex)) mw.title = it.getString(nameIndex)
             }
         }
-    }
+    } catch (ignored: UnsupportedOperationException) {}
 
     fun deletePlaylist(playlist: Playlist) = runBackground(Runnable { playlist.delete() })
 }



More information about the Android mailing list