From f01e616369abe1ba5be57c0327c14af45155fa77 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 16:37:37 +0100 Subject: [PATCH] Use the circular image view in the item list --- .../android/adapters/ItemListAdapter.kt | 20 ++++--------------- androidApp/src/main/res/layout/list_item.xml | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt index bbd53c2..1cbe9ba 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt @@ -9,8 +9,7 @@ import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.android.databinding.ListItemBinding 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.openItemUrl import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.repository.Repository @@ -18,8 +17,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 org.kodein.di.DI import org.kodein.di.android.closestDI import org.kodein.di.instance @@ -29,7 +26,6 @@ class ItemListAdapter( override var items: ArrayList, override val updateItems: (ArrayList) -> Unit ) : ItemsAdapter() { - private val generator: ColorGenerator = ColorGenerator.MATERIAL private val c: Context = app.baseContext override val di: DI by closestDI(app) @@ -56,20 +52,12 @@ class ItemListAdapter( if (itm.getThumbnail(repository.baseUrl).isEmpty()) { 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.itemImage.setImageDrawable(drawable) + binding.itemImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString()) } else { - c.circularBitmapDrawable(itm.getIcon(repository.baseUrl), binding.itemImage) + c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage) } } else { - c.bitmapCenterCrop(itm.getThumbnail(repository.baseUrl), binding.itemImage) + c.circularDrawable(itm.getThumbnail(repository.baseUrl), binding.itemImage) } } } diff --git a/androidApp/src/main/res/layout/list_item.xml b/androidApp/src/main/res/layout/list_item.xml index 8e36b3b..9b66604 100644 --- a/androidApp/src/main/res/layout/list_item.xml +++ b/androidApp/src/main/res/layout/list_item.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> -