Square covers in list view (closes #3121)

This commit is contained in:
arkon 2020-05-16 16:35:40 -04:00
parent 471d5d62d5
commit 3357e878a5
7 changed files with 42 additions and 17 deletions

View File

@ -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)

View File

@ -60,6 +60,7 @@ class LibraryGridHolder(
.load(item.manga.toMangaThumbnail())
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.centerCrop()
.dontAnimate()
.into(thumbnail)
}
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}
/**

View File

@ -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"

View File

@ -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"