properly cache fullscreen images

This commit is contained in:
tibbi 2020-06-12 13:06:16 +02:00
parent df610dfa4b
commit bb33cee722
4 changed files with 9 additions and 4 deletions

View file

@ -78,12 +78,12 @@ android {
} }
dependencies { 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 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' 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.android.exoplayer:exoplayer-core:2.9.6'
implementation 'com.google.vr:sdk-panowidget:1.180.0' implementation 'com.google.vr:sdk-panowidget:1.180.0'
implementation 'com.google.vr:sdk-videowidget:1.180.0' implementation 'com.google.vr:sdk-videowidget:1.180.0'

View file

@ -599,7 +599,7 @@ class PhotoFragment : ViewPagerFragment() {
val minTileDpi = if (showHighestQuality) -1 else getMinTileDpi() val minTileDpi = if (showHighestQuality) -1 else getMinTileDpi()
val bitmapDecoder = object : DecoderFactory<ImageDecoder> { val bitmapDecoder = object : DecoderFactory<ImageDecoder> {
override fun make() = MyGlideImageDecoder(rotation) override fun make() = MyGlideImageDecoder(rotation, mMedium.getSignature())
} }
val regionDecoder = object : DecoderFactory<ImageRegionDecoder> { val regionDecoder = object : DecoderFactory<ImageRegionDecoder> {

View file

@ -7,13 +7,15 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.load.DecodeFormat import com.bumptech.glide.load.DecodeFormat
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target import com.bumptech.glide.request.target.Target
import com.bumptech.glide.signature.ObjectKey
import com.davemorrissey.labs.subscaleview.ImageDecoder 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 { override fun decode(context: Context, uri: Uri): Bitmap {
val options = RequestOptions() val options = RequestOptions()
.format(DecodeFormat.PREFER_ARGB_8888) .format(DecodeFormat.PREFER_ARGB_8888)
.signature(signature)
.fitCenter() .fitCenter()
val builder = Glide.with(context) val builder = Glide.with(context)

View file

@ -5,6 +5,7 @@ import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.Index import androidx.room.Index
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import com.bumptech.glide.signature.ObjectKey
import com.simplemobiletools.commons.extensions.formatDate import com.simplemobiletools.commons.extensions.formatDate
import com.simplemobiletools.commons.extensions.formatSize import com.simplemobiletools.commons.extensions.formatSize
import com.simplemobiletools.commons.extensions.getFilenameExtension import com.simplemobiletools.commons.extensions.getFilenameExtension
@ -86,4 +87,6 @@ data class Medium(
return calendar.timeInMillis.toString() return calendar.timeInMillis.toString()
} }
fun getSignature() = ObjectKey("$path-$modified")
} }