Skip to content

Commit 8923be8

Browse files
authored
⚡️ [Android] Use last modified date for Glide caches key (#848)
1 parent fc03caf commit 8923be8

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ that can be found in the LICENSE file. -->
44

55
# CHANGELOG
66

7+
## 2.4.1
8+
9+
### Improvements
10+
11+
- Use last modified date for Glide caches key on Android. (#848)
12+
713
## 2.4.0
814

915
### Features

android/src/main/kotlin/com/fluttercandies/photo_manager/core/PhotoManager.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ class PhotoManager(private val context: Context) {
9393
resultHandler.replyError("The asset not found!")
9494
return
9595
}
96-
val uri = asset.getUri()
9796
ThumbnailUtil.getThumbnail(
9897
context,
99-
uri,
98+
asset,
10099
option.width,
101100
option.height,
102101
format,

android/src/main/kotlin/com/fluttercandies/photo_manager/thumb/ThumbnailUtil.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import com.bumptech.glide.Glide
77
import com.bumptech.glide.Priority
88
import com.bumptech.glide.request.FutureTarget
99
import com.bumptech.glide.request.RequestOptions
10+
import com.bumptech.glide.signature.ObjectKey
11+
import com.fluttercandies.photo_manager.core.entity.AssetEntity
1012
import io.flutter.plugin.common.MethodChannel
1113
import com.fluttercandies.photo_manager.core.entity.ThumbLoadOption
1214
import com.fluttercandies.photo_manager.util.ResultHandler
@@ -42,7 +44,7 @@ object ThumbnailUtil {
4244

4345
fun getThumbnail(
4446
context: Context,
45-
uri: Uri,
47+
entity: AssetEntity,
4648
width: Int,
4749
height: Int,
4850
format: Bitmap.CompressFormat,
@@ -56,7 +58,8 @@ object ThumbnailUtil {
5658
val resource = Glide.with(context)
5759
.asBitmap()
5860
.apply(RequestOptions().frame(frame).priority(Priority.IMMEDIATE))
59-
.load(uri)
61+
.load(entity.getUri())
62+
.signature(ObjectKey(entity.modifiedDate))
6063
.submit(width, height).get()
6164
val bos = ByteArrayOutputStream()
6265
resource.compress(format, quality, bos)

example/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: photo_manager_example
22
description: Demonstrates how to use the photo_manager plugin.
3-
version: 2.4.0+18
3+
version: 2.4.1+19
44
publish_to: none
55

66
environment:

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: photo_manager
22
description: A Flutter plugin that provides assets abstraction management APIs on Android, iOS, and macOS.
33
repository: https://github.com/fluttercandies/flutter_photo_manager
4-
version: 2.4.0
4+
version: 2.4.1
55

66
environment:
77
sdk: ">=2.13.0 <3.0.0"

0 commit comments

Comments
 (0)