Lighter weight method of rounding cover art

This commit is contained in:
arkon 2020-05-03 22:29:09 -04:00
parent 018dbce57e
commit dabca5f09e
7 changed files with 34 additions and 44 deletions

View File

@ -34,6 +34,9 @@ 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

@ -38,6 +38,9 @@ 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(

View File

@ -85,6 +85,9 @@ class MangaInfoController(private val fromSource: Boolean = false) :
override fun onViewCreated(view: View) { override fun onViewCreated(view: View) {
super.onViewCreated(view) super.onViewCreated(view)
// Setting this via XML doesn't work
binding.mangaCover.clipToOutline = true
binding.btnFavorite.clicks() binding.btnFavorite.clicks()
.onEach { onFavoriteClick() } .onEach { onFavoriteClick() }
.launchIn(scope) .launchIn(scope)

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/card_radius" />
<solid android:color="?attr/colorSurface" />
</shape>

View File

@ -11,45 +11,32 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.cardview.widget.CardView <ImageView
android:id="@+id/manga_cover_card" android:id="@+id/manga_cover"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginStart="16dp" android:layout_margin="16dp"
android:layout_marginTop="16dp" android:background="@drawable/rounded_rectangle"
android:layout_marginBottom="16dp" android:contentDescription="@string/description_cover"
app:cardCornerRadius="@dimen/card_radius"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,3:2" app:layout_constraintDimensionRatio="h,3:2"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"> app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="@+id/manga_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/description_cover"
tools:background="@color/material_grey_700" />
</androidx.cardview.widget.CardView>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/info_scrollview" android:id="@+id/info_scrollview"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/manga_cover_card" app:layout_constraintStart_toEndOf="@+id/manga_cover"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:padding="16dp">
<TextView <TextView
android:id="@+id/manga_full_title" android:id="@+id/manga_full_title"

View File

@ -38,29 +38,18 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:background="@color/material_grey_700" /> tools:background="@color/material_grey_700" />
<androidx.cardview.widget.CardView <ImageView
android:id="@+id/manga_cover_card" android:id="@+id/manga_cover"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginStart="16dp" android:layout_margin="16dp"
android:layout_marginTop="16dp" android:background="@drawable/rounded_rectangle"
android:layout_marginEnd="16dp" android:contentDescription="@string/description_cover"
android:layout_marginBottom="16dp"
app:cardCornerRadius="@dimen/card_radius"
app:layout_constraintDimensionRatio="h,2:3"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,2:3"
app:layout_constraintEnd_toStartOf="@+id/guideline2" app:layout_constraintEnd_toStartOf="@+id/guideline2"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/manga_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/description_cover"
tools:background="@color/material_grey_700" />
</androidx.cardview.widget.CardView>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/manga_info_section" android:id="@+id/manga_info_section"

View File

@ -7,18 +7,17 @@
android:background="@drawable/library_item_selector" android:background="@drawable/library_item_selector"
android:padding="4dp"> android:padding="4dp">
<androidx.cardview.widget.CardView <FrameLayout
android:id="@+id/card" android:id="@+id/card"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="220dp" android:layout_height="220dp"
app:cardCornerRadius="@dimen/card_radius"> android:background="@drawable/rounded_rectangle">
<ImageView <ImageView
android:id="@+id/thumbnail" android:id="@+id/thumbnail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
tools:background="?attr/colorSurface"
tools:ignore="ContentDescription" tools:ignore="ContentDescription"
tools:src="@mipmap/ic_launcher" /> tools:src="@mipmap/ic_launcher" />
@ -120,6 +119,6 @@
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="gone" /> android:visibility="gone" />
</androidx.cardview.widget.CardView> </FrameLayout>
</FrameLayout> </FrameLayout>