Use ShapeableImageView for rounded thumbnails instead of Coil transformations

This commit is contained in:
arkon 2021-08-31 22:35:52 -04:00
parent 59aef13200
commit 0e26abf7a6
11 changed files with 21 additions and 38 deletions

View File

@ -3,9 +3,7 @@ package eu.kanade.tachiyomi.ui.browse.migration.manga
import android.view.View import android.view.View
import coil.clear import coil.clear
import coil.loadAny import coil.loadAny
import coil.transform.RoundedCornersTransformation
import eu.davidea.viewholders.FlexibleViewHolder import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.SourceListItemBinding import eu.kanade.tachiyomi.databinding.SourceListItemBinding
class MigrationMangaHolder( class MigrationMangaHolder(
@ -24,11 +22,8 @@ class MigrationMangaHolder(
fun bind(item: MigrationMangaItem) { fun bind(item: MigrationMangaItem) {
binding.title.text = item.manga.title binding.title.text = item.manga.title
// Update the cover. // Update the cover
val radius = itemView.context.resources.getDimension(R.dimen.card_radius)
binding.thumbnail.clear() binding.thumbnail.clear()
binding.thumbnail.loadAny(item.manga) { binding.thumbnail.loadAny(item.manga)
transformations(RoundedCornersTransformation(radius))
}
} }
} }

View File

@ -4,7 +4,6 @@ import android.view.View
import androidx.core.view.isVisible import androidx.core.view.isVisible
import coil.clear import coil.clear
import coil.loadAny import coil.loadAny
import coil.transform.RoundedCornersTransformation
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher
@ -53,10 +52,8 @@ class SourceListHolder(private val view: View, adapter: FlexibleAdapter<*>) :
override fun setImage(manga: Manga) { override fun setImage(manga: Manga) {
binding.thumbnail.clear() binding.thumbnail.clear()
if (!manga.thumbnail_url.isNullOrEmpty()) { if (!manga.thumbnail_url.isNullOrEmpty()) {
val radius = view.context.resources.getDimension(R.dimen.card_radius)
binding.thumbnail.loadAny(manga) { binding.thumbnail.loadAny(manga) {
setParameter(MangaCoverFetcher.USE_CUSTOM_COVER, false) setParameter(MangaCoverFetcher.USE_CUSTOM_COVER, false)
transformations(RoundedCornersTransformation(radius))
} }
} }
} }

View File

@ -4,9 +4,7 @@ import android.view.View
import androidx.core.view.isVisible import androidx.core.view.isVisible
import coil.clear import coil.clear
import coil.loadAny import coil.loadAny
import coil.transform.RoundedCornersTransformation
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.SourceListItemBinding import eu.kanade.tachiyomi.databinding.SourceListItemBinding
/** /**
@ -57,11 +55,8 @@ class LibraryListHolder(
onLongClick(itemView) onLongClick(itemView)
} }
// Update the cover. // Update the cover
val radius = view.context.resources.getDimension(R.dimen.card_radius)
binding.thumbnail.clear() binding.thumbnail.clear()
binding.thumbnail.loadAny(item.manga) { binding.thumbnail.loadAny(item.manga)
transformations(RoundedCornersTransformation(radius))
}
} }
} }

View File

@ -4,10 +4,8 @@ import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import coil.clear import coil.clear
import coil.loadAny import coil.loadAny
import coil.transform.RoundedCornersTransformation
import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.databinding.TrackSearchItemBinding import eu.kanade.tachiyomi.databinding.TrackSearchItemBinding
import eu.kanade.tachiyomi.util.system.dpToPx
import java.util.Locale import java.util.Locale
class TrackSearchHolder( class TrackSearchHolder(
@ -24,9 +22,7 @@ class TrackSearchHolder(
binding.trackSearchTitle.text = track.title binding.trackSearchTitle.text = track.title
binding.trackSearchCover.clear() binding.trackSearchCover.clear()
if (track.cover_url.isNotEmpty()) { if (track.cover_url.isNotEmpty()) {
binding.trackSearchCover.loadAny(track.cover_url) { binding.trackSearchCover.loadAny(track.cover_url)
transformations(RoundedCornersTransformation(6.dpToPx.toFloat()))
}
} }
val hasStatus = track.publishing_status.isNotBlank() val hasStatus = track.publishing_status.isNotBlank()

View File

@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.recent.history
import android.view.View import android.view.View
import coil.clear import coil.clear
import coil.loadAny import coil.loadAny
import coil.transform.RoundedCornersTransformation
import eu.davidea.viewholders.FlexibleViewHolder import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
@ -66,10 +65,7 @@ class HistoryHolder(
} }
// Set cover // Set cover
val radius = itemView.context.resources.getDimension(R.dimen.card_radius)
binding.cover.clear() binding.cover.clear()
binding.cover.loadAny(item.manga) { binding.cover.loadAny(item.manga)
transformations(RoundedCornersTransformation(radius))
}
} }
} }

View File

@ -4,8 +4,6 @@ import android.view.View
import androidx.core.view.isVisible import androidx.core.view.isVisible
import coil.clear import coil.clear
import coil.loadAny import coil.loadAny
import coil.transform.RoundedCornersTransformation
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.UpdatesItemBinding import eu.kanade.tachiyomi.databinding.UpdatesItemBinding
import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.ui.manga.chapter.base.BaseChapterHolder import eu.kanade.tachiyomi.ui.manga.chapter.base.BaseChapterHolder
@ -55,10 +53,7 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter)
binding.download.setState(item.status, item.progress) binding.download.setState(item.status, item.progress)
// Set cover // Set cover
val radius = itemView.context.resources.getDimension(R.dimen.card_radius)
binding.mangaCover.clear() binding.mangaCover.clear()
binding.mangaCover.loadAny(item.manga) { binding.mangaCover.loadAny(item.manga)
transformations(RoundedCornersTransformation(radius))
}
} }
} }

View File

@ -12,7 +12,7 @@
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/cover" android:id="@+id/cover"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -22,6 +22,7 @@
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:shapeAppearance="@style/ShapeAppearanceOverlay.Cover"
tools:src="@mipmap/ic_launcher" /> tools:src="@mipmap/ic_launcher" />
<LinearLayout <LinearLayout

View File

@ -8,7 +8,7 @@
android:background="@drawable/list_item_selector_background" android:background="@drawable/list_item_selector_background"
android:paddingHorizontal="8dp"> android:paddingHorizontal="8dp">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/thumbnail" android:id="@+id/thumbnail"
android:layout_width="56dp" android:layout_width="56dp"
android:layout_height="56dp" android:layout_height="56dp"
@ -18,6 +18,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/ShapeAppearanceOverlay.Cover"
tools:src="@mipmap/ic_launcher" /> tools:src="@mipmap/ic_launcher" />
<TextView <TextView

View File

@ -16,7 +16,7 @@
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/track_search_cover" android:id="@+id/track_search_cover"
android:layout_width="68dp" android:layout_width="68dp"
android:layout_height="95dp" android:layout_height="95dp"
@ -26,6 +26,7 @@
android:scaleType="centerCrop" android:scaleType="centerCrop"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/ShapeAppearanceOverlay.Cover"
tools:src="@mipmap/ic_launcher" /> tools:src="@mipmap/ic_launcher" />
<TextView <TextView

View File

@ -5,13 +5,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:background="@drawable/list_item_selector_background" android:background="@drawable/list_item_selector_background"
android:paddingStart="12dp"
android:paddingEnd="4dp"> android:paddingEnd="4dp">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/manga_cover" 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_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
@ -19,6 +19,7 @@
app:layout_constraintDimensionRatio="h,1:1" app:layout_constraintDimensionRatio="h,1:1"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/ShapeAppearanceOverlay.Cover"
tools:src="@mipmap/ic_launcher" /> tools:src="@mipmap/ic_launcher" />
<TextView <TextView

View File

@ -327,6 +327,11 @@
<item name="cornerSize">8dp</item> <item name="cornerSize">8dp</item>
</style> </style>
<style name="ShapeAppearanceOverlay.Cover" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">@dimen/card_radius</item>
</style>
<style name="ThemeOverlay.Tachiyomi.Dialog.Fullscreen" parent="ThemeOverlay.MaterialComponents"> <style name="ThemeOverlay.Tachiyomi.Dialog.Fullscreen" parent="ThemeOverlay.MaterialComponents">
<item name="android:windowIsFloating">false</item> <item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">?android:attr/colorBackground</item> <item name="android:windowBackground">?android:attr/colorBackground</item>