mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
add cache signatures to thumbnails
This commit is contained in:
parent
152a56c32b
commit
94258a57fa
1 changed files with 6 additions and 0 deletions
|
@ -13,6 +13,7 @@ import android.view.ViewConfiguration
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.DecodeFormat
|
import com.bumptech.glide.load.DecodeFormat
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
|
import com.bumptech.glide.signature.StringSignature
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.BuildConfig
|
import com.simplemobiletools.gallery.BuildConfig
|
||||||
|
@ -185,6 +186,7 @@ fun SimpleActivity.removeNoMedia(path: String, callback: () -> Unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Activity.getFileSignature(path: String) = StringSignature(File(path).lastModified().toString())
|
||||||
fun Activity.loadImage(path: String, target: MySquareImageView) {
|
fun Activity.loadImage(path: String, target: MySquareImageView) {
|
||||||
if (path.isImageFast() || path.isVideoFast()) {
|
if (path.isImageFast() || path.isVideoFast()) {
|
||||||
if (path.isPng()) {
|
if (path.isPng()) {
|
||||||
|
@ -205,6 +207,7 @@ fun Activity.loadPng(path: String, target: MySquareImageView) {
|
||||||
val builder = Glide.with(this)
|
val builder = Glide.with(this)
|
||||||
.load(path)
|
.load(path)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
|
.signature(getFileSignature(path))
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
|
|
||||||
|
@ -215,6 +218,7 @@ fun Activity.loadPng(path: String, target: MySquareImageView) {
|
||||||
fun Activity.loadJpg(path: String, target: MySquareImageView) {
|
fun Activity.loadJpg(path: String, target: MySquareImageView) {
|
||||||
val builder = Glide.with(this)
|
val builder = Glide.with(this)
|
||||||
.load(path)
|
.load(path)
|
||||||
|
.signature(getFileSignature(path))
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||||
.crossFade()
|
.crossFade()
|
||||||
|
|
||||||
|
@ -226,6 +230,7 @@ fun Activity.loadAnimatedGif(path: String, target: MySquareImageView) {
|
||||||
val builder = Glide.with(this)
|
val builder = Glide.with(this)
|
||||||
.load(path)
|
.load(path)
|
||||||
.asGif()
|
.asGif()
|
||||||
|
.signature(getFileSignature(path))
|
||||||
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
||||||
.crossFade()
|
.crossFade()
|
||||||
|
|
||||||
|
@ -237,6 +242,7 @@ fun Activity.loadStaticGif(path: String, target: MySquareImageView) {
|
||||||
val builder = Glide.with(this)
|
val builder = Glide.with(this)
|
||||||
.load(path)
|
.load(path)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
|
.signature(getFileSignature(path))
|
||||||
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
||||||
|
|
||||||
if (config.cropThumbnails) builder.centerCrop() else builder.fitCenter()
|
if (config.cropThumbnails) builder.centerCrop() else builder.fitCenter()
|
||||||
|
|
Loading…
Reference in a new issue