extracting helper for setting horizontal padding

This commit is contained in:
Adam Brown 2022-04-11 09:24:23 +01:00
parent 1f6068976d
commit 215cac2aec
2 changed files with 11 additions and 6 deletions

View file

@ -32,3 +32,12 @@ fun View.showKeyboard(andRequestFocus: Boolean = false) {
val imm = context?.getSystemService<InputMethodManager>()
imm?.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT)
}
fun View.setHorizontalPadding(padding: Int?) {
setPadding(
padding ?: paddingLeft,
paddingTop,
padding ?: paddingRight,
paddingBottom
)
}

View file

@ -26,6 +26,7 @@ import im.vector.app.R
import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.onClick
import im.vector.app.core.extensions.setHorizontalPadding
@EpoxyModelClass(layout = R.layout.item_policy)
abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
@ -50,12 +51,7 @@ abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
override fun bind(holder: Holder) {
super.bind(holder)
holder.let {
it.view.setPadding(
horizontalPadding ?: it.view.paddingLeft,
it.view.paddingTop,
horizontalPadding ?: it.view.paddingRight,
it.view.paddingBottom
)
it.view.setHorizontalPadding(horizontalPadding)
it.checkbox.isChecked = checked
it.checkbox.setOnCheckedChangeListener(checkChangeListener)
it.title.text = title