From eb3799283ea7c8184fd318ad3697ee6276ee5846 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Mon, 19 Dec 2022 11:32:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Reply=20errors=20when=20thumbnai?= =?UTF-8?q?ls=20failed=20to=20load=20(#883)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++ .../photo_manager/thumb/ThumbnailUtil.kt | 28 +------------------ example/pubspec.yaml | 2 +- pubspec.yaml | 2 +- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 949fd642..4bc189de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ that can be found in the LICENSE file. --> # CHANGELOG +## 2.5.2 + +### Improvements + +- Reply errors when thumbnails are failed to load on Android. (#883) + ## 2.5.1+1 ### Fixes diff --git a/android/src/main/kotlin/com/fluttercandies/photo_manager/thumb/ThumbnailUtil.kt b/android/src/main/kotlin/com/fluttercandies/photo_manager/thumb/ThumbnailUtil.kt index 5b8e3eb5..bed45105 100644 --- a/android/src/main/kotlin/com/fluttercandies/photo_manager/thumb/ThumbnailUtil.kt +++ b/android/src/main/kotlin/com/fluttercandies/photo_manager/thumb/ThumbnailUtil.kt @@ -16,32 +16,6 @@ import java.io.ByteArrayOutputStream import java.io.File object ThumbnailUtil { - fun getThumbnail( - ctx: Context, - path: String, - width: Int, - height: Int, - format: Bitmap.CompressFormat, - quality: Int, - frame: Long, - result: MethodChannel.Result? - ) { - val resultHandler = ResultHandler(result) - - try { - val resource = Glide.with(ctx) - .asBitmap() - .apply(RequestOptions().frame(frame).priority(Priority.IMMEDIATE)) - .load(File(path)) - .submit(width, height).get() - val bos = ByteArrayOutputStream() - resource.compress(format, quality, bos) - resultHandler.reply(bos.toByteArray()) - } catch (e: Exception) { - resultHandler.reply(null) - } - } - fun getThumbnail( context: Context, entity: AssetEntity, @@ -65,7 +39,7 @@ object ThumbnailUtil { resource.compress(format, quality, bos) resultHandler.reply(bos.toByteArray()) } catch (e: Exception) { - resultHandler.reply(null) + resultHandler.replyError("Thumbnail request error", e.toString()) } } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 3b928ffc..c40a7d7e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: photo_manager_example description: Demonstrates how to use the photo_manager plugin. -version: 2.5.1+24 +version: 2.5.2+25 publish_to: none environment: diff --git a/pubspec.yaml b/pubspec.yaml index 3f4436dd..a9b03402 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: photo_manager description: A Flutter plugin that provides assets abstraction management APIs on Android, iOS, and macOS. repository: https://github.com/fluttercandies/flutter_photo_manager -version: 2.5.1+1 +version: 2.5.2 environment: sdk: ">=2.13.0 <3.0.0"