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 {
|
val bitmap: Bitmap? = this.context?.run {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
this.contentResolver.loadThumbnail(
|
try {
|
||||||
ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, mediumId.toLong()),
|
this.contentResolver.loadThumbnail(
|
||||||
Size(width ?: 72, height ?: 72),
|
ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, mediumId.toLong()),
|
||||||
|
Size(width ?: 72, height ?: 72),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
null
|
null
|
||||||
)
|
}
|
||||||
} else {
|
} else {
|
||||||
MediaStore.Images.Thumbnails.getThumbnail(
|
MediaStore.Images.Thumbnails.getThumbnail(
|
||||||
this.contentResolver, mediumId.toLong(),
|
this.contentResolver, mediumId.toLong(),
|
||||||
@ -430,11 +434,15 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
|||||||
|
|
||||||
val bitmap: Bitmap? = this.context?.run {
|
val bitmap: Bitmap? = this.context?.run {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
this.contentResolver.loadThumbnail(
|
try {
|
||||||
ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, mediumId.toLong()),
|
this.contentResolver.loadThumbnail(
|
||||||
Size(width ?: 72, height ?: 72),
|
ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, mediumId.toLong()),
|
||||||
|
Size(width ?: 72, height ?: 72),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
null
|
null
|
||||||
)
|
}
|
||||||
} else {
|
} else {
|
||||||
MediaStore.Video.Thumbnails.getThumbnail(
|
MediaStore.Video.Thumbnails.getThumbnail(
|
||||||
this.contentResolver, mediumId.toLong(),
|
this.contentResolver, mediumId.toLong(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user