diff options
author | Marco Nelissen <marcone@google.com> | 2015-02-17 23:54:29 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-17 23:54:30 +0000 |
commit | ffaee8bda9c8d22af17098fec0e6626301d91844 (patch) | |
tree | 03f66f98a75872c9aacdd9a645e86cb883572c14 /core | |
parent | a94e42970d4e664e193cde0cf2700cb7e15961c9 (diff) | |
parent | 0e24cb7fb5b2b1941d8340cbe577dbfcb624ccdb (diff) | |
download | frameworks_base-ffaee8bda9c8d22af17098fec0e6626301d91844.zip frameworks_base-ffaee8bda9c8d22af17098fec0e6626301d91844.tar.gz frameworks_base-ffaee8bda9c8d22af17098fec0e6626301d91844.tar.bz2 |
Merge "Fix NPE" into lmp-mr1-dev
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/provider/MediaStore.java | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index 736ec54..5afbd6d 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -638,7 +638,6 @@ public final class MediaStore { static Bitmap getThumbnail(ContentResolver cr, long origId, long groupId, int kind, BitmapFactory.Options options, Uri baseUri, boolean isVideo) { Bitmap bitmap = null; - String filePath = null; // Log.v(TAG, "getThumbnail: origId="+origId+", kind="+kind+", isVideo="+isVideo); // If the magic is non-zero, we simply return thumbnail if it does exist. // querying MediaProvider and simply return thumbnail. @@ -710,18 +709,18 @@ public final class MediaStore { Uri uri = Uri.parse( baseUri.buildUpon().appendPath(String.valueOf(origId)) .toString().replaceFirst("thumbnails", "media")); - if (filePath == null) { - if (c != null) c.close(); - c = cr.query(uri, PROJECTION, null, null, null); - if (c == null || !c.moveToFirst()) { - return null; - } - filePath = c.getString(1); + if (c != null) c.close(); + c = cr.query(uri, PROJECTION, null, null, null); + if (c == null || !c.moveToFirst()) { + return null; } - if (isVideo) { - bitmap = ThumbnailUtils.createVideoThumbnail(filePath, kind); - } else { - bitmap = ThumbnailUtils.createImageThumbnail(filePath, kind); + String filePath = c.getString(1); + if (filePath != null) { + if (isVideo) { + bitmap = ThumbnailUtils.createVideoThumbnail(filePath, kind); + } else { + bitmap = ThumbnailUtils.createImageThumbnail(filePath, kind); + } } } } catch (SQLiteException ex) { |