Move cover card outline clipping code from item to holder classes

This commit is contained in:
arkon 2020-05-16 16:32:14 -04:00
parent e810b343cf
commit 471d5d62d5
4 changed files with 8 additions and 6 deletions

View File

@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
import eu.kanade.tachiyomi.widget.StateImageViewTarget import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.source_grid_item.card
import kotlinx.android.synthetic.main.source_grid_item.progress import kotlinx.android.synthetic.main.source_grid_item.progress
import kotlinx.android.synthetic.main.source_grid_item.thumbnail import kotlinx.android.synthetic.main.source_grid_item.thumbnail
import kotlinx.android.synthetic.main.source_grid_item.title import kotlinx.android.synthetic.main.source_grid_item.title
@ -39,6 +40,9 @@ class SourceGridHolder(private val view: View, private val adapter: FlexibleAdap
} }
override fun setImage(manga: Manga) { override fun setImage(manga: Manga) {
// Setting this via XML doesn't work
card.clipToOutline = true
GlideApp.with(view.context).clear(thumbnail) GlideApp.with(view.context).clear(thumbnail)
if (!manga.thumbnail_url.isNullOrEmpty()) { if (!manga.thumbnail_url.isNullOrEmpty()) {
GlideApp.with(view.context) GlideApp.with(view.context)

View File

@ -34,9 +34,6 @@ class SourceItem(val manga: Manga, private val catalogueAsList: Preference<Boole
val parent = adapter.recyclerView val parent = adapter.recyclerView
return if (parent is AutofitRecyclerView) { return if (parent is AutofitRecyclerView) {
view.apply { view.apply {
// Setting this via XML doesn't work
card.clipToOutline = true
card.layoutParams = FrameLayout.LayoutParams( card.layoutParams = FrameLayout.LayoutParams(
MATCH_PARENT, parent.itemWidth / 3 * 4 MATCH_PARENT, parent.itemWidth / 3 * 4
) )

View File

@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.isLocal
import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.source_grid_item.card
import kotlinx.android.synthetic.main.source_grid_item.download_text import kotlinx.android.synthetic.main.source_grid_item.download_text
import kotlinx.android.synthetic.main.source_grid_item.local_text import kotlinx.android.synthetic.main.source_grid_item.local_text
import kotlinx.android.synthetic.main.source_grid_item.thumbnail import kotlinx.android.synthetic.main.source_grid_item.thumbnail
@ -50,6 +51,9 @@ class LibraryGridHolder(
// set local visibility if its local manga // set local visibility if its local manga
local_text.visibleIf { item.manga.isLocal() } local_text.visibleIf { item.manga.isLocal() }
// Setting this via XML doesn't work
card.clipToOutline = true
// Update the cover. // Update the cover.
GlideApp.with(view.context).clear(thumbnail) GlideApp.with(view.context).clear(thumbnail)
GlideApp.with(view.context) GlideApp.with(view.context)

View File

@ -39,9 +39,6 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference
val parent = adapter.recyclerView val parent = adapter.recyclerView
return if (parent is AutofitRecyclerView) { return if (parent is AutofitRecyclerView) {
view.apply { view.apply {
// Setting this via XML doesn't work
card.clipToOutline = true
val coverHeight = parent.itemWidth / 3 * 4 val coverHeight = parent.itemWidth / 3 * 4
card.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, coverHeight) card.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, coverHeight)
gradient.layoutParams = FrameLayout.LayoutParams( gradient.layoutParams = FrameLayout.LayoutParams(