From bb33cee722521c2a226dfff7dd33560bd5d43654 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 12 Jun 2020 13:06:16 +0200 Subject: [PATCH] properly cache fullscreen images --- app/build.gradle | 4 ++-- .../simplemobiletools/gallery/pro/fragments/PhotoFragment.kt | 2 +- .../gallery/pro/helpers/MyGlideImageDecoder.kt | 4 +++- .../kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt | 3 +++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1c7695781..48603de79 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,12 +78,12 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.29.0' + implementation 'com.simplemobiletools:commons:5.29.1' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' - implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6' implementation 'com.google.android.exoplayer:exoplayer-core:2.9.6' implementation 'com.google.vr:sdk-panowidget:1.180.0' implementation 'com.google.vr:sdk-videowidget:1.180.0' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 3495e80a9..06222dfe7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -599,7 +599,7 @@ class PhotoFragment : ViewPagerFragment() { val minTileDpi = if (showHighestQuality) -1 else getMinTileDpi() val bitmapDecoder = object : DecoderFactory { - override fun make() = MyGlideImageDecoder(rotation) + override fun make() = MyGlideImageDecoder(rotation, mMedium.getSignature()) } val regionDecoder = object : DecoderFactory { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyGlideImageDecoder.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyGlideImageDecoder.kt index c1bd9b3a0..f56fc88d0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyGlideImageDecoder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyGlideImageDecoder.kt @@ -7,13 +7,15 @@ import com.bumptech.glide.Glide import com.bumptech.glide.load.DecodeFormat import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.target.Target +import com.bumptech.glide.signature.ObjectKey import com.davemorrissey.labs.subscaleview.ImageDecoder -class MyGlideImageDecoder(val degrees: Int) : ImageDecoder { +class MyGlideImageDecoder(val degrees: Int, val signature: ObjectKey) : ImageDecoder { override fun decode(context: Context, uri: Uri): Bitmap { val options = RequestOptions() .format(DecodeFormat.PREFER_ARGB_8888) + .signature(signature) .fitCenter() val builder = Glide.with(context) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt index 894feae17..50b9bb87c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt @@ -5,6 +5,7 @@ import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.Index import androidx.room.PrimaryKey +import com.bumptech.glide.signature.ObjectKey import com.simplemobiletools.commons.extensions.formatDate import com.simplemobiletools.commons.extensions.formatSize import com.simplemobiletools.commons.extensions.getFilenameExtension @@ -86,4 +87,6 @@ data class Medium( return calendar.timeInMillis.toString() } + + fun getSignature() = ObjectKey("$path-$modified") }