Skip to content

Commit

Permalink
🥅 Reply errors when thumbnails failed to load (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored Dec 19, 2022
1 parent 210ba5a commit eb37992
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit eb37992

Please sign in to comment.