From 9536e6e4653233a5a71ab7122307006c0807b297 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 16:34:38 +0100 Subject: [PATCH] Use the circular image view in the Source list --- .../android/adapters/SourcesListAdapter.kt | 18 ++++-------------- .../src/main/res/layout/source_list_item.xml | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt index 2eba4c1..8315eb6 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt @@ -10,17 +10,15 @@ import android.widget.Button import android.widget.Toast import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.RecyclerView -import bou.amine.apps.readerforselfossv2.android.UpsertSourceActivity import bou.amine.apps.readerforselfossv2.android.R +import bou.amine.apps.readerforselfossv2.android.UpsertSourceActivity import bou.amine.apps.readerforselfossv2.android.databinding.SourceListItemBinding import bou.amine.apps.readerforselfossv2.android.model.toTextDrawableString -import bou.amine.apps.readerforselfossv2.android.utils.glide.circularBitmapDrawable +import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded import bou.amine.apps.readerforselfossv2.utils.getIcon -import com.amulyakhare.textdrawable.TextDrawable -import com.amulyakhare.textdrawable.util.ColorGenerator import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -34,7 +32,6 @@ class SourcesListAdapter( private val items: ArrayList ) : RecyclerView.Adapter(), DIAware { private val c: Context = app.baseContext - private val generator: ColorGenerator = ColorGenerator.MATERIAL private lateinit var binding: SourceListItemBinding override val di: DI by closestDI(app) @@ -49,16 +46,9 @@ class SourcesListAdapter( val itm = items[position] 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) } if (!itm.error.isNullOrBlank()) { diff --git a/androidApp/src/main/res/layout/source_list_item.xml b/androidApp/src/main/res/layout/source_list_item.xml index d924c01..9ea0cfa 100644 --- a/androidApp/src/main/res/layout/source_list_item.xml +++ b/androidApp/src/main/res/layout/source_list_item.xml @@ -25,7 +25,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" /> -