Use the text itself as a color identifier

This commit is contained in:
davidoskky 2023-03-25 21:58:36 +01:00
parent 1ad529067d
commit ea6261c975
4 changed files with 11 additions and 5 deletions

View File

@ -80,7 +80,9 @@ class ItemCardAdapter(
}
if (itm.getIcon(repository.baseUrl).isEmpty()) {
binding.sourceImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString())
binding.sourceImage.setBackgroundAndText(
itm.sourcetitle.getHtmlDecoded().toTextDrawableString()
)
} else {
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage)
}

View File

@ -52,7 +52,9 @@ class ItemListAdapter(
if (itm.getThumbnail(repository.baseUrl).isEmpty()) {
if (itm.getIcon(repository.baseUrl).isEmpty()) {
binding.itemImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString())
binding.itemImage.setBackgroundAndText(
itm.sourcetitle.getHtmlDecoded().toTextDrawableString()
)
} else {
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage)
}

View File

@ -46,7 +46,9 @@ class SourcesListAdapter(
val itm = items[position]
if (itm.getIcon(repository.baseUrl).isEmpty()) {
binding.itemImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString())
binding.itemImage.setBackgroundAndText(
itm.title.getHtmlDecoded().toTextDrawableString()
)
} else {
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage)
}

View File

@ -46,9 +46,9 @@ class CircleImageView @JvmOverloads constructor(
textView = view.findViewById(R.id.circleText)
}
fun setBackgroundAndText(colorIdentifier: String, text: String) {
fun setBackgroundAndText(text: String) {
val circleDrawable = GradientDrawable()
val color = colorFromIdentifier(colorIdentifier)
val color = colorFromIdentifier(text)
circleDrawable.setColor(color)
imageView.setImageDrawable(circleDrawable)