Reduce cross fade duration to 150ms

This commit is contained in:
Naveen 2024-04-16 16:11:52 +05:30
parent 140af47c0d
commit 86b22f828a
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3
2 changed files with 33 additions and 9 deletions

View file

@ -1,5 +1,6 @@
package org.fossify.gallery.extensions
import android.annotation.SuppressLint
import android.appwidget.AppWidgetManager
import android.content.ComponentName
import android.content.Context
@ -472,8 +473,15 @@ fun Context.getFolderNameFromPath(path: String): String {
}
fun Context.loadImage(
type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean,
roundCorners: Int, signature: ObjectKey, skipMemoryCacheAtPaths: ArrayList<String>? = null
type: Int,
path: String,
target: MySquareImageView,
horizontalScroll: Boolean,
animateGifs: Boolean,
cropThumbnails: Boolean,
roundCorners: Int,
signature: ObjectKey,
skipMemoryCacheAtPaths: ArrayList<String>? = null,
) {
target.isHorizontalScrolling = horizontalScroll
if (type == TYPE_SVGS) {
@ -505,6 +513,7 @@ fun Context.getPathLocation(path: String): Int {
}
}
@SuppressLint("CheckResult")
fun Context.loadImageBase(
path: String,
target: MySquareImageView,
@ -514,7 +523,7 @@ fun Context.loadImageBase(
skipMemoryCacheAtPaths: ArrayList<String>? = null,
animate: Boolean = false,
tryLoadingWithPicasso: Boolean = false,
crossFadeDuration: Int = 300
crossFadeDuration: Int = THUMBNAIL_FADE_DURATION_MS,
) {
val options = RequestOptions()
.signature(signature)
@ -572,7 +581,7 @@ fun Context.loadImageBase(
model: Any,
targetBitmap: Target<Drawable>,
dataSource: DataSource,
isFirstResource: Boolean
isFirstResource: Boolean,
): Boolean {
return false
}
@ -582,7 +591,14 @@ fun Context.loadImageBase(
builder.into(target)
}
fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, signature: ObjectKey) {
fun Context.loadSVG(
path: String,
target: MySquareImageView,
cropThumbnails: Boolean,
roundCorners: Int,
signature: ObjectKey,
crossFadeDuration: Int = THUMBNAIL_FADE_DURATION_MS,
) {
target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
val options = RequestOptions().signature(signature)
@ -591,7 +607,7 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo
.listener(SvgSoftwareLayerSetter())
.load(path)
.apply(options)
.transition(DrawableTransitionOptions.withCrossFade())
.transition(DrawableTransitionOptions.withCrossFade(crossFadeDuration))
if (roundCorners != ROUNDED_CORNERS_NONE) {
val cornerSize =
@ -636,7 +652,7 @@ fun Context.getCachedDirectories(
getImagesOnly: Boolean = false,
forceShowHidden: Boolean = false,
forceShowExcluded: Boolean = false,
callback: (ArrayList<Directory>) -> Unit
callback: (ArrayList<Directory>) -> Unit,
) {
ensureBackgroundThread {
try {
@ -988,8 +1004,13 @@ fun Context.addPathToDB(path: String) {
}
fun Context.createDirectoryFromMedia(
path: String, curMedia: ArrayList<Medium>, albumCovers: ArrayList<AlbumCover>, hiddenString: String,
includedFolders: MutableSet<String>, getProperFileSize: Boolean, noMediaFolders: ArrayList<String>
path: String,
curMedia: ArrayList<Medium>,
albumCovers: ArrayList<AlbumCover>,
hiddenString: String,
includedFolders: MutableSet<String>,
getProperFileSize: Boolean,
noMediaFolders: ArrayList<String>,
): Directory {
val OTGPath = config.OTGPath
val grouped = MediaFetcher(this).groupMedia(curMedia, path)

View file

@ -245,6 +245,9 @@ const val FOLDER_MEDIA_CNT_NONE = 3
const val FOLDER_STYLE_SQUARE = 1
const val FOLDER_STYLE_ROUNDED_CORNERS = 2
// animations
const val THUMBNAIL_FADE_DURATION_MS = 150
fun getPermissionToRequest() = if (isTiramisuPlus()) PERMISSION_READ_MEDIA_IMAGES else PERMISSION_WRITE_STORAGE
fun getRequiredPermission() = if (isUpsideDownCakePlus()) PERMISSION_READ_MEDIA_VISUAL_USER_SELECTED else getPermissionToRequest()