From 84d546b724dd4b5819f9f7ca20605378ed6471d0 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sun, 15 Aug 2021 21:53:25 +0700 Subject: [PATCH] Set expanded cover dimension ratio from the source image (#5721) Avoids cropping. --- .../ui/manga/info/MangaInfoHeaderAdapter.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt index d6777d89f..bb8b17333 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt @@ -6,6 +6,7 @@ import android.view.ViewGroup import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import coil.loadAny +import coil.target.ImageViewTarget import com.google.android.material.dialog.MaterialAlertDialogBuilder import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga @@ -262,8 +263,17 @@ class MangaInfoHeaderAdapter( setFavoriteButtonState(manga.favorite) // Set cover if changed. - listOfNotNull(binding.mangaCover, binding.backdrop).forEach { - it.loadAny(manga) + binding.backdrop.loadAny(manga) + binding.mangaCover.loadAny(manga) { + listener( + onSuccess = { request, _ -> + (request.target as? ImageViewTarget)?.drawable?.let { drawable -> + val ratio = drawable.minimumWidth / drawable.minimumHeight.toFloat() + binding.root.getConstraintSet(R.id.end) + ?.setDimensionRatio(R.id.manga_cover, ratio.toString()) + } + } + ) } // Manga info section