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

View file

@ -188,37 +188,57 @@ fun SimpleActivity.removeNoMedia(path: String, callback: () -> Unit) {
fun Activity.loadImage(path: String, target: MySquareImageView) { fun Activity.loadImage(path: String, target: MySquareImageView) {
if (path.isImageFast() || path.isVideoFast()) { if (path.isImageFast() || path.isVideoFast()) {
if (path.isPng()) { if (path.isPng()) {
Glide.with(this) loadPng(path, target)
.load(path)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.format(DecodeFormat.PREFER_ARGB_8888)
.centerCrop()
.into(target)
} else { } else {
Glide.with(this) loadJpg(path, target)
.load(path)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.centerCrop()
.crossFade()
.into(target)
} }
} else if (path.isGif()) { } else if (path.isGif()) {
if (config.animateGifs) { if (config.animateGifs) {
Glide.with(this) loadAnimatedGif(path, target)
.load(path)
.asGif()
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.centerCrop()
.crossFade()
.into(target)
} else { } else {
Glide.with(this) loadStaticGif(path, target)
.load(path)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.centerCrop()
.into(target)
} }
} }
} }
fun Activity.loadPng(path: String, target: MySquareImageView) {
val builder = Glide.with(this)
.load(path)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.format(DecodeFormat.PREFER_ARGB_8888)
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)
.crossFade()
if (config.cropThumbnails) builder.centerCrop() else builder.fitCenter()
builder.into(target)
}
fun Activity.loadAnimatedGif(path: String, target: MySquareImageView) {
val builder = Glide.with(this)
.load(path)
.asGif()
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.crossFade()
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)
if (config.cropThumbnails) builder.centerCrop() else builder.fitCenter()
builder.into(target)
}