take the Crop Thumbnails setting into consideration when displaying thumbnails
This commit is contained in:
parent
a5faf7a0a5
commit
e9115530ea
|
@ -188,37 +188,57 @@ fun SimpleActivity.removeNoMedia(path: String, callback: () -> Unit) {
|
|||
fun Activity.loadImage(path: String, target: MySquareImageView) {
|
||||
if (path.isImageFast() || path.isVideoFast()) {
|
||||
if (path.isPng()) {
|
||||
Glide.with(this)
|
||||
loadPng(path, target)
|
||||
} else {
|
||||
loadJpg(path, target)
|
||||
}
|
||||
} else if (path.isGif()) {
|
||||
if (config.animateGifs) {
|
||||
loadAnimatedGif(path, target)
|
||||
} else {
|
||||
loadStaticGif(path, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.loadPng(path: String, target: MySquareImageView) {
|
||||
val builder = Glide.with(this)
|
||||
.load(path)
|
||||
.asBitmap()
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||
.centerCrop()
|
||||
.into(target)
|
||||
} else {
|
||||
Glide.with(this)
|
||||
|
||||
if (config.cropThumbnails) builder.centerCrop() else builder.fitCenter()
|
||||
builder.into(target)
|
||||
}
|
||||
|
||||
fun Activity.loadJpg(path: String, target: MySquareImageView) {
|
||||
val builder = Glide.with(this)
|
||||
.load(path)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||
.centerCrop()
|
||||
.crossFade()
|
||||
.into(target)
|
||||
|
||||
if (config.cropThumbnails) builder.centerCrop() else builder.fitCenter()
|
||||
builder.into(target)
|
||||
}
|
||||
} else if (path.isGif()) {
|
||||
if (config.animateGifs) {
|
||||
Glide.with(this)
|
||||
|
||||
fun Activity.loadAnimatedGif(path: String, target: MySquareImageView) {
|
||||
val builder = Glide.with(this)
|
||||
.load(path)
|
||||
.asGif()
|
||||
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
||||
.centerCrop()
|
||||
.crossFade()
|
||||
.into(target)
|
||||
} else {
|
||||
Glide.with(this)
|
||||
|
||||
if (config.cropThumbnails) builder.centerCrop() else builder.fitCenter()
|
||||
builder.into(target)
|
||||
}
|
||||
|
||||
fun Activity.loadStaticGif(path: String, target: MySquareImageView) {
|
||||
val builder = Glide.with(this)
|
||||
.load(path)
|
||||
.asBitmap()
|
||||
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
||||
.centerCrop()
|
||||
.into(target)
|
||||
}
|
||||
}
|
||||
|
||||
if (config.cropThumbnails) builder.centerCrop() else builder.fitCenter()
|
||||
builder.into(target)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue