textDrawable #136

Merged
AmineB merged 8 commits from davidoskky/ReaderForSelfoss-multiplatform:textDrawable into master 2023-03-26 11:12:03 +00:00
2 changed files with 4 additions and 14 deletions
Showing only changes of commit 6ef6743527 - Show all commits

View File

@ -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<SelfossModel.Item>) -> Unit
) : ItemsAdapter<ItemCardAdapter.ViewHolder>() {
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())
AmineB marked this conversation as resolved Outdated

You could call setBackgroundAndText with a single parameter, and call toTextDrawableString inside.

Also, here, there is an issue, it should be itm.sourcetitle that should be used.

                binding.sourceImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded()) 
You could call `setBackgroundAndText` with a single parameter, and call `toTextDrawableString` inside. Also, here, there is an issue, it should be `itm.sourcetitle` that should be used. ``` binding.sourceImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded()) ```
} else {
c.circularBitmapDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage)
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage)
}
}
}

View File

@ -39,7 +39,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/itemImage">
<ImageView
<bou.amine.apps.readerforselfossv2.android.utils.CircleImageView
android:id="@+id/sourceImage"
android:layout_width="40dp"
android:layout_height="40dp"