textDrawable #136
@ -9,7 +9,6 @@ import android.widget.ImageView.ScaleType
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import bou.amine.apps.readerforselfossv2.android.R
|
||||
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.circularDrawable
|
||||
@ -80,7 +79,7 @@ class ItemCardAdapter(
|
||||
}
|
||||
|
||||
if (itm.getIcon(repository.baseUrl).isEmpty()) {
|
||||
binding.sourceImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString())
|
||||
binding.sourceImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded())
|
||||
} else {
|
||||
AmineB marked this conversation as resolved
Outdated
|
||||
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage)
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
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.circularDrawable
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.openItemUrl
|
||||
@ -52,7 +51,7 @@ 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())
|
||||
} else {
|
||||
AmineB marked this conversation as resolved
Outdated
AmineB
commented
Same as before:
Same as before:
```
binding.itemImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded())
```
|
||||
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage)
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
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.circularDrawable
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
@ -46,7 +45,7 @@ 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())
|
||||
} else {
|
||||
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage)
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.model.toTextDrawableString
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import kotlin.math.abs
|
||||
|
||||
@ -46,13 +47,13 @@ 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)
|
||||
|
||||
textView.text = text
|
||||
textView.text = text.toTextDrawableString()
|
||||
}
|
||||
|
||||
private fun colorFromIdentifier(key: String): Int {
|
||||
|
Loading…
Reference in New Issue
Block a user
You could call
setBackgroundAndText
with a single parameter, and calltoTextDrawableString
inside.Also, here, there is an issue, it should be
itm.sourcetitle
that should be used.