mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
improving the performance at media scrolling
This commit is contained in:
parent
7957f28b97
commit
a77580df50
6 changed files with 26 additions and 27 deletions
|
@ -77,7 +77,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.32.22'
|
||||
implementation 'com.simplemobiletools:commons:5.32.25'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
|
||||
|
@ -97,8 +97,8 @@ dependencies {
|
|||
kapt 'com.github.bumptech.glide:compiler:4.10.0'
|
||||
|
||||
kapt 'androidx.room:room-compiler:2.2.6'
|
||||
implementation 'androidx.room:room-runtime:2.2.5'
|
||||
annotationProcessor 'androidx.room:room-compiler:2.2.5'
|
||||
implementation 'androidx.room:room-runtime:2.2.6'
|
||||
annotationProcessor 'androidx.room:room-compiler:2.2.6'
|
||||
}
|
||||
|
||||
// Apply the PESDKPlugin
|
||||
|
|
|
@ -167,7 +167,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
val path = directoryDao.getDirectoryThumbnail(folderPath)
|
||||
if (path != null) {
|
||||
runOnUiThread {
|
||||
loadJpg(path, config_image, config.cropThumbnails, ROUNDED_CORNERS_NONE)
|
||||
loadJpg(path, config_image, config.cropThumbnails, ROUNDED_CORNERS_NONE, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -710,7 +710,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
else -> ROUNDED_CORNERS_BIG
|
||||
}
|
||||
|
||||
activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners)
|
||||
activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, directory.modified)
|
||||
}
|
||||
|
||||
dir_pin.beVisibleIf(pinnedFolders.contains(directory.path))
|
||||
|
|
|
@ -18,10 +18,7 @@ import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
|||
import com.simplemobiletools.commons.dialogs.RenameDialog
|
||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.FAVORITES
|
||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
|
@ -544,14 +541,16 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
|
||||
val roundedCorners = if (isListViewType) ROUNDED_CORNERS_SMALL else ROUNDED_CORNERS_NONE
|
||||
if (loadImageInstantly) {
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, rotatedImagePaths)
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, medium.modified,
|
||||
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, roundedCorners, rotatedImagePaths)
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners,
|
||||
medium.modified, rotatedImagePaths)
|
||||
}
|
||||
}, IMAGE_LOAD_DELAY)
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList<String>, callback:
|
|||
|
||||
out?.flush()
|
||||
|
||||
if (fileDocument?.getItemSize(true) == copiedSize && getDoesFilePathExist(destination)) {
|
||||
if (fileDocument.getItemSize(true) == copiedSize && getDoesFilePathExist(destination)) {
|
||||
mediaDB.updateDeleted("$RECYCLE_BIN$source", System.currentTimeMillis(), source)
|
||||
pathsCnt--
|
||||
}
|
||||
|
|
|
@ -398,17 +398,17 @@ fun Context.getFolderNameFromPath(path: String): String {
|
|||
}
|
||||
|
||||
fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean,
|
||||
roundCorners: Int, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
roundCorners: Int, lastModified: Long, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
target.isHorizontalScrolling = horizontalScroll
|
||||
if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS || type == TYPE_PORTRAITS) {
|
||||
if (type == TYPE_IMAGES && path.isPng()) {
|
||||
loadPng(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths)
|
||||
loadPng(path, target, cropThumbnails, roundCorners, lastModified, skipMemoryCacheAtPaths)
|
||||
} else {
|
||||
loadJpg(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths)
|
||||
loadJpg(path, target, cropThumbnails, roundCorners, lastModified, skipMemoryCacheAtPaths)
|
||||
}
|
||||
} else if (type == TYPE_GIFS) {
|
||||
if (!animateGifs) {
|
||||
loadStaticGIF(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths)
|
||||
loadStaticGIF(path, target, cropThumbnails, roundCorners, lastModified, skipMemoryCacheAtPaths)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -419,12 +419,12 @@ 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) {
|
||||
loadStaticGIF(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths)
|
||||
loadStaticGIF(path, target, cropThumbnails, roundCorners, lastModified, skipMemoryCacheAtPaths)
|
||||
} catch (e: OutOfMemoryError) {
|
||||
loadStaticGIF(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths)
|
||||
loadStaticGIF(path, target, cropThumbnails, roundCorners, lastModified, skipMemoryCacheAtPaths)
|
||||
}
|
||||
} else if (type == TYPE_SVGS) {
|
||||
loadSVG(path, target, cropThumbnails, roundCorners)
|
||||
loadSVG(path, target, cropThumbnails, roundCorners, lastModified)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,9 +449,9 @@ fun Context.getPathLocation(path: String): Int {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, lastModified: Long, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
val options = RequestOptions()
|
||||
.signature(path.getFileSignature())
|
||||
.signature(path.getFileSignature(lastModified))
|
||||
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.priority(Priority.LOW)
|
||||
|
@ -472,9 +472,9 @@ fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boo
|
|||
builder.into(target)
|
||||
}
|
||||
|
||||
fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, lastModified: Long, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
val options = RequestOptions()
|
||||
.signature(path.getFileSignature())
|
||||
.signature(path.getFileSignature(lastModified))
|
||||
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
|
||||
.priority(Priority.LOW)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
|
@ -494,9 +494,9 @@ fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boo
|
|||
builder.into(target)
|
||||
}
|
||||
|
||||
fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, lastModified: Long, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
val options = RequestOptions()
|
||||
.signature(path.getFileSignature())
|
||||
.signature(path.getFileSignature(lastModified))
|
||||
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
|
||||
.priority(Priority.LOW)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
|
@ -516,10 +516,10 @@ fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnail
|
|||
builder.into(target)
|
||||
}
|
||||
|
||||
fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int) {
|
||||
fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, lastModified: Long) {
|
||||
target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
|
||||
|
||||
val options = RequestOptions().signature(path.getFileSignature())
|
||||
val options = RequestOptions().signature(path.getFileSignature(lastModified))
|
||||
var builder = Glide.with(applicationContext)
|
||||
.`as`(PictureDrawable::class.java)
|
||||
.listener(SvgSoftwareLayerSetter())
|
||||
|
|
Loading…
Reference in a new issue