mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 18:51:51 +01:00
ImageView.setVectorCompat now uses AttrRes
This commit is contained in:
parent
656192f7cd
commit
249190d85c
@ -7,7 +7,6 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.databinding.DownloadItemBinding
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
|
||||
/**
|
||||
@ -55,8 +54,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
||||
|
||||
binding.downloadMenu.setVectorCompat(
|
||||
R.drawable.ic_more_vert_24dp,
|
||||
view.context
|
||||
.getResourceColor(android.R.attr.textColorPrimary)
|
||||
android.R.attr.textColorPrimary
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||
@ -52,13 +51,11 @@ class MigrationProcessHolder(
|
||||
|
||||
binding.migrationMenu.setVectorCompat(
|
||||
R.drawable.ic_more_vert_24dp,
|
||||
view.context.getResourceColor(android.R.attr.textColorPrimary)
|
||||
android.R.attr.textColorPrimary
|
||||
)
|
||||
binding.skipManga.setVectorCompat(
|
||||
R.drawable.ic_close_24dp,
|
||||
view.context.getResourceColor(
|
||||
android.R.attr.textColorPrimary
|
||||
)
|
||||
android.R.attr.textColorPrimary
|
||||
)
|
||||
binding.migrationMenu.isInvisible = true
|
||||
binding.skipManga.isVisible = true
|
||||
|
@ -1,20 +1,22 @@
|
||||
package eu.kanade.tachiyomi.util.view
|
||||
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
|
||||
/**
|
||||
* Set a vector on a [ImageView].
|
||||
*
|
||||
* @param drawable id of drawable resource
|
||||
*/
|
||||
fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
|
||||
val vector = VectorDrawableCompat.create(resources, drawable, context.theme)
|
||||
fun ImageView.setVectorCompat(@DrawableRes drawable: Int, @AttrRes tint: Int? = null) {
|
||||
val vector = AppCompatResources.getDrawable(context, drawable)
|
||||
if (tint != null) {
|
||||
vector?.mutate()
|
||||
vector?.setTint(tint)
|
||||
vector?.setTint(context.getResourceColor(tint))
|
||||
}
|
||||
setImageDrawable(vector)
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import androidx.core.view.isVisible
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.CommonViewEmptyBinding
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
|
||||
class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
@ -40,7 +39,7 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
||||
* @param textResource text of information view
|
||||
*/
|
||||
fun show(@DrawableRes drawable: Int, message: String, actions: List<Action>? = null) {
|
||||
binding.imageView.setVectorCompat(drawable, context.getResourceColor(android.R.attr.textColorHint))
|
||||
binding.imageView.setVectorCompat(drawable, android.R.attr.textColorHint)
|
||||
binding.textLabel.text = message
|
||||
|
||||
binding.actionsContainer.removeAllViews()
|
||||
|
Loading…
Reference in New Issue
Block a user