[Android] Catch IllegalStateException caused by Google bug

Geoffrey Métais git at videolan.org
Thu Apr 9 16:09:01 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr  9 13:19:01 2015 +0200| [217f427698ea9f9567b030c33c91d268019dcf05] | committer: Geoffrey Métais

Catch IllegalStateException caused by Google bug

See https://code.google.com/p/android/issues/detail?id=32472

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=217f427698ea9f9567b030c33c91d268019dcf05
---

 .../src/org/videolan/vlc/MediaDatabase.java        |   50 ++++++++++----------
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
index 09c57ec..2a9e2b6 100644
--- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
@@ -678,30 +678,32 @@ public class MediaDatabase {
                     chunk_count * CHUNK_SIZE), null);
 
             if (cursor.moveToFirst()) {
-                do {
-                    String location = cursor.getString(0);
-                    MediaWrapper media = new MediaWrapper(location,
-                            cursor.getLong(1),      // MEDIA_TIME
-                            cursor.getLong(2),      // MEDIA_LENGTH
-                            cursor.getInt(3),       // MEDIA_TYPE
-                            null,                   // MEDIA_PICTURE
-                            cursor.getString(4),    // MEDIA_TITLE
-                            cursor.getString(5),    // MEDIA_ARTIST
-                            cursor.getString(6),    // MEDIA_GENRE
-                            cursor.getString(7),    // MEDIA_ALBUM
-                            cursor.getString(8),    // MEDIA_ALBUMARTIST
-                            cursor.getInt(9),       // MEDIA_WIDTH
-                            cursor.getInt(10),       // MEDIA_HEIGHT
-                            cursor.getString(11),   // MEDIA_ARTWORKURL
-                            cursor.getInt(12),      // MEDIA_AUDIOTRACK
-                            cursor.getInt(13),      // MEDIA_SPUTRACK
-                            cursor.getInt(14),      // MEDIA_TRACKNUMBER
-                            cursor.getInt(15),     // MEDIA_DISCNUMBER
-                            cursor.getLong(16));     // MEDIA_LAST_MODIFIED
-                    medias.put(media.getLocation(), media);
-
-                    count++;
-                } while (cursor.moveToNext());
+                try {
+                    do {
+                        String location = cursor.getString(0);
+                        MediaWrapper media = new MediaWrapper(location,
+                                cursor.getLong(1),      // MEDIA_TIME
+                                cursor.getLong(2),      // MEDIA_LENGTH
+                                cursor.getInt(3),       // MEDIA_TYPE
+                                null,                   // MEDIA_PICTURE
+                                cursor.getString(4),    // MEDIA_TITLE
+                                cursor.getString(5),    // MEDIA_ARTIST
+                                cursor.getString(6),    // MEDIA_GENRE
+                                cursor.getString(7),    // MEDIA_ALBUM
+                                cursor.getString(8),    // MEDIA_ALBUMARTIST
+                                cursor.getInt(9),       // MEDIA_WIDTH
+                                cursor.getInt(10),       // MEDIA_HEIGHT
+                                cursor.getString(11),   // MEDIA_ARTWORKURL
+                                cursor.getInt(12),      // MEDIA_AUDIOTRACK
+                                cursor.getInt(13),      // MEDIA_SPUTRACK
+                                cursor.getInt(14),      // MEDIA_TRACKNUMBER
+                                cursor.getInt(15),     // MEDIA_DISCNUMBER
+                                cursor.getLong(16));     // MEDIA_LAST_MODIFIED
+                        medias.put(media.getLocation(), media);
+
+                        count++;
+                    } while (cursor.moveToNext());
+                } catch (IllegalStateException e) {} //Google bug causing IllegalStateException, see https://code.google.com/p/android/issues/detail?id=32472
             }
 
             cursor.close();



More information about the Android mailing list