mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
skip memory cache at loading thumbnails after rotation
This commit is contained in:
parent
56bc2b6af1
commit
f34ae01115
2 changed files with 15 additions and 9 deletions
|
@ -43,6 +43,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
private val viewType = config.getFolderViewType(if (config.showAll) SHOW_ALL else path)
|
||||
private val isListViewType = viewType == VIEW_TYPE_LIST
|
||||
private var visibleItemPaths = ArrayList<String>()
|
||||
private var rotatedImagePaths = ArrayList<String>()
|
||||
private var loadImageInstantly = false
|
||||
private var delayHandler = Handler(Looper.getMainLooper())
|
||||
private var currentMediaHash = media.hashCode()
|
||||
|
@ -280,7 +281,9 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
Thread {
|
||||
val paths = getSelectedPaths().filter { it.isImageFast() }
|
||||
var fileCnt = paths.size
|
||||
rotatedImagePaths.clear()
|
||||
paths.forEach {
|
||||
rotatedImagePaths.add(it)
|
||||
activity.saveRotatedImageToFile(it, it, degrees, true) {
|
||||
fileCnt--
|
||||
if (fileCnt == 0) {
|
||||
|
@ -460,14 +463,14 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
}
|
||||
|
||||
if (loadImageInstantly) {
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, rotatedImagePaths)
|
||||
} else {
|
||||
medium_thumbnail.setImageDrawable(null)
|
||||
medium_thumbnail.isHorizontalScrolling = scrollHorizontally
|
||||
delayHandler.postDelayed({
|
||||
val isVisible = visibleItemPaths.contains(medium.path)
|
||||
if (isVisible) {
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, rotatedImagePaths)
|
||||
}
|
||||
}, IMAGE_LOAD_DELAY)
|
||||
}
|
||||
|
|
|
@ -387,13 +387,14 @@ fun Context.getFolderNameFromPath(path: String): String {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean) {
|
||||
fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean,
|
||||
skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
target.isHorizontalScrolling = horizontalScroll
|
||||
if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS) {
|
||||
if (type == TYPE_IMAGES && path.isPng()) {
|
||||
loadPng(path, target, cropThumbnails)
|
||||
loadPng(path, target, cropThumbnails, skipMemoryCacheAtPaths)
|
||||
} else {
|
||||
loadJpg(path, target, cropThumbnails)
|
||||
loadJpg(path, target, cropThumbnails, skipMemoryCacheAtPaths)
|
||||
}
|
||||
} else if (type == TYPE_GIFS) {
|
||||
try {
|
||||
|
@ -407,9 +408,9 @@ fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizo
|
|||
|
||||
target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
|
||||
} catch (e: Exception) {
|
||||
loadJpg(path, target, cropThumbnails)
|
||||
loadJpg(path, target, cropThumbnails, skipMemoryCacheAtPaths)
|
||||
} catch (e: OutOfMemoryError) {
|
||||
loadJpg(path, target, cropThumbnails)
|
||||
loadJpg(path, target, cropThumbnails, skipMemoryCacheAtPaths)
|
||||
}
|
||||
} else if (type == TYPE_SVGS) {
|
||||
loadSVG(path, target, cropThumbnails)
|
||||
|
@ -435,9 +436,10 @@ fun Context.getPathLocation(path: String): Int {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean) {
|
||||
fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
val options = RequestOptions()
|
||||
.signature(path.getFileSignature())
|
||||
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||
|
||||
|
@ -449,9 +451,10 @@ fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boo
|
|||
builder.apply(options).into(target)
|
||||
}
|
||||
|
||||
fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean) {
|
||||
fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
val options = RequestOptions()
|
||||
.signature(path.getFileSignature())
|
||||
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
|
||||
val builder = Glide.with(applicationContext)
|
||||
|
|
Loading…
Reference in a new issue