use an improved way of file thumbnail caching

This commit is contained in:
tibbi 2021-01-14 20:59:52 +01:00
parent c9ee4f8f60
commit d68aee2b5f
4 changed files with 18 additions and 4 deletions

View file

@ -95,7 +95,7 @@ class DecompressItemsAdapter(activity: SimpleActivity, var listItems: MutableLis
} else {
val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").toLowerCase(), { fileDrawable })
val options = RequestOptions()
.signature(listItem.mPath.getFileSignature())
.signature(listItem.getKey())
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.error(drawable)
.centerCrop()

View file

@ -736,7 +736,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").toLowerCase(), { fileDrawable })
val options = RequestOptions()
.signature(listItem.mPath.getFileSignature())
.signature(listItem.getKey())
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.error(drawable)
.transform(CenterCrop(), RoundedCorners(10))

View file

@ -231,7 +231,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
return
}
val lastModifieds = if (isRPlus()) context!!.getFolderLastModifieds(path) else HashMap()
val lastModifieds = context!!.getFolderLastModifieds(path)
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
if (files != null) {
for (file in files) {

View file

@ -1,6 +1,20 @@
package com.simplemobiletools.filemanager.pro.models
import com.bumptech.glide.signature.ObjectKey
import com.simplemobiletools.commons.models.FileDirItem
import java.io.File
data class ListItem(val mPath: String, val mName: String = "", var mIsDirectory: Boolean = false, var mChildren: Int = 0, var mSize: Long = 0L, var mModified: Long = 0L,
var isSectionTitle: Boolean) : FileDirItem(mPath, mName, mIsDirectory, mChildren, mSize, mModified)
var isSectionTitle: Boolean) : FileDirItem(mPath, mName, mIsDirectory, mChildren, mSize, mModified) {
fun getSignature(): String {
val lastModified = if (modified > 1) {
modified
} else {
File(path).lastModified()
}
return "$path-$lastModified-$size"
}
fun getKey() = ObjectKey(getSignature())
}