From 3357e878a5b0c2590f98f24414bdba26a3a21765 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 16 May 2020 16:35:40 -0400 Subject: [PATCH] Square covers in list view (closes #3121) --- .../browse/source/browse/SourceListHolder.kt | 9 ++++++-- .../tachiyomi/ui/library/LibraryGridHolder.kt | 1 + .../tachiyomi/ui/library/LibraryListHolder.kt | 10 ++++++-- .../tachiyomi/ui/migration/MangaHolder.kt | 10 ++++++-- .../ui/recent/updates/UpdatesHolder.kt | 23 ++++++++++++------- app/src/main/res/layout/source_list_item.xml | 4 +--- app/src/main/res/layout/updates_item.xml | 2 ++ 7 files changed, 42 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceListHolder.kt index acf36de16..5aa2c7288 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceListHolder.kt @@ -2,6 +2,9 @@ package eu.kanade.tachiyomi.ui.browse.source.browse import android.view.View import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.load.resource.bitmap.CenterCrop +import com.bumptech.glide.load.resource.bitmap.RoundedCorners +import com.bumptech.glide.request.RequestOptions import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga @@ -40,12 +43,14 @@ class SourceListHolder(private val view: View, adapter: FlexibleAdapter<*>) : override fun setImage(manga: Manga) { GlideApp.with(view.context).clear(thumbnail) + if (!manga.thumbnail_url.isNullOrEmpty()) { + val radius = view.context.resources.getDimensionPixelSize(R.dimen.card_radius) + val requestOptions = RequestOptions().transform(CenterCrop(), RoundedCorners(radius)) GlideApp.with(view.context) .load(manga.toMangaThumbnail()) .diskCacheStrategy(DiskCacheStrategy.DATA) - .centerCrop() - .circleCrop() + .apply(requestOptions) .dontAnimate() .placeholder(android.R.color.transparent) .into(thumbnail) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt index 1ee979eb3..a8e3ea1dc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt @@ -60,6 +60,7 @@ class LibraryGridHolder( .load(item.manga.toMangaThumbnail()) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) .centerCrop() + .dontAnimate() .into(thumbnail) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt index 946fbe346..661502812 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt @@ -2,7 +2,11 @@ package eu.kanade.tachiyomi.ui.library import android.view.View import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.load.resource.bitmap.CenterCrop +import com.bumptech.glide.load.resource.bitmap.RoundedCorners +import com.bumptech.glide.request.RequestOptions import eu.davidea.flexibleadapter.FlexibleAdapter +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.util.isLocal @@ -59,11 +63,13 @@ class LibraryListHolder( // Update the cover. GlideApp.with(itemView.context).clear(thumbnail) + + val radius = view.context.resources.getDimensionPixelSize(R.dimen.card_radius) + val requestOptions = RequestOptions().transform(CenterCrop(), RoundedCorners(radius)) GlideApp.with(itemView.context) .load(item.manga.toMangaThumbnail()) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - .centerCrop() - .circleCrop() + .apply(requestOptions) .dontAnimate() .into(thumbnail) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt index b42d42561..a3f337c7a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt @@ -2,7 +2,11 @@ package eu.kanade.tachiyomi.ui.migration import android.view.View import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.load.resource.bitmap.CenterCrop +import com.bumptech.glide.load.resource.bitmap.RoundedCorners +import com.bumptech.glide.request.RequestOptions import eu.davidea.flexibleadapter.FlexibleAdapter +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder @@ -26,11 +30,13 @@ class MangaHolder( // Update the cover. GlideApp.with(itemView.context).clear(thumbnail) + + val radius = itemView.context.resources.getDimensionPixelSize(R.dimen.card_radius) + val requestOptions = RequestOptions().transform(CenterCrop(), RoundedCorners(radius)) GlideApp.with(itemView.context) .load(item.manga.toMangaThumbnail()) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - .centerCrop() - .circleCrop() + .apply(requestOptions) .dontAnimate() .into(thumbnail) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt index db627344c..eb3e433b9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt @@ -2,6 +2,9 @@ package eu.kanade.tachiyomi.ui.recent.updates import android.view.View import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.load.resource.bitmap.CenterCrop +import com.bumptech.glide.load.resource.bitmap.RoundedCorners +import com.bumptech.glide.request.RequestOptions import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.glide.GlideApp @@ -54,14 +57,6 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter) // Set manga title manga_title.text = item.manga.title - // Set cover - GlideApp.with(itemView.context).clear(manga_cover) - GlideApp.with(itemView.context) - .load(item.manga.toMangaThumbnail()) - .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - .circleCrop() - .into(manga_cover) - // Check if chapter is read and set correct color if (item.chapter.read) { chapter_title.setTextColor(readColor) @@ -73,6 +68,18 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter) // Set chapter status notifyStatus(item.status) + + // Set cover + GlideApp.with(itemView.context).clear(manga_cover) + + val radius = itemView.context.resources.getDimensionPixelSize(R.dimen.card_radius) + val requestOptions = RequestOptions().transform(CenterCrop(), RoundedCorners(radius)) + GlideApp.with(itemView.context) + .load(item.manga.toMangaThumbnail()) + .diskCacheStrategy(DiskCacheStrategy.RESOURCE) + .apply(requestOptions) + .dontAnimate() + .into(manga_cover) } /** diff --git a/app/src/main/res/layout/source_list_item.xml b/app/src/main/res/layout/source_list_item.xml index 4b02de638..c1beaedf0 100644 --- a/app/src/main/res/layout/source_list_item.xml +++ b/app/src/main/res/layout/source_list_item.xml @@ -14,9 +14,7 @@ android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height" android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height" android:layout_gravity="center_vertical" - android:layout_marginStart="8dp" - android:paddingTop="8dp" - android:paddingBottom="8dp" + android:padding="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/app/src/main/res/layout/updates_item.xml b/app/src/main/res/layout/updates_item.xml index 264782558..858356cdd 100644 --- a/app/src/main/res/layout/updates_item.xml +++ b/app/src/main/res/layout/updates_item.xml @@ -12,7 +12,9 @@ android:layout_width="56dp" android:layout_height="0dp" android:paddingStart="16dp" + android:paddingTop="8dp" android:paddingEnd="0dp" + android:paddingBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"