Remove unnecessary TextViewCompat calls.

This commit is contained in:
Isira Seneviratne 2023-02-04 05:31:51 +05:30
parent 0e6b906a12
commit 2973b204dd
2 changed files with 1 additions and 42 deletions

View File

@ -1,9 +1,7 @@
package com.github.libretube.ui.extensions
import android.graphics.drawable.Drawable
import android.widget.TextView
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.widget.TextViewCompat
fun TextView.setDrawables(
start: Int? = null,
@ -11,19 +9,10 @@ fun TextView.setDrawables(
end: Int? = null,
bottom: Int? = null
) {
setDrawables(
setCompoundDrawablesRelativeWithIntrinsicBounds(
start?.let { AppCompatResources.getDrawable(context, it) },
top?.let { AppCompatResources.getDrawable(context, it) },
end?.let { AppCompatResources.getDrawable(context, it) },
bottom?.let { AppCompatResources.getDrawable(context, it) }
)
}
fun TextView.setDrawables(
start: Drawable? = null,
top: Drawable? = null,
end: Drawable? = null,
bottom: Drawable? = null
) {
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(this, start, top, end, bottom)
}

View File

@ -6,7 +6,6 @@ import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.Gravity
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.widget.TextViewCompat
import com.github.libretube.R
/**
@ -73,33 +72,4 @@ class DrawableTextView(
}
return this
}
fun setDrawables(
start: Drawable? = null,
top: Drawable? = null,
end: Drawable? = null,
bottom: Drawable? = null
) {
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
this,
start,
top,
end,
bottom
)
}
fun setDrawablesDimension(
start: Float = drawableStartDimen,
top: Float = drawableTopDimen,
end: Float = drawableEndDimen,
bottom: Float = drawableBottomDimen
) {
drawableStartDimen = start
drawableTopDimen = top
drawableEndDimen = end
drawableBottomDimen = bottom
invalidate()
}
}