Merge "Fix NPE" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ffaee8bda9
@@ -638,7 +638,6 @@ public final class MediaStore {
|
|||||||
static Bitmap getThumbnail(ContentResolver cr, long origId, long groupId, int kind,
|
static Bitmap getThumbnail(ContentResolver cr, long origId, long groupId, int kind,
|
||||||
BitmapFactory.Options options, Uri baseUri, boolean isVideo) {
|
BitmapFactory.Options options, Uri baseUri, boolean isVideo) {
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
String filePath = null;
|
|
||||||
// Log.v(TAG, "getThumbnail: origId="+origId+", kind="+kind+", isVideo="+isVideo);
|
// Log.v(TAG, "getThumbnail: origId="+origId+", kind="+kind+", isVideo="+isVideo);
|
||||||
// If the magic is non-zero, we simply return thumbnail if it does exist.
|
// If the magic is non-zero, we simply return thumbnail if it does exist.
|
||||||
// querying MediaProvider and simply return thumbnail.
|
// querying MediaProvider and simply return thumbnail.
|
||||||
@@ -710,20 +709,20 @@ public final class MediaStore {
|
|||||||
Uri uri = Uri.parse(
|
Uri uri = Uri.parse(
|
||||||
baseUri.buildUpon().appendPath(String.valueOf(origId))
|
baseUri.buildUpon().appendPath(String.valueOf(origId))
|
||||||
.toString().replaceFirst("thumbnails", "media"));
|
.toString().replaceFirst("thumbnails", "media"));
|
||||||
if (filePath == null) {
|
|
||||||
if (c != null) c.close();
|
if (c != null) c.close();
|
||||||
c = cr.query(uri, PROJECTION, null, null, null);
|
c = cr.query(uri, PROJECTION, null, null, null);
|
||||||
if (c == null || !c.moveToFirst()) {
|
if (c == null || !c.moveToFirst()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
filePath = c.getString(1);
|
String filePath = c.getString(1);
|
||||||
}
|
if (filePath != null) {
|
||||||
if (isVideo) {
|
if (isVideo) {
|
||||||
bitmap = ThumbnailUtils.createVideoThumbnail(filePath, kind);
|
bitmap = ThumbnailUtils.createVideoThumbnail(filePath, kind);
|
||||||
} else {
|
} else {
|
||||||
bitmap = ThumbnailUtils.createImageThumbnail(filePath, kind);
|
bitmap = ThumbnailUtils.createImageThumbnail(filePath, kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (SQLiteException ex) {
|
} catch (SQLiteException ex) {
|
||||||
Log.w(TAG, ex);
|
Log.w(TAG, ex);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user