From 6ef6743527d6586613618a426cfbf22eae1dbccc Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 16:31:49 +0100 Subject: [PATCH] Use the circular image view in the card adapter --- .../android/adapters/ItemCardAdapter.kt | 16 +++------------- androidApp/src/main/res/layout/card_item.xml | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt index f21bd77..3e98d9c 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt @@ -12,7 +12,7 @@ import bou.amine.apps.readerforselfossv2.android.databinding.CardItemBinding import bou.amine.apps.readerforselfossv2.android.model.toTextDrawableString import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener import bou.amine.apps.readerforselfossv2.android.utils.glide.bitmapCenterCrop -import bou.amine.apps.readerforselfossv2.android.utils.glide.circularBitmapDrawable +import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable import bou.amine.apps.readerforselfossv2.android.utils.openInBrowserAsNewTask import bou.amine.apps.readerforselfossv2.android.utils.openItemUrl import bou.amine.apps.readerforselfossv2.android.utils.shareLink @@ -22,8 +22,6 @@ import bou.amine.apps.readerforselfossv2.service.AppSettingsService import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded import bou.amine.apps.readerforselfossv2.utils.getIcon import bou.amine.apps.readerforselfossv2.utils.getThumbnail -import com.amulyakhare.textdrawable.TextDrawable -import com.amulyakhare.textdrawable.util.ColorGenerator import com.bumptech.glide.Glide import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -38,7 +36,6 @@ class ItemCardAdapter( override val updateItems: (ArrayList) -> Unit ) : ItemsAdapter() { private val c: Context = app.baseContext - private val generator: ColorGenerator = ColorGenerator.MATERIAL private val imageMaxHeight: Int = c.resources.getDimension(R.dimen.card_image_max_height).toInt() @@ -83,16 +80,9 @@ class ItemCardAdapter( } if (itm.getIcon(repository.baseUrl).isEmpty()) { - val color = generator.getColor(itm.title.getHtmlDecoded()) - - val drawable = - TextDrawable - .builder() - .round() - .build(itm.title.getHtmlDecoded().toTextDrawableString(), color) - binding.sourceImage.setImageDrawable(drawable) + binding.sourceImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString()) } else { - c.circularBitmapDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage) + c.circularDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage) } } } diff --git a/androidApp/src/main/res/layout/card_item.xml b/androidApp/src/main/res/layout/card_item.xml index 329b68e..b153220 100644 --- a/androidApp/src/main/res/layout/card_item.xml +++ b/androidApp/src/main/res/layout/card_item.xml @@ -39,7 +39,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/itemImage"> -