diff --git a/vector/src/main/java/im/vector/app/core/platform/ButtonStateView.kt b/vector/src/main/java/im/vector/app/core/platform/ButtonStateView.kt index fe187a915e..ee2933f542 100755 --- a/vector/src/main/java/im/vector/app/core/platform/ButtonStateView.kt +++ b/vector/src/main/java/im/vector/app/core/platform/ButtonStateView.kt @@ -24,6 +24,8 @@ import android.widget.FrameLayout import androidx.core.view.isInvisible import androidx.core.view.isVisible import im.vector.app.R +import im.vector.app.core.epoxy.ClickListener +import im.vector.app.core.epoxy.onClick import im.vector.app.databinding.ViewButtonStateBinding class ButtonStateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) @@ -36,12 +38,9 @@ class ButtonStateView @JvmOverloads constructor(context: Context, attrs: Attribu object Error : State() } - var callback: Callback? = null - - interface Callback { - fun onButtonClicked() - fun onRetryClicked() - } + var commonClicked: ClickListener? = null + var buttonClicked: ClickListener? = null + var retryClicked: ClickListener? = null // Big or Flat button var button: Button @@ -54,8 +53,9 @@ class ButtonStateView @JvmOverloads constructor(context: Context, attrs: Attribu layoutParams = LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) - views.buttonStateRetry.setOnClickListener { - callback?.onRetryClicked() + views.buttonStateRetry.onClick { + commonClicked?.invoke(it) + retryClicked?.invoke(it) } // Read attributes @@ -80,8 +80,9 @@ class ButtonStateView @JvmOverloads constructor(context: Context, attrs: Attribu } } - button.setOnClickListener { - callback?.onButtonClicked() + button.onClick { + commonClicked?.invoke(it) + buttonClicked?.invoke(it) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomCategoryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomCategoryItem.kt index 9adddfd5d3..a4748bc9a6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomCategoryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomCategoryItem.kt @@ -23,8 +23,10 @@ import androidx.core.graphics.drawable.DrawableCompat import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick import im.vector.app.features.themes.ThemeUtils @EpoxyModelClass(layout = R.layout.item_room_category) @@ -34,7 +36,7 @@ abstract class RoomCategoryItem : VectorEpoxyModel() { @EpoxyAttribute var expanded: Boolean = false @EpoxyAttribute var unreadNotificationCount: Int = 0 @EpoxyAttribute var showHighlighted: Boolean = false - @EpoxyAttribute var listener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) @@ -46,7 +48,7 @@ abstract class RoomCategoryItem : VectorEpoxyModel() { holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted)) holder.titleView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) holder.titleView.text = title - holder.rootView.setOnClickListener { listener?.invoke() } + holder.rootView.onClick(listener) } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomInvitationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomInvitationItem.kt index 7327c5533e..b0cc8fec6c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomInvitationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomInvitationItem.kt @@ -22,8 +22,10 @@ import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.platform.ButtonStateView import im.vector.app.features.home.AvatarRenderer @@ -37,36 +39,16 @@ abstract class RoomInvitationItem : VectorEpoxyModel( @EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer @EpoxyAttribute lateinit var matrixItem: MatrixItem @EpoxyAttribute var secondLine: CharSequence? = null - @EpoxyAttribute var listener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null @EpoxyAttribute lateinit var changeMembershipState: ChangeMembershipState - @EpoxyAttribute var acceptListener: (() -> Unit)? = null - @EpoxyAttribute var rejectListener: (() -> Unit)? = null - - private val acceptCallback = object : ButtonStateView.Callback { - override fun onButtonClicked() { - acceptListener?.invoke() - } - - override fun onRetryClicked() { - acceptListener?.invoke() - } - } - - private val rejectCallback = object : ButtonStateView.Callback { - override fun onButtonClicked() { - rejectListener?.invoke() - } - - override fun onRetryClicked() { - rejectListener?.invoke() - } - } + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var acceptListener: ClickListener? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var rejectListener: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) - holder.rootView.setOnClickListener { listener?.invoke() } - holder.acceptView.callback = acceptCallback - holder.rejectView.callback = rejectCallback + holder.rootView.onClick(listener) + holder.acceptView.commonClicked = acceptListener + holder.rejectView.commonClicked = rejectListener InviteButtonStateBinder.bind(holder.acceptView, holder.rejectView, changeMembershipState) holder.titleView.text = matrixItem.getBestName() holder.subtitleView.setTextOrHide(secondLine) diff --git a/vector/src/main/java/im/vector/app/features/invite/VectorInviteView.kt b/vector/src/main/java/im/vector/app/features/invite/VectorInviteView.kt index 0c1030b774..b2919d59b8 100644 --- a/vector/src/main/java/im/vector/app/features/invite/VectorInviteView.kt +++ b/vector/src/main/java/im/vector/app/features/invite/VectorInviteView.kt @@ -23,10 +23,8 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.updateLayoutParams import im.vector.app.R import im.vector.app.core.di.HasScreenInjector -import im.vector.app.core.platform.ButtonStateView import im.vector.app.databinding.VectorInviteViewBinding import im.vector.app.features.home.AvatarRenderer - import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary import org.matrix.android.sdk.api.util.toMatrixItem @@ -56,25 +54,8 @@ class VectorInviteView @JvmOverloads constructor(context: Context, attrs: Attrib } inflate(context, R.layout.vector_invite_view, this) views = VectorInviteViewBinding.bind(this) - views.inviteAcceptView.callback = object : ButtonStateView.Callback { - override fun onButtonClicked() { - callback?.onAcceptInvite() - } - - override fun onRetryClicked() { - callback?.onAcceptInvite() - } - } - - views.inviteRejectView.callback = object : ButtonStateView.Callback { - override fun onButtonClicked() { - callback?.onRejectInvite() - } - - override fun onRetryClicked() { - callback?.onRejectInvite() - } - } + views.inviteAcceptView.commonClicked = { callback?.onAcceptInvite() } + views.inviteRejectView.commonClicked = { callback?.onRejectInvite() } } fun render(sender: RoomMemberSummary, mode: Mode = Mode.LARGE, changeMembershipState: ChangeMembershipState) { diff --git a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt index ad71d0b1b5..733eb0575e 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt @@ -51,19 +51,8 @@ class MatrixToRoomSpaceFragment @Inject constructor( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - views.matrixToCardMainButton.callback = object : ButtonStateView.Callback { - override fun onButtonClicked() { - mainButtonClicked() - } - - override fun onRetryClicked() = onButtonClicked() - } - views.matrixToCardSecondaryButton.callback = object : ButtonStateView.Callback { - override fun onButtonClicked() { - secondaryButtonClicked() - } - override fun onRetryClicked() = onButtonClicked() - } + views.matrixToCardMainButton.commonClicked = { mainButtonClicked() } + views.matrixToCardSecondaryButton.commonClicked = { secondaryButtonClicked() } } override fun invalidate() = withState(sharedViewModel) { state -> diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/PublicRoomItem.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/PublicRoomItem.kt index 3a4ba5bb34..1223e92673 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/PublicRoomItem.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/PublicRoomItem.kt @@ -22,8 +22,10 @@ import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.platform.ButtonStateView import im.vector.app.features.home.AvatarRenderer @@ -50,15 +52,15 @@ abstract class PublicRoomItem : VectorEpoxyModel() { @EpoxyAttribute var joinState: JoinState = JoinState.NOT_JOINED - @EpoxyAttribute - var globalListener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var globalListener: ClickListener? = null - @EpoxyAttribute - var joinListener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var joinListener: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) - holder.rootView.setOnClickListener { globalListener?.invoke() } + holder.rootView.onClick(globalListener) avatarRenderer.render(matrixItem, holder.avatarView) holder.nameView.text = matrixItem.displayName @@ -76,16 +78,7 @@ abstract class PublicRoomItem : VectorEpoxyModel() { } ) - holder.buttonState.callback = object : ButtonStateView.Callback { - override fun onButtonClicked() { - joinListener?.invoke() - } - - override fun onRetryClicked() { - // Same action - onButtonClicked() - } - } + holder.buttonState.commonClicked = { joinListener?.invoke(it) } } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/UnknownRoomItem.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/UnknownRoomItem.kt index 084f518405..1383aec54b 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/UnknownRoomItem.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/UnknownRoomItem.kt @@ -22,8 +22,10 @@ import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick import im.vector.app.features.home.AvatarRenderer import org.matrix.android.sdk.api.util.MatrixItem @@ -36,12 +38,12 @@ abstract class UnknownRoomItem : VectorEpoxyModel() { @EpoxyAttribute lateinit var matrixItem: MatrixItem - @EpoxyAttribute - var globalListener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var globalListener: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) - holder.rootView.setOnClickListener { globalListener?.invoke() } + holder.rootView.onClick(globalListener) avatarRenderer.render(matrixItem, holder.avatarView) holder.nameView.text = matrixItem.displayName } diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/picker/RoomDirectoryItem.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/picker/RoomDirectoryItem.kt index 7cf8e538ac..db1ba95e9e 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/picker/RoomDirectoryItem.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/picker/RoomDirectoryItem.kt @@ -25,8 +25,10 @@ import androidx.core.view.isVisible import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.glide.GlideApp @@ -48,12 +50,12 @@ abstract class RoomDirectoryItem : VectorEpoxyModel() @EpoxyAttribute var checked: Boolean = false - @EpoxyAttribute - var globalListener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var globalListener: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) - holder.rootView.setOnClickListener { globalListener?.invoke() } + holder.rootView.onClick(globalListener) // Avatar GlideApp.with(holder.avatarView) diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt index 5757bc1b9e..e1536281ef 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt @@ -57,16 +57,7 @@ class RoomPreviewNoPreviewFragment @Inject constructor( super.onViewCreated(view, savedInstanceState) setupToolbar(views.roomPreviewNoPreviewToolbar) - views.roomPreviewNoPreviewJoin.callback = object : ButtonStateView.Callback { - override fun onButtonClicked() { - roomPreviewViewModel.handle(RoomPreviewAction.Join) - } - - override fun onRetryClicked() { - // Same action - onButtonClicked() - } - } + views.roomPreviewNoPreviewJoin.commonClicked = { roomPreviewViewModel.handle(RoomPreviewAction.Join) } } override fun invalidate() = withState(roomPreviewViewModel) { state -> diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceItem.kt index 62c0b6149f..dd2883376f 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceItem.kt @@ -23,8 +23,10 @@ import androidx.core.view.isVisible import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick import im.vector.app.core.resources.ColorProvider import im.vector.app.core.ui.views.ShieldImageView import im.vector.app.core.utils.DimensionConverter @@ -47,8 +49,8 @@ abstract class DeviceItem : VectorEpoxyModel() { @EpoxyAttribute var currentDevice = false - @EpoxyAttribute - var itemClickAction: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var itemClickAction: ClickListener? = null @EpoxyAttribute var detailedMode = false @@ -73,7 +75,7 @@ abstract class DeviceItem : VectorEpoxyModel() { override fun bind(holder: Holder) { super.bind(holder) - holder.root.setOnClickListener { itemClickAction?.invoke() } + holder.root.onClick(itemClickAction) if (e2eCapable) { val shield = TrustUtils.shieldForTrust( diff --git a/vector/src/main/java/im/vector/app/features/settings/ignored/UserItem.kt b/vector/src/main/java/im/vector/app/features/settings/ignored/UserItem.kt index 286ebbb2a7..bb27a8be36 100644 --- a/vector/src/main/java/im/vector/app/features/settings/ignored/UserItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/ignored/UserItem.kt @@ -21,8 +21,10 @@ import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick import im.vector.app.core.extensions.setTextOrHide import im.vector.app.features.home.AvatarRenderer import org.matrix.android.sdk.api.util.MatrixItem @@ -39,12 +41,12 @@ abstract class UserItem : VectorEpoxyModel() { @EpoxyAttribute lateinit var matrixItem: MatrixItem - @EpoxyAttribute - var itemClickAction: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var itemClickAction: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) - holder.root.setOnClickListener { itemClickAction?.invoke() } + holder.root.onClick(itemClickAction) avatarRenderer.render(matrixItem, holder.avatarImage) holder.userIdText.setTextOrHide(matrixItem.id) diff --git a/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginCenterButtonItem.kt b/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginCenterButtonItem.kt index a0e409ed02..f3e6378a4b 100644 --- a/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginCenterButtonItem.kt +++ b/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginCenterButtonItem.kt @@ -20,23 +20,23 @@ import android.widget.Button import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick import im.vector.app.core.extensions.setTextOrHide @EpoxyModelClass(layout = R.layout.item_login_centered_button) abstract class LoginCenterButtonItem : VectorEpoxyModel() { @EpoxyAttribute var text: String? = null - @EpoxyAttribute var listener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) holder.button.setTextOrHide(text) - holder.button.setOnClickListener { - listener?.invoke() - } + holder.button.onClick(listener) } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginErrorWithRetryItem.kt b/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginErrorWithRetryItem.kt index 47d4617271..834fedb272 100644 --- a/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginErrorWithRetryItem.kt +++ b/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginErrorWithRetryItem.kt @@ -21,8 +21,10 @@ import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass 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.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick @EpoxyModelClass(layout = R.layout.item_login_error_retry) abstract class LoginErrorWithRetryItem : VectorEpoxyModel() { @@ -30,13 +32,13 @@ abstract class LoginErrorWithRetryItem : VectorEpoxyModel Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var listener: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) holder.textView.text = text - holder.buttonView.setOnClickListener { listener?.invoke() } + holder.buttonView.onClick(listener) } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginPasswordFormItem.kt b/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginPasswordFormItem.kt index 872fa5391d..6028fe6912 100644 --- a/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginPasswordFormItem.kt +++ b/vector/src/main/java/im/vector/app/features/signout/soft/epoxy/LoginPasswordFormItem.kt @@ -25,9 +25,11 @@ import com.airbnb.epoxy.EpoxyModelClass import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputLayout 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.VectorEpoxyModel import im.vector.app.core.epoxy.addTextChangedListenerOnce +import im.vector.app.core.epoxy.onClick import im.vector.app.core.extensions.showPassword import im.vector.app.core.platform.SimpleTextWatcher import im.vector.app.core.resources.StringProvider @@ -40,8 +42,8 @@ abstract class LoginPasswordFormItem : VectorEpoxyModel Unit)? = null - @EpoxyAttribute var forgetPasswordClickListener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var passwordRevealClickListener: ClickListener? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var forgetPasswordClickListener: ClickListener? = null @EpoxyAttribute var submitClickListener: ((String) -> Unit)? = null @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var onPasswordEdited: ((String) -> Unit)? = null @@ -57,8 +59,8 @@ abstract class LoginPasswordFormItem : VectorEpoxyModel() { @EpoxyAttribute var text: String? = null - @EpoxyAttribute var listener: (() -> Unit)? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null override fun bind(holder: Holder) { super.bind(holder) holder.button.setTextOrHide(text) - holder.button.setOnClickListener { - listener?.invoke() - } + holder.button.onClick(listener) } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt index 434fa613ab..28c06d84d1 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt @@ -79,24 +79,16 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment { views.spaceCard.matrixToCardMainButton.render(ButtonStateView.State.Button) } - is Loading -> { + is Loading -> { views.spaceCard.matrixToCardMainButton.render(ButtonStateView.State.Loading) views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = false } - is Success -> { + is Success -> { interactionListener?.spaceInviteBottomSheetOnAccept(inviteArgs.spaceId) dismiss() } - is Fail -> { + is Fail -> { views.spaceCard.matrixToCardMainButton.render(ButtonStateView.State.Error) views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = true } @@ -162,15 +154,15 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment { views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Button) } - is Loading -> { + is Loading -> { views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Loading) views.spaceCard.matrixToCardMainButton.button.isEnabled = false } - is Success -> { + is Success -> { interactionListener?.spaceInviteBottomSheetOnDecline(inviteArgs.spaceId) dismiss() } - is Fail -> { + is Fail -> { views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Error) views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = true }