mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Remove unnecessary TextViewCompat calls.
This commit is contained in:
parent
0e6b906a12
commit
2973b204dd
@ -1,9 +1,7 @@
|
|||||||
package com.github.libretube.ui.extensions
|
package com.github.libretube.ui.extensions
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import androidx.core.widget.TextViewCompat
|
|
||||||
|
|
||||||
fun TextView.setDrawables(
|
fun TextView.setDrawables(
|
||||||
start: Int? = null,
|
start: Int? = null,
|
||||||
@ -11,19 +9,10 @@ fun TextView.setDrawables(
|
|||||||
end: Int? = null,
|
end: Int? = null,
|
||||||
bottom: Int? = null
|
bottom: Int? = null
|
||||||
) {
|
) {
|
||||||
setDrawables(
|
setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||||
start?.let { AppCompatResources.getDrawable(context, it) },
|
start?.let { AppCompatResources.getDrawable(context, it) },
|
||||||
top?.let { AppCompatResources.getDrawable(context, it) },
|
top?.let { AppCompatResources.getDrawable(context, it) },
|
||||||
end?.let { AppCompatResources.getDrawable(context, it) },
|
end?.let { AppCompatResources.getDrawable(context, it) },
|
||||||
bottom?.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)
|
|
||||||
}
|
|
||||||
|
@ -6,7 +6,6 @@ import android.graphics.drawable.Drawable
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
import androidx.core.widget.TextViewCompat
|
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,33 +72,4 @@ class DrawableTextView(
|
|||||||
}
|
}
|
||||||
return this
|
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user