Merge pull request #2958 from Isira-Seneviratne/Remove_TextViewCompat

Remove unnecessary TextViewCompat calls.
This commit is contained in:
Bnyro 2023-02-04 08:54:35 +01:00 committed by GitHub
commit 459d8f92ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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()
}
}