Use ClickListener and onClick extension wherever it's possible on Epoxy items

This commit is contained in:
Benoit Marty 2021-05-31 12:33:39 +02:00
parent 0c7b9f4690
commit 90634a9f9c
68 changed files with 245 additions and 281 deletions

View file

@ -19,10 +19,10 @@ package im.vector.app.core.epoxy
import android.view.View
/**
* Generally we do not care about the View parameter in [View.OnClickListener.onClick()], so create facility to remove it.
* View.OnClickListener lambda
*/
typealias ClickListener = () -> Unit
typealias ClickListener = (View) -> Unit
fun View.onClick(listener: ClickListener?) {
setOnClickListener { listener?.invoke() }
setOnClickListener { listener?.invoke(it) }
}

View file

@ -30,8 +30,10 @@ import androidx.core.widget.ImageViewCompat
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
/**
@ -70,13 +72,11 @@ abstract class BottomSheetActionItem : VectorEpoxyModel<BottomSheetActionItem.Ho
var destructive = false
@EpoxyAttribute
lateinit var listener: View.OnClickListener
lateinit var listener: ClickListener
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.setOnClickListener {
listener.onClick(it)
}
holder.view.onClick(listener)
holder.startSpace.isVisible = subMenuItem
val tintColor = if (destructive) {
ContextCompat.getColor(holder.view.context, R.color.riotx_notice)

View file

@ -16,7 +16,6 @@
*/
package im.vector.app.core.epoxy.bottomsheet
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.StringRes
@ -24,8 +23,10 @@ import androidx.core.content.ContextCompat
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
/**
@ -48,14 +49,11 @@ abstract class BottomSheetRadioActionItem : VectorEpoxyModel<BottomSheetRadioAct
var description: CharSequence? = null
@EpoxyAttribute
lateinit var listener: View.OnClickListener
lateinit var listener: ClickListener
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.setOnClickListener {
listener.onClick(it)
}
holder.view.onClick(listener)
if (titleRes != null) {
holder.titleText.setText(titleRes!!)
} else {

View file

@ -59,7 +59,7 @@ abstract class BottomSheetRoomPreviewItem : VectorEpoxyModel<BottomSheetRoomPrev
setLowPriorityState(holder, izLowPriority)
setFavoriteState(holder, izFavorite)
holder.roomLowPriority.setOnClickListener {
holder.roomLowPriority.onClick {
// Immediate echo
setLowPriorityState(holder, !izLowPriority)
if (!izLowPriority) {
@ -67,9 +67,9 @@ abstract class BottomSheetRoomPreviewItem : VectorEpoxyModel<BottomSheetRoomPrev
setFavoriteState(holder, false)
}
// And do the action
lowPriorityClickListener?.invoke()
lowPriorityClickListener?.invoke(it)
}
holder.roomFavorite.setOnClickListener {
holder.roomFavorite.onClick {
// Immediate echo
setFavoriteState(holder, !izFavorite)
if (!izFavorite) {
@ -77,7 +77,7 @@ abstract class BottomSheetRoomPreviewItem : VectorEpoxyModel<BottomSheetRoomPrev
setLowPriorityState(holder, false)
}
// And do the action
favoriteClickListener?.invoke()
favoriteClickListener?.invoke(it)
}
holder.roomSettings.apply {
onClick(settingsClickListener)

View file

@ -16,11 +16,12 @@
package im.vector.app.core.epoxy.profiles
import android.view.View
import androidx.annotation.CallSuper
import androidx.core.view.isVisible
import com.airbnb.epoxy.EpoxyAttribute
import im.vector.app.core.epoxy.ClickListener
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.crypto.RoomEncryptionTrustLevel
@ -33,7 +34,7 @@ abstract class BaseProfileMatrixItem<T : ProfileMatrixItem.Holder> : VectorEpoxy
@EpoxyAttribute
var userEncryptionTrustLevel: RoomEncryptionTrustLevel? = null
@EpoxyAttribute var clickListener: View.OnClickListener? = null
@EpoxyAttribute var clickListener: ClickListener? = null
@CallSuper
override fun bind(holder: T) {
@ -43,7 +44,7 @@ abstract class BaseProfileMatrixItem<T : ProfileMatrixItem.Holder> : VectorEpoxy
.takeIf { it != bestName }
// Special case for ThreePid fake matrix item
.takeIf { it != "@" }
holder.view.setOnClickListener(clickListener?.takeIf { editable })
holder.view.onClick(clickListener?.takeIf { editable })
holder.titleView.text = bestName
holder.subtitleView.setTextOrHide(matrixId)
holder.editableView.isVisible = editable

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.core.ui.bottomsheet
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
/**
@ -51,7 +50,7 @@ abstract class BottomSheetGenericController<State : BottomSheetGenericState, Act
val actions = getActions(state)
actions.forEach { action ->
action.toRadioBottomSheetItem()
.listener(View.OnClickListener { listener?.didSelectAction(action) })
.listener { listener?.didSelectAction(action) }
.addTo(this)
}
}

View file

@ -15,15 +15,16 @@
*/
package im.vector.app.core.ui.list
import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.google.android.material.button.MaterialButton
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
/**
@ -36,7 +37,7 @@ abstract class GenericButtonItem : VectorEpoxyModel<GenericButtonItem.Holder>()
var text: String? = null
@EpoxyAttribute
var buttonClickAction: View.OnClickListener? = null
var buttonClickAction: ClickListener? = null
@EpoxyAttribute
@ColorInt
@ -57,7 +58,7 @@ abstract class GenericButtonItem : VectorEpoxyModel<GenericButtonItem.Holder>()
holder.button.icon = null
}
buttonClickAction?.let { holder.button.setOnClickListener(it) }
holder.button.onClick(buttonClickAction)
}
class Holder : VectorEpoxyHolder() {

View file

@ -15,15 +15,16 @@
*/
package im.vector.app.core.ui.list
import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.google.android.material.button.MaterialButton
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
/**
* A generic button list item.
@ -35,7 +36,7 @@ abstract class GenericPositiveButtonItem : VectorEpoxyModel<GenericPositiveButto
var text: String? = null
@EpoxyAttribute
var buttonClickAction: View.OnClickListener? = null
var buttonClickAction: ClickListener? = null
@EpoxyAttribute
@ColorInt
@ -53,8 +54,7 @@ abstract class GenericPositiveButtonItem : VectorEpoxyModel<GenericPositiveButto
} else {
holder.button.icon = null
}
buttonClickAction?.let { holder.button.setOnClickListener(it) }
holder.button.onClick(buttonClickAction)
}
class Holder : VectorEpoxyHolder() {

View file

@ -59,8 +59,7 @@ class ReadReceiptsView @JvmOverloads constructor(
contentDescription = context.getString(R.string.a11y_view_read_receipts)
}
fun render(readReceipts: List<ReadReceiptData>, avatarRenderer: AvatarRenderer, clickListener: OnClickListener) {
setOnClickListener(clickListener)
fun render(readReceipts: List<ReadReceiptData>, avatarRenderer: AvatarRenderer) {
if (readReceipts.isNotEmpty()) {
isVisible = true
for (index in 0 until MAX_RECEIPT_DISPLAYED) {

View file

@ -16,14 +16,15 @@
package im.vector.app.features.autocomplete
import android.view.View
import android.widget.ImageView
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
@ -34,11 +35,11 @@ abstract class AutocompleteMatrixItem : VectorEpoxyModel<AutocompleteMatrixItem.
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
@EpoxyAttribute lateinit var matrixItem: MatrixItem
@EpoxyAttribute var subName: String? = null
@EpoxyAttribute var clickListener: View.OnClickListener? = null
@EpoxyAttribute var clickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.setOnClickListener(clickListener)
holder.view.onClick(clickListener)
holder.nameView.text = matrixItem.getBestName()
holder.subNameView.setTextOrHide(subName)
avatarRenderer.render(matrixItem, holder.avatarImageView)

View file

@ -37,9 +37,7 @@ class AutocompleteCommandController @Inject constructor(private val stringProvid
name(command.command)
parameters(command.parameters)
description(host.stringProvider.getString(command.description))
clickListener { _ ->
host.listener?.onItemClick(command)
}
clickListener { host.listener?.onItemClick(command) }
}
}
}

View file

@ -16,13 +16,14 @@
package im.vector.app.features.autocomplete.command
import android.view.View
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_autocomplete_command)
abstract class AutocompleteCommandItem : VectorEpoxyModel<AutocompleteCommandItem.Holder>() {
@ -37,12 +38,11 @@ abstract class AutocompleteCommandItem : VectorEpoxyModel<AutocompleteCommandIte
var description: CharSequence? = null
@EpoxyAttribute
var clickListener: View.OnClickListener? = null
var clickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.setOnClickListener(clickListener)
holder.view.onClick(clickListener)
holder.nameView.text = name
holder.parametersView.text = parameters
holder.descriptionView.text = description

View file

@ -40,9 +40,7 @@ class AutocompleteGroupController @Inject constructor() : TypedEpoxyController<L
id(groupSummary.groupId)
matrixItem(groupSummary.toMatrixItem())
avatarRenderer(host.avatarRenderer)
clickListener { _ ->
host.listener?.onItemClick(groupSummary)
}
clickListener { host.listener?.onItemClick(groupSummary) }
}
}
}

View file

@ -40,9 +40,7 @@ class AutocompleteMemberController @Inject constructor() : TypedEpoxyController<
id(user.userId)
matrixItem(user.toMatrixItem())
avatarRenderer(host.avatarRenderer)
clickListener { _ ->
host.listener?.onItemClick(user)
}
clickListener { host.listener?.onItemClick(user) }
}
}
}

View file

@ -39,9 +39,7 @@ class AutocompleteRoomController @Inject constructor(private val avatarRenderer:
matrixItem(roomSummary.toMatrixItem())
subName(roomSummary.canonicalAlias)
avatarRenderer(host.avatarRenderer)
clickListener { _ ->
host.listener?.onItemClick(roomSummary)
}
clickListener { host.listener?.onItemClick(roomSummary) }
}
}
}

View file

@ -95,35 +95,35 @@ class ContactsBookController @Inject constructor(
avatarRenderer(host.avatarRenderer)
}
mappedContact.emails
.forEachIndexed { index, it ->
if (onlyBoundContacts && it.matrixId == null) return@forEachIndexed
.forEachIndexed { index, email ->
if (onlyBoundContacts && email.matrixId == null) return@forEachIndexed
contactDetailItem {
id("${mappedContact.id}-e-$index-${it.email}")
threePid(it.email)
matrixId(it.matrixId)
id("${mappedContact.id}-e-$index-${email.email}")
threePid(email.email)
matrixId(email.matrixId)
clickListener {
if (it.matrixId != null) {
host.callback?.onMatrixIdClick(it.matrixId)
if (email.matrixId != null) {
host.callback?.onMatrixIdClick(email.matrixId)
} else {
host.callback?.onThreePidClick(ThreePid.Email(it.email))
host.callback?.onThreePidClick(ThreePid.Email(email.email))
}
}
}
}
mappedContact.msisdns
.forEachIndexed { index, it ->
if (onlyBoundContacts && it.matrixId == null) return@forEachIndexed
.forEachIndexed { index, msisdn ->
if (onlyBoundContacts && msisdn.matrixId == null) return@forEachIndexed
contactDetailItem {
id("${mappedContact.id}-m-$index-${it.phoneNumber}")
threePid(it.phoneNumber)
matrixId(it.matrixId)
id("${mappedContact.id}-m-$index-${msisdn.phoneNumber}")
threePid(msisdn.phoneNumber)
matrixId(msisdn.matrixId)
clickListener {
if (it.matrixId != null) {
host.callback?.onMatrixIdClick(it.matrixId)
if (msisdn.matrixId != null) {
host.callback?.onMatrixIdClick(msisdn.matrixId)
} else {
host.callback?.onThreePidClick(ThreePid.Msisdn(it.phoneNumber))
host.callback?.onThreePidClick(ThreePid.Msisdn(msisdn.phoneNumber))
}
}
}

View file

@ -16,14 +16,15 @@
package im.vector.app.features.crypto.keysbackup.settings
import android.view.View
import android.widget.Button
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
@EpoxyModelClass(layout = R.layout.item_keys_backup_settings_button_footer)
@ -33,21 +34,21 @@ abstract class KeysBackupSettingFooterItem : VectorEpoxyModel<KeysBackupSettingF
var textButton1: String? = null
@EpoxyAttribute
var clickOnButton1: View.OnClickListener? = null
var clickOnButton1: ClickListener? = null
@EpoxyAttribute
var textButton2: String? = null
@EpoxyAttribute
var clickOnButton2: View.OnClickListener? = null
var clickOnButton2: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.button1.setTextOrHide(textButton1)
holder.button1.setOnClickListener(clickOnButton1)
holder.button1.onClick(clickOnButton1)
holder.button2.setTextOrHide(textButton2)
holder.button2.setOnClickListener(clickOnButton2)
holder.button2.onClick(clickOnButton2)
}
class Holder : VectorEpoxyHolder() {

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.features.crypto.keysbackup.settings
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Fail
@ -166,13 +165,13 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor(
if (isBackupAlreadySetup) {
textButton1(host.stringProvider.getString(R.string.keys_backup_settings_restore_backup_button))
clickOnButton1(View.OnClickListener { host.listener?.didSelectRestoreMessageRecovery() })
clickOnButton1 { host.listener?.didSelectRestoreMessageRecovery() }
textButton2(host.stringProvider.getString(R.string.keys_backup_settings_delete_backup_button))
clickOnButton2(View.OnClickListener { host.listener?.didSelectDeleteSetupMessageRecovery() })
clickOnButton2 { host.listener?.didSelectDeleteSetupMessageRecovery() }
} else {
textButton1(host.stringProvider.getString(R.string.keys_backup_setup))
clickOnButton1(View.OnClickListener { host.listener?.didSelectSetupMessageRecovery() })
clickOnButton1 { host.listener?.didSelectSetupMessageRecovery() }
}
}
}

View file

@ -16,7 +16,6 @@
package im.vector.app.features.devtools
import android.view.View
import com.airbnb.epoxy.EpoxyController
import im.vector.app.R
import im.vector.app.core.resources.StringProvider
@ -38,23 +37,23 @@ class RoomDevToolRootController @Inject constructor(
genericButtonItem {
id("explore")
text(host.stringProvider.getString(R.string.dev_tools_explore_room_state))
buttonClickAction(View.OnClickListener {
buttonClickAction {
host.interactionListener?.processAction(RoomDevToolAction.ExploreRoomState)
})
}
}
genericButtonItem {
id("send")
text(host.stringProvider.getString(R.string.dev_tools_send_custom_event))
buttonClickAction(View.OnClickListener {
buttonClickAction {
host.interactionListener?.processAction(RoomDevToolAction.SendCustomEvent(false))
})
}
}
genericButtonItem {
id("send_state")
text(host.stringProvider.getString(R.string.dev_tools_send_state_event))
buttonClickAction(View.OnClickListener {
buttonClickAction {
host.interactionListener?.processAction(RoomDevToolAction.SendCustomEvent(true))
})
}
}
}
}

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.features.discovery
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Fail
@ -125,7 +124,7 @@ class DiscoverySettingsController @Inject constructor(
id("idServerFooter")
helperText(host.stringProvider.getString(R.string.settings_agree_to_terms, identityServer))
showCompoundDrawable(true)
itemClickListener(View.OnClickListener { host.listener?.openIdentityServerTerms() })
itemClickListener { host.listener?.openIdentityServerTerms() }
}
settingsButtonItem {
id("seeTerms")

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.features.discovery
import android.view.View
import android.widget.TextView
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
@ -23,7 +22,9 @@ import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.airbnb.epoxy.EpoxyModelWithHolder
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.setTextOrHide
@EpoxyModelClass(layout = R.layout.item_settings_helper_info)
@ -37,7 +38,7 @@ abstract class SettingsInfoItem : EpoxyModelWithHolder<SettingsInfoItem.Holder>(
var helperTextResId: Int? = null
@EpoxyAttribute
var itemClickListener: View.OnClickListener? = null
var itemClickListener: ClickListener? = null
@EpoxyAttribute
@DrawableRes
@ -55,7 +56,7 @@ abstract class SettingsInfoItem : EpoxyModelWithHolder<SettingsInfoItem.Holder>(
holder.text.setTextOrHide(helperText)
}
holder.view.setOnClickListener(itemClickListener)
holder.view.onClick(itemClickListener)
if (showCompoundDrawable) {
holder.text.setCompoundDrawablesWithIntrinsicBounds(compoundDrawable, 0, 0, 0)

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.features.discovery
import android.view.View
import android.widget.TextView
import androidx.annotation.StringRes
import androidx.core.view.isVisible
@ -24,7 +23,9 @@ import com.airbnb.epoxy.EpoxyModelClass
import com.airbnb.epoxy.EpoxyModelWithHolder
import com.google.android.material.switchmaterial.SwitchMaterial
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.setTextOrHide
@EpoxyModelClass(layout = R.layout.item_settings_simple_item)
@ -45,7 +46,7 @@ abstract class SettingsItem : EpoxyModelWithHolder<SettingsItem.Holder>() {
var description: CharSequence? = null
@EpoxyAttribute
var itemClickListener: View.OnClickListener? = null
var itemClickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -63,7 +64,7 @@ abstract class SettingsItem : EpoxyModelWithHolder<SettingsItem.Holder>() {
holder.switchButton.isVisible = false
holder.view.setOnClickListener(itemClickListener)
holder.view.onClick(itemClickListener)
}
class Holder : VectorEpoxyHolder() {

View file

@ -18,7 +18,6 @@ package im.vector.app.features.home.room.breadcrumbs
import com.airbnb.epoxy.EpoxyController
import im.vector.app.core.epoxy.zeroItem
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject
@ -53,21 +52,19 @@ class BreadcrumbsController @Inject constructor(
// An empty breadcrumbs list can only be temporary because when entering in a room,
// this one is added to the breadcrumbs
safeViewState.asyncBreadcrumbs.invoke()
?.forEach {
?.forEach { roomSummary ->
breadcrumbsItem {
id(it.roomId)
hasTypingUsers(it.typingUsers.isNotEmpty())
id(roomSummary.roomId)
hasTypingUsers(roomSummary.typingUsers.isNotEmpty())
avatarRenderer(host.avatarRenderer)
matrixItem(it.toMatrixItem())
unreadNotificationCount(it.notificationCount)
showHighlighted(it.highlightCount > 0)
hasUnreadMessage(it.hasUnreadMessages)
hasDraft(it.userDrafts.isNotEmpty())
itemClickListener(
DebouncedClickListener({ _ ->
host.listener?.onBreadcrumbClicked(it.roomId)
})
)
matrixItem(roomSummary.toMatrixItem())
unreadNotificationCount(roomSummary.notificationCount)
showHighlighted(roomSummary.highlightCount > 0)
hasUnreadMessage(roomSummary.hasUnreadMessages)
hasDraft(roomSummary.userDrafts.isNotEmpty())
itemClickListener {
host.listener?.onBreadcrumbClicked(roomSummary.roomId)
}
}
}
}

View file

@ -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.features.home.AvatarRenderer
import im.vector.app.features.home.room.list.UnreadCounterBadgeView
import org.matrix.android.sdk.api.util.MatrixItem
@ -39,11 +41,11 @@ abstract class BreadcrumbsItem : VectorEpoxyModel<BreadcrumbsItem.Holder>() {
@EpoxyAttribute var showHighlighted: Boolean = false
@EpoxyAttribute var hasUnreadMessage: Boolean = false
@EpoxyAttribute var hasDraft: Boolean = false
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.rootView.setOnClickListener(itemClickListener)
holder.rootView.onClick(itemClickListener)
holder.unreadIndentIndicator.isVisible = hasUnreadMessage
avatarRenderer.render(matrixItem, holder.avatarImageView)
holder.avatarImageView.contentDescription = matrixItem.getBestName()

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.features.home.room.detail.timeline.action
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import com.airbnb.mvrx.Success
import im.vector.app.EmojiCompatFontProvider
@ -107,7 +106,7 @@ class MessageActionsEpoxyController @Inject constructor(
}
when (state.informationData.e2eDecoration) {
E2EDecoration.WARN_IN_CLEAR -> {
E2EDecoration.WARN_IN_CLEAR -> {
bottomSheetSendStateItem {
id("e2e_clear")
showProgress(false)
@ -169,7 +168,7 @@ class MessageActionsEpoxyController @Inject constructor(
textRes(action.titleRes)
showExpand(action is EventSharedAction.ReportContent)
expanded(state.expendedReportContentMenu)
listener(View.OnClickListener { host.listener?.didSelectMenuAction(action) })
listener { host.listener?.didSelectMenuAction(action) }
destructive(action.destructive)
}
@ -185,7 +184,7 @@ class MessageActionsEpoxyController @Inject constructor(
subMenuItem(true)
iconRes(actionReport.iconResId)
textRes(actionReport.titleRes)
listener(View.OnClickListener { host.listener?.didSelectMenuAction(actionReport) })
listener { host.listener?.didSelectMenuAction(actionReport) }
}
}
}

View file

@ -29,7 +29,6 @@ import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.files.LocalFilesHelper
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.core.utils.containsOnlyEmojis
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
@ -322,10 +321,9 @@ class MessageItemFactory @Inject constructor(
if (messageContent.msgType == MessageType.MSGTYPE_STICKER_LOCAL) {
mode(ImageContentRenderer.Mode.STICKER)
} else {
clickListener(
DebouncedClickListener({ view ->
callback?.onImageMessageClicked(messageContent, data, view)
}))
clickListener { view ->
callback?.onImageMessageClicked(messageContent, data, view)
}
}
}
}

View file

@ -16,7 +16,6 @@
package im.vector.app.features.home.room.detail.timeline.factory
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import im.vector.app.features.home.room.detail.timeline.item.ReadReceiptData
@ -42,8 +41,8 @@ class ReadReceiptsItemFactory @Inject constructor(private val avatarRenderer: Av
.eventId(eventId)
.readReceipts(readReceiptsData)
.avatarRenderer(avatarRenderer)
.clickListener(DebouncedClickListener({ _ ->
.clickListener {
callback?.onReadReceiptsClicked(readReceiptsData)
}))
}
}
}

View file

@ -16,7 +16,6 @@
package im.vector.app.features.home.room.detail.timeline.helper
import im.vector.app.EmojiCompatFontProvider
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
@ -41,12 +40,12 @@ class MessageItemAttributesFactory @Inject constructor(
itemLongClickListener = { view ->
callback?.onEventLongClicked(informationData, messageContent, view) ?: false
},
itemClickListener = DebouncedClickListener({ view ->
itemClickListener = { view ->
callback?.onEventCellClicked(informationData, messageContent, view)
}),
memberClickListener = DebouncedClickListener({
},
memberClickListener = {
callback?.onMemberNameClicked(informationData)
}),
},
reactionPillCallback = callback,
avatarCallback = callback,
readReceiptsCallback = callback,

View file

@ -23,6 +23,8 @@ import android.widget.TextView
import androidx.annotation.IdRes
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.core.ui.views.ShieldImageView
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
@ -94,7 +96,7 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
}
}
holder.view.setOnClickListener(baseAttributes.itemClickListener)
holder.view.onClick(baseAttributes.itemClickListener)
holder.view.setOnLongClickListener(baseAttributes.itemLongClickListener)
}
@ -124,9 +126,9 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
val avatarRenderer: AvatarRenderer
val messageColorProvider: MessageColorProvider
val itemLongClickListener: View.OnLongClickListener?
val itemClickListener: View.OnClickListener?
val itemClickListener: ClickListener?
// val memberClickListener: View.OnClickListener?
// val memberClickListener: ClickListener?
val reactionPillCallback: TimelineEventController.ReactionPillCallback?
// val avatarCallback: TimelineEventController.AvatarCallback?
@ -139,7 +141,7 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
// override val avatarRenderer: AvatarRenderer,
// override val colorProvider: ColorProvider,
// override val itemLongClickListener: View.OnLongClickListener? = null,
// override val itemClickListener: View.OnClickListener? = null,
// override val itemClickListener: ClickListener? = null,
// override val reactionPillCallback: TimelineEventController.ReactionPillCallback? = null,
// override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null
// ) : Attributes

View file

@ -26,6 +26,7 @@ import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import com.airbnb.epoxy.EpoxyAttribute
import im.vector.app.R
import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.ui.views.SendStateImageView
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
@ -118,8 +119,8 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
override val avatarRenderer: AvatarRenderer,
override val messageColorProvider: MessageColorProvider,
override val itemLongClickListener: View.OnLongClickListener? = null,
override val itemClickListener: View.OnClickListener? = null,
val memberClickListener: View.OnClickListener? = null,
override val itemClickListener: ClickListener? = null,
val memberClickListener: ClickListener? = null,
override val reactionPillCallback: TimelineEventController.ReactionPillCallback? = null,
val avatarCallback: TimelineEventController.AvatarCallback? = null,
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null,

View file

@ -28,6 +28,7 @@ import androidx.core.view.updateLayoutParams
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.extensions.setLeftDrawable
import im.vector.app.core.extensions.setTextWithColoredPart
import im.vector.app.features.home.AvatarRenderer
@ -147,7 +148,7 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
override val avatarRenderer: AvatarRenderer,
override val messageColorProvider: MessageColorProvider,
override val itemLongClickListener: View.OnLongClickListener? = null,
override val itemClickListener: View.OnClickListener? = null,
override val itemClickListener: ClickListener? = null,
override val reactionPillCallback: TimelineEventController.ReactionPillCallback? = null,
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null
) : AbsBaseMessageItem.Attributes

View file

@ -20,6 +20,7 @@ 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.onClick
import im.vector.app.core.extensions.setTextOrHide
import me.saket.bettermovementmethod.BetterLinkMovementMethod
@ -36,7 +37,7 @@ abstract class MessageBlockCodeItem : AbsMessageItem<MessageBlockCodeItem.Holder
super.bind(holder)
holder.messageView.text = message
renderSendState(holder.messageView, holder.messageView)
holder.messageView.setOnClickListener(attributes.itemClickListener)
holder.messageView.onClick(attributes.itemClickListener)
holder.messageView.setOnLongClickListener(attributes.itemLongClickListener)
holder.editedView.movementMethod = BetterLinkMovementMethod.getInstance()
holder.editedView.setTextOrHide(editedSpan)

View file

@ -26,6 +26,7 @@ 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.onClick
import im.vector.app.features.home.room.detail.timeline.helper.ContentDownloadStateTrackerBinder
import im.vector.app.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder
@ -43,7 +44,7 @@ abstract class MessageFileItem : AbsMessageItem<MessageFileItem.Holder>() {
var iconRes: Int = 0
// @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
// var clickListener: View.OnClickListener? = null
// var clickListener: ClickListener? = null
@EpoxyAttribute
var izLocalFile = false
@ -81,9 +82,9 @@ abstract class MessageFileItem : AbsMessageItem<MessageFileItem.Holder>() {
}
// holder.view.setOnClickListener(clickListener)
holder.filenameView.setOnClickListener(attributes.itemClickListener)
holder.filenameView.onClick(attributes.itemClickListener)
holder.filenameView.setOnLongClickListener(attributes.itemLongClickListener)
holder.fileImageWrapper.setOnClickListener(attributes.itemClickListener)
holder.fileImageWrapper.onClick(attributes.itemClickListener)
holder.fileImageWrapper.setOnLongClickListener(attributes.itemLongClickListener)
holder.filenameView.paintFlags = (holder.filenameView.paintFlags or Paint.UNDERLINE_TEXT_FLAG)
}

View file

@ -24,6 +24,8 @@ 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.onClick
import im.vector.app.core.files.LocalFilesHelper
import im.vector.app.core.glide.GlideApp
import im.vector.app.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder
@ -42,7 +44,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
var mode = ImageContentRenderer.Mode.THUMBNAIL
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: View.OnClickListener? = null
var clickListener: ClickListener? = null
@EpoxyAttribute
lateinit var imageContentRenderer: ImageContentRenderer
@ -62,10 +64,10 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
} else {
holder.progressLayout.isVisible = false
}
holder.imageView.setOnClickListener(clickListener)
holder.imageView.onClick(clickListener)
holder.imageView.setOnLongClickListener(attributes.itemLongClickListener)
ViewCompat.setTransitionName(holder.imageView, "imagePreview_${id()}")
holder.mediaContentView.setOnClickListener(attributes.itemClickListener)
holder.mediaContentView.onClick(attributes.itemClickListener)
holder.mediaContentView.setOnLongClickListener(attributes.itemLongClickListener)
holder.playContentView.visibility = if (playable) View.VISIBLE else View.GONE
}

View file

@ -24,6 +24,7 @@ import androidx.core.widget.TextViewCompat
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.epoxy.onClick
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import im.vector.app.features.home.room.detail.timeline.tools.findPillsAndProcess
import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever
@ -95,7 +96,7 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
holder.messageView.movementMethod = movementMethod
renderSendState(holder.messageView, holder.messageView)
holder.messageView.setOnClickListener(attributes.itemClickListener)
holder.messageView.onClick(attributes.itemClickListener)
holder.messageView.setOnLongClickListener(attributes.itemLongClickListener)
if (canUseTextFuture) {

View file

@ -16,12 +16,13 @@
package im.vector.app.features.home.room.detail.timeline.item
import android.view.View
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.airbnb.epoxy.EpoxyModelWithHolder
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.ui.views.ReadReceiptsView
import im.vector.app.features.home.AvatarRenderer
@ -31,7 +32,7 @@ abstract class ReadReceiptsItem : EpoxyModelWithHolder<ReadReceiptsItem.Holder>(
@EpoxyAttribute lateinit var eventId: String
@EpoxyAttribute lateinit var readReceipts: List<ReadReceiptData>
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) lateinit var avatarRenderer: AvatarRenderer
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) lateinit var clickListener: View.OnClickListener
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) lateinit var clickListener: ClickListener
override fun canAppendReadMarker(): Boolean = false
@ -39,7 +40,8 @@ abstract class ReadReceiptsItem : EpoxyModelWithHolder<ReadReceiptsItem.Holder>(
override fun bind(holder: Holder) {
super.bind(holder)
holder.readReceiptsView.render(readReceipts, avatarRenderer, clickListener)
holder.readReceiptsView.onClick(clickListener)
holder.readReceiptsView.render(readReceipts, avatarRenderer)
}
override fun unbind(holder: Holder) {

View file

@ -26,6 +26,7 @@ import androidx.core.view.updateLayoutParams
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.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
@ -88,7 +89,7 @@ abstract class StatusTileTimelineItem : AbsBaseMessageItem<StatusTileTimelineIte
override val avatarRenderer: AvatarRenderer,
override val messageColorProvider: MessageColorProvider,
override val itemLongClickListener: View.OnLongClickListener? = null,
override val itemClickListener: View.OnClickListener? = null,
override val itemClickListener: ClickListener? = null,
override val reactionPillCallback: TimelineEventController.ReactionPillCallback? = null,
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null,
val emojiTypeFace: Typeface? = null

View file

@ -29,8 +29,9 @@ import androidx.core.view.updateLayoutParams
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.onClick
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.RoomDetailAction
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
@ -111,46 +112,25 @@ abstract class VerificationRequestItem : AbsBaseMessageItem<VerificationRequestI
holder.buttonBar.isVisible = false
}
holder.callback = callback
holder.attributes = attributes
holder.acceptButton.onClick {
callback?.onTimelineItemAction(RoomDetailAction.AcceptVerificationRequest(attributes.referenceId, attributes.otherUserId))
}
holder.declineButton.onClick {
callback?.onTimelineItemAction(RoomDetailAction.DeclineVerificationRequest(attributes.referenceId, attributes.otherUserId))
}
renderSendState(holder.view, null, holder.failedToSendIndicator)
}
override fun unbind(holder: Holder) {
super.unbind(holder)
holder.callback = null
holder.attributes = null
}
class Holder : AbsBaseMessageItem.Holder(STUB_ID) {
var callback: TimelineEventController.Callback? = null
var attributes: Attributes? = null
private val _clickListener = DebouncedClickListener(View.OnClickListener {
val att = attributes ?: return@OnClickListener
if (it == acceptButton) {
callback?.onTimelineItemAction(RoomDetailAction.AcceptVerificationRequest(att.referenceId, att.otherUserId))
} else if (it == declineButton) {
callback?.onTimelineItemAction(RoomDetailAction.DeclineVerificationRequest(att.referenceId, att.otherUserId))
}
})
val titleView by bind<AppCompatTextView>(R.id.itemVerificationTitleTextView)
val descriptionView by bind<AppCompatTextView>(R.id.itemVerificationDetailTextView)
val buttonBar by bind<ViewGroup>(R.id.itemVerificationButtonBar)
val statusTextView by bind<TextView>(R.id.itemVerificationStatusText)
val endGuideline by bind<View>(R.id.messageEndGuideline)
private val declineButton by bind<Button>(R.id.sas_verification_verified_decline_button)
private val acceptButton by bind<Button>(R.id.sas_verification_verified_accept_button)
val declineButton by bind<Button>(R.id.sas_verification_verified_decline_button)
val acceptButton by bind<Button>(R.id.sas_verification_verified_accept_button)
val failedToSendIndicator by bind<ImageView>(R.id.messageFailToSendIndicator)
override fun bindView(itemView: View) {
super.bindView(itemView)
acceptButton.setOnClickListener(_clickListener)
declineButton.setOnClickListener(_clickListener)
}
}
companion object {
@ -169,8 +149,8 @@ abstract class VerificationRequestItem : AbsBaseMessageItem<VerificationRequestI
override val avatarRenderer: AvatarRenderer,
override val messageColorProvider: MessageColorProvider,
override val itemLongClickListener: View.OnLongClickListener? = null,
override val itemClickListener: View.OnClickListener? = null,
// val memberClickListener: View.OnClickListener? = null,
override val itemClickListener: ClickListener? = null,
// val memberClickListener: ClickListener? = null,
override val reactionPillCallback: TimelineEventController.ReactionPillCallback? = null,
// val avatarCallback: TimelineEventController.AvatarCallback? = null,
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null,

View file

@ -27,6 +27,7 @@ import androidx.core.view.updateLayoutParams
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.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
@ -79,7 +80,7 @@ abstract class WidgetTileTimelineItem : AbsBaseMessageItem<WidgetTileTimelineIte
override val avatarRenderer: AvatarRenderer,
override val messageColorProvider: MessageColorProvider,
override val itemLongClickListener: View.OnLongClickListener? = null,
override val itemClickListener: View.OnClickListener? = null,
override val itemClickListener: ClickListener? = null,
override val reactionPillCallback: TimelineEventController.ReactionPillCallback? = null,
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null,
val emojiTypeFace: Typeface? = null

View file

@ -16,7 +16,6 @@
package im.vector.app.features.home.room.detail.widget
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import im.vector.app.R
import im.vector.app.core.resources.ColorProvider
@ -44,11 +43,11 @@ class RoomWidgetsController @Inject constructor(
text(host.stringProvider.getString(R.string.room_no_active_widgets))
}
} else {
widgets.forEach {
widgets.forEach { widget ->
roomWidgetItem {
id(it.widgetId)
widget(it)
widgetClicked { host.listener?.didSelectWidget(it) }
id(widget.widgetId)
widget(widget)
widgetClicked { host.listener?.didSelectWidget(widget) }
}
}
}
@ -56,7 +55,7 @@ class RoomWidgetsController @Inject constructor(
id("addIntegration")
text(host.stringProvider.getString(R.string.room_manage_integrations))
textColor(host.colorProvider.getColor(R.color.riotx_accent))
buttonClickAction(View.OnClickListener { host.listener?.didSelectManageWidgets() })
buttonClickAction { host.listener?.didSelectManageWidgets() }
}
}

View file

@ -28,8 +28,10 @@ import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.amulyakhare.textdrawable.TextDrawable
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.ui.views.ShieldImageView
import im.vector.app.features.home.AvatarRenderer
@ -57,12 +59,12 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
@EpoxyAttribute var showHighlighted: Boolean = false
@EpoxyAttribute var hasFailedSending: Boolean = false
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemLongClickListener: View.OnLongClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null
@EpoxyAttribute var showSelected: Boolean = false
override fun bind(holder: Holder) {
super.bind(holder)
holder.rootView.setOnClickListener(itemClickListener)
holder.rootView.onClick(itemClickListener)
holder.rootView.setOnLongClickListener {
it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
itemLongClickListener?.onLongClick(it) ?: false

View file

@ -23,7 +23,6 @@ import im.vector.app.core.date.DateFormatKind
import im.vector.app.core.date.VectorDateFormatter
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.format.DisplayableEventFormatter
import im.vector.app.features.home.room.typing.TypingHelper
@ -64,8 +63,8 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
.buttonLabel(stringProvider.getString(R.string.join))
.loading(suggestedRoomJoiningStates[spaceChildInfo.childRoomId] is Loading)
.memberCount(spaceChildInfo.activeMemberCount ?: 0)
.buttonClickListener(DebouncedClickListener({ listener?.onJoinSuggestedRoom(spaceChildInfo) }))
.itemClickListener(DebouncedClickListener({ listener?.onSuggestedRoomClicked(spaceChildInfo) }))
.buttonClickListener { listener?.onJoinSuggestedRoom(spaceChildInfo) }
.itemClickListener { listener?.onSuggestedRoomClicked(spaceChildInfo) }
}
private fun createInvitationItem(roomSummary: RoomSummary,
@ -127,10 +126,6 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
.itemLongClickListener { _ ->
onLongClick?.invoke(roomSummary) ?: false
}
.itemClickListener(
DebouncedClickListener({
onClick?.invoke(roomSummary)
})
)
.itemClickListener { onClick?.invoke(roomSummary) }
}
}

View file

@ -29,8 +29,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.features.home.AvatarRenderer
import im.vector.app.features.themes.ThemeUtils
import me.gujun.android.span.image
@ -52,12 +54,12 @@ abstract class SpaceChildInfoItem : VectorEpoxyModel<SpaceChildInfoItem.Holder>(
@EpoxyAttribute var buttonLabel: String? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemLongClickListener: View.OnLongClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var buttonClickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var buttonClickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.rootView.setOnClickListener(itemClickListener)
holder.rootView.onClick(itemClickListener)
holder.rootView.setOnLongClickListener {
it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
itemLongClickListener?.onLongClick(it) ?: false
@ -95,11 +97,12 @@ abstract class SpaceChildInfoItem : VectorEpoxyModel<SpaceChildInfoItem.Holder>(
holder.joinButton.isVisible = true
}
holder.joinButton.setOnClickListener {
holder.joinButton.onClick {
// local echo
holder.joinButton.isEnabled = false
// FIXME It may lead to crash if the view is gone
holder.view.postDelayed({ holder.joinButton.isEnabled = true }, 400)
buttonClickListener?.onClick(it)
buttonClickListener?.invoke(it)
}
}

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.features.home.room.list.actions
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import im.vector.app.core.epoxy.bottomsheet.bottomSheetActionItem
import im.vector.app.core.epoxy.bottomsheet.bottomSheetRoomPreviewItem
@ -87,7 +86,7 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
iconRes(iconResId)
textRes(titleRes)
destructive(this@toBottomSheetItem.destructive)
listener(View.OnClickListener { host.listener?.didSelectMenuAction(this@toBottomSheetItem) })
listener { host.listener?.didSelectMenuAction(this@toBottomSheetItem) }
}
}

View file

@ -16,7 +16,6 @@
package im.vector.app.features.login.terms
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import org.matrix.android.sdk.internal.auth.registration.LocalizedFlowDataLoginTerms
import javax.inject.Inject
@ -35,8 +34,7 @@ class PolicyController @Inject constructor() : TypedEpoxyController<List<Localiz
checked(entry.checked)
title(entry.localizedFlowDataLoginTerms.localizedName)
subtitle(host.homeServer)
clickListener(View.OnClickListener { host.listener?.openPolicy(entry.localizedFlowDataLoginTerms) })
clickListener { host.listener?.openPolicy(entry.localizedFlowDataLoginTerms) }
checkChangeListener { _, isChecked ->
host.listener?.setChecked(entry.localizedFlowDataLoginTerms, isChecked)
}

View file

@ -16,7 +16,6 @@
package im.vector.app.features.login.terms
import android.view.View
import android.widget.CheckBox
import android.widget.CompoundButton
import android.widget.TextView
@ -24,7 +23,9 @@ import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.airbnb.epoxy.EpoxyModelWithHolder
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
@EpoxyModelClass(layout = R.layout.item_policy)
abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
@ -41,7 +42,7 @@ abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: View.OnClickListener? = null
var clickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -50,7 +51,7 @@ abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
it.checkbox.setOnCheckedChangeListener(checkChangeListener)
it.title.text = title
it.subtitle.text = subtitle
it.view.setOnClickListener(clickListener)
it.view.onClick(clickListener)
}
}

View file

@ -18,7 +18,6 @@ package im.vector.app.features.roomdirectory.picker
import android.text.InputType
import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.TextView
import com.airbnb.epoxy.TypedEpoxyController
@ -156,9 +155,9 @@ class RoomDirectoryPickerController @Inject constructor(
id("add")
text(host.stringProvider.getString(R.string.directory_add_a_new_server))
textColor(host.colorProvider.getColor(R.color.riotx_accent))
buttonClickAction(View.OnClickListener {
buttonClickAction {
host.callback?.onStartEnterServer()
})
}
}
}
}

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.features.roomprofile.alias.detail
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import im.vector.app.core.epoxy.bottomsheet.bottomSheetActionItem
import im.vector.app.core.epoxy.dividerItem
@ -79,7 +78,7 @@ class RoomAliasBottomSheetController @Inject constructor() : TypedEpoxyControlle
iconRes(iconResId)
textRes(titleRes)
destructive(this@toBottomSheetItem.destructive)
listener(View.OnClickListener { host.listener?.didSelectMenuAction(this@toBottomSheetItem) })
listener { host.listener?.didSelectMenuAction(this@toBottomSheetItem) }
}
}

View file

@ -83,7 +83,7 @@ class RoomBannedMemberListController @Inject constructor(
} else {
inProgress(false)
editable(true)
clickListener { _ ->
clickListener {
host.callback?.onUnbanClicked(roomMember)
}
}

View file

@ -96,7 +96,7 @@ class RoomMemberListController @Inject constructor(
matrixItem(roomMember.toMatrixItem())
avatarRenderer(host.avatarRenderer)
userEncryptionTrustLevel(data.trustLevelMap.invoke()?.get(roomMember.userId))
clickListener { _ ->
clickListener {
host.callback?.onRoomMemberClicked(roomMember)
}
}
@ -143,7 +143,7 @@ class RoomMemberListController @Inject constructor(
matrixItem(MatrixItem.UserItem("@", displayName = content.displayName))
avatarRenderer(host.avatarRenderer)
editable(data.actionsPermissions.canRevokeThreePidInvite)
clickListener { _ ->
clickListener {
host.callback?.onThreePidInviteClicked(event)
}
}

View file

@ -23,7 +23,6 @@ import im.vector.app.core.ui.list.genericButtonItem
import im.vector.app.core.ui.list.genericItem
import im.vector.app.core.ui.list.genericItemWithValue
import im.vector.app.core.ui.list.genericPositiveButtonItem
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.core.utils.DimensionConverter
import me.gujun.android.span.span
import javax.inject.Inject
@ -53,9 +52,9 @@ class CrossSigningSettingsController @Inject constructor(
genericButtonItem {
id("Reset")
text(host.stringProvider.getString(R.string.reset_cross_signing))
buttonClickAction(DebouncedClickListener({
buttonClickAction {
host.interactionListener?.didTapInitializeCrossSigning()
}))
}
}
}
data.xSigningKeysAreTrusted -> {
@ -67,9 +66,9 @@ class CrossSigningSettingsController @Inject constructor(
genericButtonItem {
id("Reset")
text(host.stringProvider.getString(R.string.reset_cross_signing))
buttonClickAction(DebouncedClickListener({
buttonClickAction {
host.interactionListener?.didTapInitializeCrossSigning()
}))
}
}
}
data.xSigningIsEnableInAccount -> {
@ -81,9 +80,9 @@ class CrossSigningSettingsController @Inject constructor(
genericButtonItem {
id("Reset")
text(host.stringProvider.getString(R.string.reset_cross_signing))
buttonClickAction(DebouncedClickListener({
buttonClickAction {
host.interactionListener?.didTapInitializeCrossSigning()
}))
}
}
}
else -> {
@ -95,9 +94,9 @@ class CrossSigningSettingsController @Inject constructor(
genericPositiveButtonItem {
id("Initialize")
text(host.stringProvider.getString(R.string.initialize_cross_signing))
buttonClickAction(DebouncedClickListener({
buttonClickAction {
host.interactionListener?.didTapInitializeCrossSigning()
}))
}
}
}
}

View file

@ -35,8 +35,7 @@ abstract class LocaleItem : VectorEpoxyModel<LocaleItem.Holder>() {
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.onClick { clickListener?.invoke() }
holder.view.onClick(clickListener)
holder.titleView.setTextOrHide(title)
holder.subtitleView.setTextOrHide(subtitle)
}

View file

@ -74,14 +74,14 @@ class LocalePickerController @Inject constructor(
} else {
list()
.filter { it.toString() != data.currentLocale.toString() }
.forEach {
.forEach { locale ->
localeItem {
id(it.toString())
title(VectorLocale.localeToLocalisedString(it).safeCapitalize(it))
id(locale.toString())
title(VectorLocale.localeToLocalisedString(locale).safeCapitalize(locale))
if (host.vectorPreferences.developerMode()) {
subtitle(VectorLocale.localeToLocalisedStringInfo(it))
subtitle(VectorLocale.localeToLocalisedStringInfo(locale))
}
clickListener { host.listener?.onLocaleClicked(it) }
clickListener { host.listener?.onLocaleClicked(locale) }
}
}
}

View file

@ -52,7 +52,7 @@ abstract class ThreePidItem : EpoxyModelWithHolder<ThreePidItem.Holder>() {
}
holder.title.text = title
holder.delete.onClick { deleteClickListener?.invoke() }
holder.delete.onClick(deleteClickListener)
holder.delete.isVisible = deleteClickListener != null
}

View file

@ -17,7 +17,6 @@
package im.vector.app.features.settings.threepids
import android.text.InputType
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.Loading
@ -131,7 +130,7 @@ class ThreePidsSettingsController @Inject constructor(
id("addEmail")
text(host.stringProvider.getString(R.string.settings_add_email_address))
textColor(host.colorProvider.getColor(R.color.riotx_accent))
buttonClickAction(View.OnClickListener { host.interactionListener?.addEmail() })
buttonClickAction { host.interactionListener?.addEmail() }
}
is ThreePidsSettingsUiState.AddingEmail -> {
settingsEditTextItem {
@ -190,7 +189,7 @@ class ThreePidsSettingsController @Inject constructor(
id("addMsisdn")
text(host.stringProvider.getString(R.string.settings_add_phone_number))
textColor(host.colorProvider.getColor(R.color.riotx_accent))
buttonClickAction(View.OnClickListener { host.interactionListener?.addMsisdn() })
buttonClickAction { host.interactionListener?.addMsisdn() }
}
is ThreePidsSettingsUiState.AddingEmail -> Unit
is ThreePidsSettingsUiState.AddingPhoneNumber -> {

View file

@ -20,21 +20,20 @@ import android.view.View
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.utils.DebouncedClickListener
import im.vector.app.core.epoxy.onClick
@EpoxyModelClass(layout = R.layout.item_space_beta_header)
abstract class SpaceBetaHeaderItem : VectorEpoxyModel<SpaceBetaHeaderItem.Holder>() {
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickAction: View.OnClickListener? = null
var clickAction: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.feedBackAction.setOnClickListener(DebouncedClickListener({
clickAction?.onClick(it)
}))
holder.feedBackAction.onClick(clickAction)
}
class Holder : VectorEpoxyHolder() {

View file

@ -16,7 +16,6 @@
package im.vector.app.features.spaces
import android.view.View
import com.airbnb.epoxy.EpoxyController
import im.vector.app.R
import im.vector.app.RoomGroupingMethod
@ -112,9 +111,9 @@ class SpaceSummaryController @Inject constructor(
val host = this
spaceBetaHeaderItem {
id("beta_header")
clickAction(View.OnClickListener {
clickAction {
host.callback?.sendFeedBack()
})
}
}
// show invites on top

View file

@ -16,7 +16,6 @@
package im.vector.app.features.spaces.explore
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.Incomplete
@ -138,12 +137,12 @@ class SpaceDirectoryController @Inject constructor(
)
apply {
if (isSpace) {
itemClickListener(View.OnClickListener { host.listener?.onSpaceChildClick(info) })
itemClickListener { host.listener?.onSpaceChildClick(info) }
} else {
itemClickListener(View.OnClickListener { host.listener?.onRoomClick(info) })
itemClickListener { host.listener?.onRoomClick(info) }
}
}
buttonClickListener(View.OnClickListener { host.listener?.onButtonClick(info) })
buttonClickListener { host.listener?.onButtonClick(info) }
}
}
}

View file

@ -21,7 +21,6 @@ import com.airbnb.epoxy.EpoxyModel
import com.airbnb.epoxy.paging.PagedListEpoxyController
import im.vector.app.R
import im.vector.app.core.ui.list.GenericPillItem_
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.core.utils.createUIHandler
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.list.RoomCategoryItem_
@ -155,9 +154,9 @@ class AddRoomListController @Inject constructor(
matrixItem(item.toMatrixItem())
avatarRenderer(host.avatarRenderer)
selected(host.selectedItems[item.roomId] ?: false)
itemClickListener(DebouncedClickListener({
itemClickListener {
host.listener?.onItemSelected(item)
}))
}
}
}
}

View file

@ -16,7 +16,6 @@
package im.vector.app.features.spaces.manage
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
@ -24,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.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
@ -36,7 +37,7 @@ abstract class RoomManageSelectionItem : VectorEpoxyModel<RoomManageSelectionIte
@EpoxyAttribute lateinit var matrixItem: MatrixItem
@EpoxyAttribute var selected: Boolean = false
@EpoxyAttribute var suggested: Boolean = false
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -54,9 +55,7 @@ abstract class RoomManageSelectionItem : VectorEpoxyModel<RoomManageSelectionIte
holder.suggestedText.isVisible = suggested
holder.view.setOnClickListener {
itemClickListener?.onClick(it)
}
holder.view.onClick(itemClickListener)
}
class Holder : VectorEpoxyHolder() {

View file

@ -16,15 +16,16 @@
package im.vector.app.features.spaces.manage
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
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
@ -34,7 +35,7 @@ abstract class RoomSelectionItem : VectorEpoxyModel<RoomSelectionItem.Holder>()
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
@EpoxyAttribute lateinit var matrixItem: MatrixItem
@EpoxyAttribute var selected: Boolean = false
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -50,9 +51,7 @@ abstract class RoomSelectionItem : VectorEpoxyModel<RoomSelectionItem.Holder>()
holder.checkboxImage.contentDescription = holder.view.context.getString(R.string.a11y_unchecked)
}
holder.view.setOnClickListener {
itemClickListener?.onClick(it)
}
holder.view.onClick(itemClickListener)
}
class Holder : VectorEpoxyHolder() {

View file

@ -25,7 +25,6 @@ import im.vector.app.core.epoxy.loadingItem
import im.vector.app.core.error.ErrorFormatter
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.ui.list.genericFooterItem
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
import org.matrix.android.sdk.api.util.toMatrixItem
@ -83,9 +82,9 @@ class SpaceManageRoomsController @Inject constructor(
avatarRenderer(host.avatarRenderer)
suggested(childInfo.suggested ?: false)
selected(data.selectedRooms.contains(childInfo.childRoomId))
itemClickListener(DebouncedClickListener({
itemClickListener {
host.listener?.toggleSelection(childInfo)
}))
}
}
}
}

View file

@ -115,7 +115,7 @@ class SpacePeopleListController @Inject constructor(
}
}
clickListener { _ ->
clickListener {
host.listener?.onSpaceMemberClicked(roomMember)
}
}

View file

@ -16,7 +16,6 @@
package im.vector.app.features.terms
import android.view.View
import android.widget.CheckBox
import android.widget.CompoundButton
import android.widget.TextView
@ -24,7 +23,9 @@ import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.airbnb.epoxy.EpoxyModelWithHolder
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
@EpoxyModelClass(layout = R.layout.item_tos)
abstract class TermItem : EpoxyModelWithHolder<TermItem.Holder>() {
@ -42,7 +43,7 @@ abstract class TermItem : EpoxyModelWithHolder<TermItem.Holder>() {
var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: View.OnClickListener? = null
var clickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -50,7 +51,7 @@ abstract class TermItem : EpoxyModelWithHolder<TermItem.Holder>() {
holder.title.text = name
holder.description.text = description
holder.checkbox.setOnCheckedChangeListener(checkChangeListener)
holder.view.setOnClickListener(clickListener)
holder.view.onClick(clickListener)
}
class Holder : VectorEpoxyHolder() {

View file

@ -15,7 +15,6 @@
*/
package im.vector.app.features.terms
import android.view.View
import com.airbnb.epoxy.TypedEpoxyController
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.Incomplete
@ -68,7 +67,7 @@ class TermsController @Inject constructor(
description(host.description)
checked(term.accepted)
clickListener(View.OnClickListener { host.listener?.review(term) })
clickListener { host.listener?.review(term) }
checkChangeListener { _, isChecked ->
host.listener?.setChecked(term, isChecked)
}

View file

@ -16,28 +16,28 @@
package im.vector.app.features.userdirectory
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.DrawableRes
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.utils.DebouncedClickListener
@EpoxyModelClass(layout = R.layout.item_contact_action)
abstract class ActionItem : VectorEpoxyModel<ActionItem.Holder>() {
@EpoxyAttribute var title: CharSequence? = null
@EpoxyAttribute @DrawableRes var actionIconRes: Int? = null
@EpoxyAttribute var clickAction: View.OnClickListener? = null
@EpoxyAttribute var clickAction: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.setOnClickListener(clickAction?.let { DebouncedClickListener(it) })
holder.view.onClick(clickAction)
// If name is empty, use userId as name and force it being centered
holder.actionTitleText.setTextOrHide(title)
if (actionIconRes != null) {

View file

@ -24,8 +24,10 @@ import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.amulyakhare.textdrawable.TextDrawable
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
@ -34,12 +36,12 @@ abstract class UserDirectoryUserItem : VectorEpoxyModel<UserDirectoryUserItem.Ho
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
@EpoxyAttribute lateinit var matrixItem: MatrixItem
@EpoxyAttribute var clickListener: View.OnClickListener? = null
@EpoxyAttribute var clickListener: ClickListener? = null
@EpoxyAttribute var selected: Boolean = false
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.setOnClickListener(clickListener)
holder.view.onClick(clickListener)
// If name is empty, use userId as name and force it being centered
if (matrixItem.displayName.isNullOrEmpty()) {
holder.userIdView.visibility = View.GONE

View file

@ -16,7 +16,6 @@
package im.vector.app.features.userdirectory
import android.view.View
import com.airbnb.epoxy.EpoxyController
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.Loading
@ -60,9 +59,9 @@ class UserListController @Inject constructor(private val session: Session,
id(R.drawable.ic_share)
title(host.stringProvider.getString(R.string.invite_friends))
actionIconRes(R.drawable.ic_share)
clickAction(View.OnClickListener {
clickAction {
host.callback?.onInviteFriendClick()
})
}
}
}
if (currentState.showContactBookAction) {
@ -70,9 +69,9 @@ class UserListController @Inject constructor(private val session: Session,
id(R.drawable.ic_baseline_perm_contact_calendar_24)
title(host.stringProvider.getString(R.string.contacts_book_title))
actionIconRes(R.drawable.ic_baseline_perm_contact_calendar_24)
clickAction(View.OnClickListener {
clickAction {
host.callback?.onContactBookClick()
})
}
}
}
if (currentState.showInviteActions()) {
@ -80,9 +79,9 @@ class UserListController @Inject constructor(private val session: Session,
id(R.drawable.ic_qr_code_add)
title(host.stringProvider.getString(R.string.qr_code))
actionIconRes(R.drawable.ic_qr_code_add)
clickAction(View.OnClickListener {
clickAction {
host.callback?.onUseQRCode()
})
}
}
}
}
@ -130,7 +129,7 @@ class UserListController @Inject constructor(private val session: Session,
selected(isSelected)
matrixItem(item.toMatrixItem())
avatarRenderer(host.avatarRenderer)
clickListener { _ ->
clickListener {
host.callback?.onItemClick(item)
}
}
@ -160,7 +159,7 @@ class UserListController @Inject constructor(private val session: Session,
selected(isSelected)
matrixItem(user.toMatrixItem())
avatarRenderer(host.avatarRenderer)
clickListener { _ ->
clickListener {
host.callback?.onItemClick(user)
}
}