take the Crop Thumbnails setting into consideration when displaying thumbnails

This commit is contained in:
tibbi 2017-03-23 20:52:48 +01:00
parent a5faf7a0a5
commit e9115530ea
1 changed files with 46 additions and 26 deletions

View File

@ -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)
}