moving the picasso loading function down, no real change

This commit is contained in:
tibbi 2021-02-18 21:03:25 +01:00
parent 2561c96c92
commit 063d09c8fa
1 changed files with 27 additions and 27 deletions

View File

@ -494,33 +494,6 @@ fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boo
builder.into(target)
}
// intended mostly for Android 11 issues, that fail loading PNG files bigger than 10 MB
fun Context.tryLoadingWithPicasso(path: String, view: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, signature: ObjectKey) {
var pathToLoad = "file://$path"
pathToLoad = pathToLoad.replace("%", "%25").replace("#", "%23")
try {
var builder = Picasso.get()
.load(pathToLoad)
.stableKey(signature.toString())
builder = if (cropThumbnails) {
builder.centerCrop().fit()
} else {
builder.centerInside()
}
if (roundCorners != ROUNDED_CORNERS_NONE) {
val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big
val cornerRadius = resources.getDimension(cornerSize).toInt()
builder = builder.transform(RoundedCornersTransformation(cornerRadius.toFloat()))
}
builder.into(view)
} catch (e: Exception) {
}
}
fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, signature: ObjectKey, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
val options = RequestOptions()
.signature(signature)
@ -585,6 +558,33 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo
builder.into(target)
}
// intended mostly for Android 11 issues, that fail loading PNG files bigger than 10 MB
fun Context.tryLoadingWithPicasso(path: String, view: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, signature: ObjectKey) {
var pathToLoad = "file://$path"
pathToLoad = pathToLoad.replace("%", "%25").replace("#", "%23")
try {
var builder = Picasso.get()
.load(pathToLoad)
.stableKey(signature.toString())
builder = if (cropThumbnails) {
builder.centerCrop().fit()
} else {
builder.centerInside()
}
if (roundCorners != ROUNDED_CORNERS_NONE) {
val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big
val cornerRadius = resources.getDimension(cornerSize).toInt()
builder = builder.transform(RoundedCornersTransformation(cornerRadius.toFloat()))
}
builder.into(view)
} catch (e: Exception) {
}
}
fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, forceShowHidden: Boolean = false, callback: (ArrayList<Directory>) -> Unit) {
ensureBackgroundThread {
val directories = try {