wrap contentResolver.loadThumbnail method in try/catch, when FileNotFoundException threw return null instead.
This commit is contained in:
parent
95bd030e91
commit
9196eddccd
@ -402,11 +402,15 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
||||
|
||||
val bitmap: Bitmap? = this.context?.run {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
try {
|
||||
this.contentResolver.loadThumbnail(
|
||||
ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, mediumId.toLong()),
|
||||
Size(width ?: 72, height ?: 72),
|
||||
null
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
MediaStore.Images.Thumbnails.getThumbnail(
|
||||
this.contentResolver, mediumId.toLong(),
|
||||
@ -430,11 +434,15 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
||||
|
||||
val bitmap: Bitmap? = this.context?.run {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
try {
|
||||
this.contentResolver.loadThumbnail(
|
||||
ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, mediumId.toLong()),
|
||||
Size(width ?: 72, height ?: 72),
|
||||
null
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
MediaStore.Video.Thumbnails.getThumbnail(
|
||||
this.contentResolver, mediumId.toLong(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user