Merge pull request #3435 from vector-im/feature/bma/debounced_click

Debounced click
This commit is contained in:
Benoit Marty 2021-06-08 19:12:03 +02:00 committed by GitHub
commit d4f48da7f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
152 changed files with 718 additions and 804 deletions

View File

@ -0,0 +1 @@
Cleanup Epoxy items, and debounce all the clicks

View File

@ -29,14 +29,14 @@ abstract class ErrorWithRetryItem : VectorEpoxyModel<ErrorWithRetryItem.Holder>(
@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.textView.text = text
holder.buttonView.isVisible = listener != null
holder.buttonView.setOnClickListener { listener?.invoke() }
holder.buttonView.onClick(listener)
}
class Holder : VectorEpoxyHolder() {

View File

@ -17,12 +17,22 @@
package im.vector.app.core.epoxy
import android.view.View
import im.vector.app.core.utils.DebouncedClickListener
/**
* 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() }
if (listener == null) {
setOnClickListener(null)
} else {
setOnClickListener(DebouncedClickListener(listener))
}
}
/**
* Simple Text listener lambda
*/
typealias TextListener = (String) -> Unit

View File

@ -16,7 +16,9 @@
package im.vector.app.core.epoxy
import android.text.TextWatcher
import android.widget.CompoundButton
import android.widget.TextView
import com.google.android.material.switchmaterial.SwitchMaterial
import com.google.android.material.textfield.TextInputEditText
@ -39,3 +41,9 @@ fun VectorEpoxyHolder.setValueOnce(switchView: SwitchMaterial, switchChecked: Bo
switchView.setOnCheckedChangeListener(listener)
}
}
fun TextView.addTextChangedListenerOnce(textWatcher: TextWatcher) {
// Ensure the watcher is not added multiple times
removeTextChangedListener(textWatcher)
addTextChangedListener(textWatcher)
}

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
/**
@ -69,14 +71,12 @@ abstract class BottomSheetActionItem : VectorEpoxyModel<BottomSheetActionItem.Ho
@EpoxyAttribute
var destructive = false
@EpoxyAttribute
lateinit var listener: View.OnClickListener
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
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

@ -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.extensions.setTextOrHide
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.tools.findPillsAndProcess
@ -61,14 +63,14 @@ abstract class BottomSheetMessagePreviewItem : VectorEpoxyModel<BottomSheetMessa
@EpoxyAttribute
var movementMethod: MovementMethod? = null
@EpoxyAttribute
var userClicked: (() -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var userClicked: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
avatarRenderer.render(matrixItem, holder.avatar)
holder.avatar.setOnClickListener { userClicked?.invoke() }
holder.sender.setOnClickListener { userClicked?.invoke() }
holder.avatar.onClick(userClicked)
holder.sender.onClick(userClicked)
holder.sender.setTextOrHide(matrixItem.displayName)
data?.let {
imageContentRenderer?.render(it, ImageContentRenderer.Mode.THUMBNAIL, holder.imagePreview)

View File

@ -24,6 +24,7 @@ import im.vector.app.EmojiCompatFontProvider
import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.epoxy.onClick
/**
* A quick reaction list for bottom sheet.
@ -50,7 +51,7 @@ abstract class BottomSheetQuickReactionsItem : VectorEpoxyModel<BottomSheetQuick
textView.text = texts[index]
textView.alpha = if (selecteds[index]) 0.2f else 1f
textView.setOnClickListener {
textView.onClick {
listener?.didSelect(texts[index], !selecteds[index])
}
}

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
/**
@ -47,15 +48,12 @@ abstract class BottomSheetRadioActionItem : VectorEpoxyModel<BottomSheetRadioAct
@EpoxyAttribute
var description: CharSequence? = null
@EpoxyAttribute
lateinit var listener: View.OnClickListener
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
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

@ -47,9 +47,9 @@ abstract class BottomSheetRoomPreviewItem : VectorEpoxyModel<BottomSheetRoomPrev
@EpoxyAttribute lateinit var stringProvider: StringProvider
@EpoxyAttribute var izLowPriority: Boolean = false
@EpoxyAttribute var izFavorite: Boolean = false
@EpoxyAttribute var settingsClickListener: ClickListener? = null
@EpoxyAttribute var lowPriorityClickListener: ClickListener? = null
@EpoxyAttribute var favoriteClickListener: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var settingsClickListener: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var lowPriorityClickListener: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var favoriteClickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -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,9 @@ abstract class BaseProfileMatrixItem<T : ProfileMatrixItem.Holder> : VectorEpoxy
@EpoxyAttribute
var userEncryptionTrustLevel: RoomEncryptionTrustLevel? = null
@EpoxyAttribute var clickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: ClickListener? = null
@CallSuper
override fun bind(holder: T) {
@ -43,7 +46,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

@ -67,7 +67,7 @@ abstract class ProfileActionItem : VectorEpoxyModel<ProfileActionItem.Holder>()
@EpoxyAttribute
var destructive: Boolean = false
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var listener: ClickListener? = null
override fun bind(holder: Holder) {

View File

@ -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)
}
}

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

@ -0,0 +1,24 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.core.ui.list
import im.vector.app.core.epoxy.ClickListener
data class Action(
val title: String,
val listener: ClickListener
)

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
/**
@ -35,8 +36,8 @@ abstract class GenericButtonItem : VectorEpoxyModel<GenericButtonItem.Holder>()
@EpoxyAttribute
var text: String? = null
@EpoxyAttribute
var buttonClickAction: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
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

@ -29,6 +29,7 @@ import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
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
/**
@ -37,10 +38,6 @@ import im.vector.app.core.extensions.setTextOrHide
@EpoxyModelClass(layout = R.layout.item_generic_empty_state)
abstract class GenericEmptyWithActionItem : VectorEpoxyModel<GenericEmptyWithActionItem.Holder>() {
class Action(var title: String) {
var perform: Runnable? = null
}
@EpoxyAttribute
var title: CharSequence? = null
@ -77,9 +74,7 @@ abstract class GenericEmptyWithActionItem : VectorEpoxyModel<GenericEmptyWithAct
}
holder.actionButton.setTextOrHide(buttonAction?.title)
holder.actionButton.setOnClickListener {
buttonAction?.perform?.run()
}
holder.actionButton.onClick(buttonAction?.listener)
}
class Holder : VectorEpoxyHolder() {

View File

@ -21,8 +21,10 @@ import androidx.annotation.ColorInt
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.themes.ThemeUtils
@ -41,8 +43,8 @@ abstract class GenericFooterItem : VectorEpoxyModel<GenericFooterItem.Holder>()
@EpoxyAttribute
var style: ItemStyle = ItemStyle.NORMAL_TEXT
@EpoxyAttribute
var itemClickAction: GenericItem.Action? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var itemClickAction: ClickListener? = null
@EpoxyAttribute
var centered: Boolean = true
@ -65,9 +67,7 @@ abstract class GenericFooterItem : VectorEpoxyModel<GenericFooterItem.Holder>()
holder.text.setTextColor(ThemeUtils.getColor(holder.view.context, R.attr.riotx_text_secondary))
}
holder.view.setOnClickListener {
itemClickAction?.perform?.run()
}
holder.view.onClick(itemClickAction)
}
class Holder : VectorEpoxyHolder() {

View File

@ -29,7 +29,7 @@ import im.vector.app.features.themes.ThemeUtils
* A generic list item header left aligned with notice color.
*/
@EpoxyModelClass(layout = R.layout.item_generic_header)
abstract class GenericItemHeader : VectorEpoxyModel<GenericItemHeader.Holder>() {
abstract class GenericHeaderItem : VectorEpoxyModel<GenericHeaderItem.Holder>() {
@EpoxyAttribute
var text: String? = null

View File

@ -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
/**
@ -38,10 +40,6 @@ import im.vector.app.core.extensions.setTextOrHide
@EpoxyModelClass(layout = R.layout.item_generic_list)
abstract class GenericItem : VectorEpoxyModel<GenericItem.Holder>() {
class Action(var title: String) {
var perform: Runnable? = null
}
@EpoxyAttribute
var title: CharSequence? = null
@ -68,8 +66,8 @@ abstract class GenericItem : VectorEpoxyModel<GenericItem.Holder>() {
@EpoxyAttribute
var destructiveButtonAction: Action? = null
@EpoxyAttribute
var itemClickAction: Action? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var itemClickAction: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -100,18 +98,12 @@ abstract class GenericItem : VectorEpoxyModel<GenericItem.Holder>() {
}
holder.actionButton.setTextOrHide(buttonAction?.title)
holder.actionButton.setOnClickListener {
buttonAction?.perform?.run()
}
holder.actionButton.onClick(buttonAction?.listener)
holder.destructiveButton.setTextOrHide(destructiveButtonAction?.title)
holder.destructiveButton.setOnClickListener {
destructiveButtonAction?.perform?.run()
}
holder.destructiveButton.onClick(destructiveButtonAction?.listener)
holder.root.setOnClickListener {
itemClickAction?.perform?.run()
}
holder.root.onClick(itemClickAction)
}
class Holder : VectorEpoxyHolder() {

View File

@ -25,8 +25,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.core.extensions.setTextOrHide
import im.vector.app.features.themes.ThemeUtils
@ -42,8 +44,8 @@ abstract class GenericPillItem : VectorEpoxyModel<GenericPillItem.Holder>() {
@EpoxyAttribute
var style: ItemStyle = ItemStyle.NORMAL_TEXT
@EpoxyAttribute
var itemClickAction: GenericItem.Action? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var itemClickAction: ClickListener? = null
@EpoxyAttribute
var centered: Boolean = false
@ -76,9 +78,7 @@ abstract class GenericPillItem : VectorEpoxyModel<GenericPillItem.Holder>() {
ImageViewCompat.setImageTintList(holder.imageView, null)
}
holder.view.setOnClickListener {
itemClickAction?.perform?.run()
}
holder.view.onClick(itemClickAction)
}
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.
@ -34,8 +35,8 @@ abstract class GenericPositiveButtonItem : VectorEpoxyModel<GenericPositiveButto
@EpoxyAttribute
var text: String? = null
@EpoxyAttribute
var buttonClickAction: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
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

@ -24,10 +24,11 @@ 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.utils.DebouncedClickListener
import im.vector.app.features.themes.ThemeUtils
/**
@ -37,7 +38,7 @@ import im.vector.app.features.themes.ThemeUtils
* If provided with an action, will display a button at the bottom of the list item.
*/
@EpoxyModelClass(layout = R.layout.item_generic_with_value)
abstract class GenericItemWithValue : VectorEpoxyModel<GenericItemWithValue.Holder>() {
abstract class GenericWithValueItem : VectorEpoxyModel<GenericWithValueItem.Holder>() {
@EpoxyAttribute
var title: CharSequence? = null
@ -53,10 +54,10 @@ abstract class GenericItemWithValue : VectorEpoxyModel<GenericItemWithValue.Hold
@DrawableRes
var titleIconResourceId: Int = -1
@EpoxyAttribute
var itemClickAction: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var itemClickAction: ClickListener? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var itemLongClickAction: View.OnLongClickListener? = null
override fun bind(holder: Holder) {
@ -78,7 +79,7 @@ abstract class GenericItemWithValue : VectorEpoxyModel<GenericItemWithValue.Hold
holder.valueText.setTextColor(ThemeUtils.getColor(holder.view.context, R.attr.riotx_text_primary))
}
holder.view.setOnClickListener(itemClickAction?.let { DebouncedClickListener(it) })
holder.view.onClick(itemClickAction)
holder.view.setOnLongClickListener(itemLongClickAction)
}

View File

@ -18,10 +18,10 @@ package im.vector.app.core.ui.views
import androidx.cardview.widget.CardView
import androidx.core.view.isVisible
import im.vector.app.core.utils.DebouncedClickListener
import org.matrix.android.sdk.api.session.call.CallState
import im.vector.app.core.epoxy.onClick
import im.vector.app.features.call.utils.EglUtils
import im.vector.app.features.call.webrtc.WebRtcCall
import org.matrix.android.sdk.api.session.call.CallState
import org.webrtc.RendererCommon
import org.webrtc.SurfaceViewRenderer
@ -88,11 +88,9 @@ class KnownCallsViewHolder {
this.currentCallsView = activeCallView
this.pipWrapper = pipWrapper
this.currentCallsView?.callback = interactionListener
pipWrapper.setOnClickListener(
DebouncedClickListener({
interactionListener.onTapToReturnToCall()
})
)
pipWrapper.onClick {
interactionListener.onTapToReturnToCall()
}
this.currentCall?.addListener(tickListener)
}

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

@ -15,24 +15,30 @@
*/
package im.vector.app.core.utils
import android.os.SystemClock
import android.view.View
import timber.log.Timber
import java.util.WeakHashMap
/**
* Simple Debounced OnClickListener
* Safe to use in different views
*/
class DebouncedClickListener(val original: View.OnClickListener, private val minimumInterval: Long = 400) : View.OnClickListener {
class DebouncedClickListener(
val original: View.OnClickListener,
private val minimumInterval: Long = 400
) : View.OnClickListener {
private val lastClickMap = WeakHashMap<View, Long>()
override fun onClick(clickedView: View) {
val previousClickTimestamp = lastClickMap[clickedView]
val currentTimestamp = System.currentTimeMillis()
override fun onClick(v: View) {
val previousClickTimestamp = lastClickMap[v] ?: 0
val currentTimestamp = SystemClock.elapsedRealtime()
lastClickMap[v] = currentTimestamp
lastClickMap[clickedView] = currentTimestamp
if (previousClickTimestamp == null || currentTimestamp - previousClickTimestamp.toLong() > minimumInterval) {
original.onClick(clickedView)
if (currentTimestamp > previousClickTimestamp + minimumInterval) {
original.onClick(v)
} else {
Timber.v("Debounced click!")
}
}
}

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(EpoxyAttribute.Option.DoNotHash) 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>() {
@ -36,13 +37,12 @@ abstract class AutocompleteCommandItem : VectorEpoxyModel<AutocompleteCommandIte
@EpoxyAttribute
var description: CharSequence? = null
@EpoxyAttribute
var clickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
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

@ -21,7 +21,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.airbnb.epoxy.TypedEpoxyController
import im.vector.app.EmojiCompatFontProvider
import im.vector.app.features.autocomplete.AutocompleteClickListener
import im.vector.app.features.reactions.ReactionClickListener
import im.vector.app.features.reactions.data.EmojiItem
import javax.inject.Inject
@ -51,13 +50,7 @@ class AutocompleteEmojiController @Inject constructor(
id(emojiItem.name)
emojiItem(emojiItem)
emojiTypeFace(host.emojiTypeface)
onClickListener(
object : ReactionClickListener {
override fun onReactionSelected(reaction: String) {
host.listener?.onItemClick(reaction)
}
}
)
onClickListener { host.listener?.onItemClick(emojiItem.emoji) }
}
}

View File

@ -21,10 +21,11 @@ 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.reactions.ReactionClickListener
import im.vector.app.features.reactions.data.EmojiItem
@EpoxyModelClass(layout = R.layout.item_autocomplete_emoji)
@ -36,8 +37,8 @@ abstract class AutocompleteEmojiItem : VectorEpoxyModel<AutocompleteEmojiItem.Ho
@EpoxyAttribute
var emojiTypeFace: Typeface? = null
@EpoxyAttribute
var onClickListener: ReactionClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onClickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -45,10 +46,7 @@ abstract class AutocompleteEmojiItem : VectorEpoxyModel<AutocompleteEmojiItem.Ho
holder.emojiText.typeface = emojiTypeFace ?: Typeface.DEFAULT
holder.emojiNameText.text = emojiItem.name
holder.emojiKeywordText.setTextOrHide(emojiItem.keywords.joinToString())
holder.view.setOnClickListener {
onClickListener?.onReactionSelected(emojiItem.emoji)
}
holder.view.onClick(onClickListener)
}
class Holder : VectorEpoxyHolder() {

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

@ -31,7 +31,9 @@ abstract class ContactDetailItem : VectorEpoxyModel<ContactDetailItem.Holder>()
@EpoxyAttribute lateinit var threePid: String
@EpoxyAttribute var matrixId: String? = null
@EpoxyAttribute var clickListener: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)

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)
@ -32,22 +33,22 @@ abstract class KeysBackupSettingFooterItem : VectorEpoxyModel<KeysBackupSettingF
@EpoxyAttribute
var textButton1: String? = null
@EpoxyAttribute
var clickOnButton1: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickOnButton1: ClickListener? = null
@EpoxyAttribute
var textButton2: String? = null
@EpoxyAttribute
var clickOnButton2: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
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

@ -25,8 +25,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.core.extensions.setTextOrHide
/**
@ -51,15 +53,12 @@ abstract class BottomSheetVerificationActionItem : VectorEpoxyModel<BottomSheetV
@EpoxyAttribute
var iconColor: Int = -1
@EpoxyAttribute
lateinit var listener: () -> Unit
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
lateinit var listener: ClickListener
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.setOnClickListener {
listener.invoke()
}
holder.view.onClick(listener)
holder.title.text = title
holder.title.setTextColor(titleColor)

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

@ -21,7 +21,6 @@ import im.vector.app.R
import im.vector.app.core.epoxy.noResultItem
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.ui.list.GenericItem
import im.vector.app.core.ui.list.genericItem
import me.gujun.android.span.span
import org.json.JSONObject
@ -51,11 +50,9 @@ class RoomStateListController @Inject constructor(
id(entry.key)
title(entry.key)
description(host.stringProvider.getQuantityString(R.plurals.entries, entry.value.size, entry.value.size))
itemClickAction(GenericItem.Action("view").apply {
perform = Runnable {
host.interactionListener?.processAction(RoomDevToolAction.ShowStateEventType(entry.key))
}
})
itemClickAction {
host.interactionListener?.processAction(RoomDevToolAction.ShowStateEventType(entry.key))
}
}
}
}
@ -93,11 +90,9 @@ class RoomStateListController @Inject constructor(
}
})
description(contentJson)
itemClickAction(GenericItem.Action("view").apply {
perform = Runnable {
host.interactionListener?.processAction(RoomDevToolAction.ShowStateEvent(stateEvent))
}
})
itemClickAction {
host.interactionListener?.processAction(RoomDevToolAction.ShowStateEvent(stateEvent))
}
}
}
}

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

@ -44,7 +44,7 @@ abstract class SettingsButtonItem : EpoxyModelWithHolder<SettingsButtonItem.Hold
@EpoxyAttribute
var buttonStyle: ButtonStyle = ButtonStyle.POSITIVE
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var buttonClickListener: ClickListener? = null
override fun bind(holder: Holder) {

View File

@ -30,13 +30,13 @@ abstract class SettingsContinueCancelItem : EpoxyModelWithHolder<SettingsContinu
@EpoxyAttribute
var continueText: String? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var continueOnClick: ClickListener? = null
@EpoxyAttribute
var canContinue: Boolean = true
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var cancelOnClick: ClickListener? = null
override fun bind(holder: Holder) {

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)
@ -36,8 +37,8 @@ abstract class SettingsInfoItem : EpoxyModelWithHolder<SettingsInfoItem.Holder>(
@StringRes
var helperTextResId: Int? = null
@EpoxyAttribute
var itemClickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
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)
@ -44,8 +45,8 @@ abstract class SettingsItem : EpoxyModelWithHolder<SettingsItem.Holder>() {
@EpoxyAttribute
var description: CharSequence? = null
@EpoxyAttribute
var itemClickListener: View.OnClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
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

@ -78,7 +78,7 @@ abstract class SettingsTextButtonSingleLineItem : EpoxyModelWithHolder<SettingsT
@EpoxyAttribute
var checked: Boolean? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var buttonClickListener: ClickListener? = null
@EpoxyAttribute

View File

@ -22,8 +22,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_form_advanced_toggle)
@ -31,7 +33,7 @@ abstract class FormAdvancedToggleItem : VectorEpoxyModel<FormAdvancedToggleItem.
@EpoxyAttribute lateinit var title: CharSequence
@EpoxyAttribute var expanded: Boolean = false
@EpoxyAttribute var listener: (() -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -42,7 +44,7 @@ abstract class FormAdvancedToggleItem : VectorEpoxyModel<FormAdvancedToggleItem.
}
holder.titleView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
holder.titleView.text = title
holder.view.setOnClickListener { listener?.invoke() }
holder.view.onClick(listener)
}
class Holder : VectorEpoxyHolder() {

View File

@ -26,8 +26,10 @@ 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.TextListener
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.setValueOnce
import im.vector.app.core.platform.SimpleTextWatcher
@ -61,11 +63,10 @@ abstract class FormEditTextItem : VectorEpoxyModel<FormEditTextItem.Holder>() {
@EpoxyAttribute
var endIconMode: Int? = null
// FIXME restore EpoxyAttribute.Option.DoNotHash and fix that properly
@EpoxyAttribute
var onTextChange: ((String) -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onTextChange: TextListener? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var editorActionListener: TextView.OnEditorActionListener? = null
private val onTextChangeListener = object : SimpleTextWatcher() {
@ -88,7 +89,7 @@ abstract class FormEditTextItem : VectorEpoxyModel<FormEditTextItem.Holder>() {
holder.textInputEditText.isSingleLine = singleLine
holder.textInputEditText.imeOptions = imeOptions ?: EditorInfo.IME_ACTION_NONE
holder.textInputEditText.addTextChangedListener(onTextChangeListener)
holder.textInputEditText.addTextChangedListenerOnce(onTextChangeListener)
holder.textInputEditText.setOnEditorActionListener(editorActionListener)
holder.bottomSeparator.isVisible = showBottomSeparator
}

View File

@ -17,15 +17,18 @@
package im.vector.app.features.form
import android.text.Editable
import android.view.View
import androidx.appcompat.widget.AppCompatButton
import com.airbnb.epoxy.EpoxyAttribute
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.TextListener
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.epoxy.setValueOnce
import im.vector.app.core.platform.SimpleTextWatcher
@ -44,11 +47,11 @@ abstract class FormEditTextWithButtonItem : VectorEpoxyModel<FormEditTextWithBut
@EpoxyAttribute
var buttonText: String? = null
@EpoxyAttribute
var onTextChange: ((String) -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onTextChange: TextListener? = null
@EpoxyAttribute
var onButtonClicked: ((View) -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onButtonClicked: ClickListener? = null
private val onTextChangeListener = object : SimpleTextWatcher() {
override fun afterTextChanged(s: Editable) {
@ -65,11 +68,10 @@ abstract class FormEditTextWithButtonItem : VectorEpoxyModel<FormEditTextWithBut
holder.textInputEditText.isEnabled = enabled
holder.textInputEditText.addTextChangedListener(onTextChangeListener)
holder.textInputEditText.addTextChangedListenerOnce(onTextChangeListener)
holder.textInputButton.text = buttonText
holder.textInputButton.setOnClickListener(onButtonClicked)
holder.textInputButton.onClick(onButtonClicked)
}
override fun shouldSaveViewState(): Boolean {

View File

@ -46,10 +46,10 @@ abstract class FormEditableAvatarItem : EpoxyModelWithHolder<FormEditableAvatarI
@EpoxyAttribute
var imageUri: Uri? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: ClickListener? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var deleteListener: ClickListener? = null
override fun bind(holder: Holder) {

View File

@ -49,10 +49,10 @@ abstract class FormEditableSquareAvatarItem : EpoxyModelWithHolder<FormEditableS
@EpoxyAttribute
var imageUri: Uri? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: ClickListener? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var deleteListener: ClickListener? = null
override fun bind(holder: Holder) {

View File

@ -25,8 +25,10 @@ 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.TextListener
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.setValueOnce
import im.vector.app.core.platform.SimpleTextWatcher
@ -58,7 +60,7 @@ abstract class FormMultiLineEditTextItem : VectorEpoxyModel<FormMultiLineEditTex
var typeFace: Typeface = Typeface.DEFAULT
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onTextChange: ((String) -> Unit)? = null
var onTextChange: TextListener? = null
private val onTextChangeListener = object : SimpleTextWatcher() {
override fun afterTextChanged(s: Editable) {
@ -80,7 +82,7 @@ abstract class FormMultiLineEditTextItem : VectorEpoxyModel<FormMultiLineEditTex
holder.textInputEditText.isEnabled = enabled
holder.textInputEditText.addTextChangedListener(onTextChangeListener)
holder.textInputEditText.addTextChangedListenerOnce(onTextChangeListener)
holder.bottomSeparator.isVisible = showBottomSeparator
}

View File

@ -39,7 +39,7 @@ abstract class FormSubmitButtonItem : EpoxyModelWithHolder<FormSubmitButtonItem.
@StringRes
var buttonTitleId: Int? = null
@EpoxyAttribute
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var buttonClickListener: ClickListener? = null
override fun bind(holder: Holder) {

View File

@ -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.platform.CheckableConstraintLayout
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
@ -34,11 +36,11 @@ abstract class GroupSummaryItem : VectorEpoxyModel<GroupSummaryItem.Holder>() {
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
@EpoxyAttribute lateinit var matrixItem: MatrixItem
@EpoxyAttribute var selected: Boolean = false
@EpoxyAttribute var listener: (() -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.rootView.setOnClickListener { listener?.invoke() }
holder.rootView.onClick(listener)
holder.groupNameView.text = matrixItem.displayName
holder.rootView.isChecked = selected
avatarRenderer.render(matrixItem, holder.avatarImageView)

View File

@ -26,8 +26,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.platform.CheckableConstraintLayout
import im.vector.app.features.home.room.list.UnreadCounterBadgeView
import im.vector.app.features.themes.ThemeUtils
@ -36,7 +38,7 @@ import im.vector.app.features.themes.ThemeUtils
abstract class HomeSpaceSummaryItem : VectorEpoxyModel<HomeSpaceSummaryItem.Holder>() {
@EpoxyAttribute var selected: Boolean = false
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: (() -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
@EpoxyAttribute var countState : UnreadCounterBadgeView.State = UnreadCounterBadgeView.State(0, false)
@EpoxyAttribute var showSeparator: Boolean = false
@ -47,7 +49,7 @@ abstract class HomeSpaceSummaryItem : VectorEpoxyModel<HomeSpaceSummaryItem.Hold
override fun bind(holder: Holder) {
super.bind(holder)
holder.rootView.setOnClickListener { listener?.invoke() }
holder.rootView.onClick(listener)
holder.groupNameView.text = holder.view.context.getString(R.string.group_details_home)
holder.rootView.isChecked = selected
holder.rootView.context.resources

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()
@ -52,11 +54,6 @@ abstract class BreadcrumbsItem : VectorEpoxyModel<BreadcrumbsItem.Holder>() {
holder.typingIndicator.isVisible = hasTypingUsers
}
override fun unbind(holder: Holder) {
holder.rootView.setOnClickListener(null)
super.unbind(holder)
}
class Holder : VectorEpoxyHolder() {
val unreadCounterBadgeView by bind<UnreadCounterBadgeView>(R.id.breadcrumbsUnreadCounterBadgeView)
val unreadIndentIndicator by bind<View>(R.id.breadcrumbsUnreadIndicator)

View File

@ -23,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
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
@ -33,7 +35,7 @@ abstract class DisplayReadReceiptItem : EpoxyModelWithHolder<DisplayReadReceiptI
@EpoxyAttribute lateinit var matrixItem: MatrixItem
@EpoxyAttribute var timestamp: CharSequence? = null
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
@EpoxyAttribute var userClicked: (() -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var userClicked: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -45,7 +47,7 @@ abstract class DisplayReadReceiptItem : EpoxyModelWithHolder<DisplayReadReceiptI
} ?: run {
holder.timestampView.isVisible = false
}
holder.view.setOnClickListener { userClicked?.invoke() }
holder.view.onClick(userClicked)
}
class Holder : VectorEpoxyHolder() {

View File

@ -36,15 +36,15 @@ class DisplayReadReceiptsController @Inject constructor(private val dateFormatte
var listener: Listener? = null
override fun buildModels(readReceipts: List<ReadReceiptData>) {
readReceipts.forEach {
val timestamp = dateFormatter.format(it.timestamp, DateFormatKind.DEFAULT_DATE_AND_TIME)
readReceipts.forEach { readReceiptData ->
val timestamp = dateFormatter.format(readReceiptData.timestamp, DateFormatKind.DEFAULT_DATE_AND_TIME)
DisplayReadReceiptItem_()
.id(it.userId)
.matrixItem(it.toMatrixItem())
.id(readReceiptData.userId)
.matrixItem(readReceiptData.toMatrixItem())
.avatarRenderer(avatarRender)
.timestamp(timestamp)
.userClicked { listener?.didSelectUser(it.userId) }
.addIf(session.myUserId != it.userId, this)
.userClicked { listener?.didSelectUser(readReceiptData.userId) }
.addIf(session.myUserId != readReceiptData.userId, this)
}
}

View File

@ -29,7 +29,7 @@ import im.vector.app.core.date.VectorDateFormatter
import im.vector.app.core.epoxy.loadingItem
import im.vector.app.core.epoxy.noResultItem
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.ui.list.GenericItemHeader_
import im.vector.app.core.ui.list.GenericHeaderItem_
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.Content
@ -111,7 +111,7 @@ class SearchResultController @Inject constructor(
timeInMillis = eventAndSender.event.originServerTs ?: System.currentTimeMillis()
}
if (lastDate?.get(Calendar.DAY_OF_YEAR) != eventDate.get(Calendar.DAY_OF_YEAR)) {
GenericItemHeader_()
GenericHeaderItem_()
.id(eventDate.hashCode())
.text(dateFormatter.format(eventDate.timeInMillis, DateFormatKind.EDIT_HISTORY_HEADER))
.let { result.add(it) }

View File

@ -36,7 +36,7 @@ abstract class SearchResultItem : VectorEpoxyModel<SearchResultItem.Holder>() {
@EpoxyAttribute var formattedDate: String? = null
@EpoxyAttribute lateinit var spannable: CharSequence
@EpoxyAttribute var sender: MatrixItem? = null
@EpoxyAttribute var listener: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)

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

@ -26,8 +26,8 @@ import im.vector.app.core.date.VectorDateFormatter
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.ui.list.genericFooterItem
import im.vector.app.core.ui.list.genericHeaderItem
import im.vector.app.core.ui.list.genericItem
import im.vector.app.core.ui.list.genericItemHeader
import im.vector.app.core.ui.list.genericLoaderItem
import im.vector.app.features.html.EventHtmlRenderer
import me.gujun.android.span.span
@ -87,7 +87,7 @@ class ViewEditHistoryEpoxyController @Inject constructor(
}
if (lastDate?.get(Calendar.DAY_OF_YEAR) != evDate.get(Calendar.DAY_OF_YEAR)) {
// need to display header with day
genericItemHeader {
genericHeaderItem {
id(evDate.hashCode())
text(host.dateFormatter.format(evDate.timeInMillis, DateFormatKind.EDIT_HISTORY_HEADER))
}

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,8 +26,9 @@ 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.epoxy.onClick
import im.vector.app.core.ui.views.SendStateImageView
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
@ -44,12 +45,17 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
@EpoxyAttribute
lateinit var attributes: Attributes
private val _avatarClickListener = DebouncedClickListener({
attributes.avatarCallback?.onAvatarClicked(attributes.informationData)
})
private val _memberNameClickListener = DebouncedClickListener({
attributes.avatarCallback?.onMemberNameClicked(attributes.informationData)
})
private val _avatarClickListener = object : ClickListener {
override fun invoke(p1: View) {
attributes.avatarCallback?.onAvatarClicked(attributes.informationData)
}
}
private val _memberNameClickListener = object : ClickListener {
override fun invoke(p1: View) {
attributes.avatarCallback?.onMemberNameClicked(attributes.informationData)
}
}
override fun bind(holder: H) {
super.bind(holder)
@ -59,9 +65,9 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
width = attributes.avatarSize
}
holder.avatarImageView.visibility = View.VISIBLE
holder.avatarImageView.setOnClickListener(_avatarClickListener)
holder.avatarImageView.onClick(_avatarClickListener)
holder.memberNameView.visibility = View.VISIBLE
holder.memberNameView.setOnClickListener(_memberNameClickListener)
holder.memberNameView.onClick(_memberNameClickListener)
holder.timeView.visibility = View.VISIBLE
holder.timeView.text = attributes.informationData.time
holder.memberNameView.text = attributes.informationData.memberName
@ -118,8 +124,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,8 @@ 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.setLeftDrawable
import im.vector.app.core.extensions.setTextWithColoredPart
import im.vector.app.features.home.AvatarRenderer
@ -64,11 +66,11 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
}
if (attributes.callStatus == CallStatus.INVITED && !attributes.informationData.sentByMe && attributes.isStillActive) {
holder.acceptRejectViewGroup.isVisible = true
holder.acceptView.setOnClickListener {
holder.acceptView.onClick {
attributes.callback?.onTimelineItemAction(RoomDetailAction.AcceptCall(callId = attributes.callId))
}
holder.rejectView.setLeftDrawable(R.drawable.ic_call_hangup, R.color.riotx_notice)
holder.rejectView.setOnClickListener {
holder.rejectView.onClick {
attributes.callback?.onTimelineItemAction(RoomDetailAction.EndCall)
}
holder.statusView.isVisible = false
@ -147,7 +149,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

@ -31,8 +31,8 @@ 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.onClick
import im.vector.app.core.extensions.setTextOrHide
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.core.utils.tappableMatchingText
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.RoomDetailAction
@ -172,28 +172,28 @@ abstract class MergedRoomCreationItem : BasedMergedItem<MergedRoomCreationItem.H
holder.roomAvatarImageView.isVisible = roomItem != null
if (roomItem != null) {
attributes.avatarRenderer.render(roomItem, holder.roomAvatarImageView)
holder.roomAvatarImageView.setOnClickListener(DebouncedClickListener({ view ->
holder.roomAvatarImageView.onClick { view ->
if (shouldSetAvatar) {
attributes.callback?.onTimelineItemAction(RoomDetailAction.QuickActionSetAvatar)
} else {
// Note: this is no op if there is no avatar on the room
attributes.callback?.onTimelineItemAction(RoomDetailAction.ShowRoomAvatarFullScreen(roomItem, view))
}
}))
}
}
holder.setAvatarButton.isVisible = shouldSetAvatar
if (shouldSetAvatar) {
holder.setAvatarButton.setOnClickListener(DebouncedClickListener({
holder.setAvatarButton.onClick {
attributes.callback?.onTimelineItemAction(RoomDetailAction.QuickActionSetAvatar)
}))
}
}
holder.addPeopleButton.isVisible = !isDirect
if (!isDirect) {
holder.addPeopleButton.setOnClickListener(DebouncedClickListener({
holder.addPeopleButton.onClick {
attributes.callback?.onTimelineItemAction(RoomDetailAction.QuickActionInvitePeople)
}))
}
}
}

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

@ -23,6 +23,7 @@ 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.onClick
import im.vector.app.core.extensions.setTextOrHide
import im.vector.app.features.home.room.detail.RoomDetailAction
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
@ -59,7 +60,7 @@ abstract class MessageOptionsItem : AbsMessageItem<MessageOptionsItem.Holder>()
as MaterialButton
holder.buttonContainer.addView(materialButton, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
materialButton.text = option.label
materialButton.setOnClickListener {
materialButton.onClick {
callback?.onTimelineItemAction(RoomDetailAction.ReplyToOptions(relatedEventId, index, option.value ?: "$index"))
}
}

View File

@ -24,8 +24,9 @@ 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.extensions.setTextOrHide
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.room.detail.RoomDetailAction
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import org.matrix.android.sdk.api.session.room.model.message.MessageOptionsContent
@ -143,14 +144,16 @@ abstract class MessagePollItem : AbsMessageItem<MessagePollItem.Holder>() {
override fun bindView(itemView: View) {
super.bindView(itemView)
val buttons = listOf(button1, button2, button3, button4, button5)
val clickListener = DebouncedClickListener({
val optionIndex = buttons.indexOf(it)
if (optionIndex != -1 && pollId != null) {
val compatValue = if (optionIndex < optionValues?.size ?: 0) optionValues?.get(optionIndex) else null
callback?.onTimelineItemAction(RoomDetailAction.ReplyToOptions(pollId!!, optionIndex, compatValue ?: "$optionIndex"))
val clickListener = object : ClickListener {
override fun invoke(p1: View) {
val optionIndex = buttons.indexOf(p1)
if (optionIndex != -1 && pollId != null) {
val compatValue = if (optionIndex < optionValues?.size ?: 0) optionValues?.get(optionIndex) else null
callback?.onTimelineItemAction(RoomDetailAction.ReplyToOptions(pollId!!, optionIndex, compatValue ?: "$optionIndex"))
}
}
})
buttons.forEach { it.setOnClickListener(clickListener) }
}
buttons.forEach { it.onClick(clickListener) }
}
}

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

@ -22,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
/**
* Item displaying an emoji reaction (single line with emoji, author, time)
@ -39,8 +41,8 @@ abstract class ReactionInfoSimpleItem : EpoxyModelWithHolder<ReactionInfoSimpleI
@EpoxyAttribute
var timeStamp: CharSequence? = null
@EpoxyAttribute
var userClicked: (() -> Unit)? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var userClicked: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
@ -52,7 +54,7 @@ abstract class ReactionInfoSimpleItem : EpoxyModelWithHolder<ReactionInfoSimpleI
} ?: run {
holder.timeStampView.isVisible = false
}
holder.view.setOnClickListener { userClicked?.invoke() }
holder.view.onClick(userClicked)
}
class Holder : VectorEpoxyHolder() {

View File

@ -52,13 +52,13 @@ class ViewReactionsEpoxyController @Inject constructor(
}
}
is Success -> {
state.mapReactionKeyToMemberList()?.forEach {
state.mapReactionKeyToMemberList()?.forEach { reactionInfo ->
reactionInfoSimpleItem {
id(it.eventId)
timeStamp(it.timestamp)
reactionKey(host.emojiCompatWrapper.safeEmojiSpanify(it.reactionKey))
authorDisplayName(it.authorName ?: it.authorId)
userClicked { host.listener?.didSelectUser(it.authorId) }
id(reactionInfo.eventId)
timeStamp(reactionInfo.timestamp)
reactionKey(host.emojiCompatWrapper.safeEmojiSpanify(reactionInfo.reactionKey))
authorDisplayName(reactionInfo.authorName ?: reactionInfo.authorId)
userClicked { host.listener?.didSelectUser(reactionInfo.authorId) }
}
}
}

View File

@ -35,7 +35,7 @@ import java.net.URL
abstract class RoomWidgetItem : EpoxyModelWithHolder<RoomWidgetItem.Holder>() {
@EpoxyAttribute lateinit var widget: Widget
@EpoxyAttribute var widgetClicked: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var widgetClicked: ClickListener? = null
@DrawableRes
@EpoxyAttribute var iconRes: Int? = 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

@ -22,6 +22,7 @@ import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
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.room.list.widget.NotifsFabMenuView
@EpoxyModelClass(layout = R.layout.item_room_filter_footer)
@ -35,9 +36,9 @@ abstract class FilteredRoomFooterItem : VectorEpoxyModel<FilteredRoomFooterItem.
override fun bind(holder: Holder) {
super.bind(holder)
holder.createRoomButton.setOnClickListener { listener?.createRoom(currentFilter) }
holder.createDirectChat.setOnClickListener { listener?.createDirectChat() }
holder.openRoomDirectory.setOnClickListener { listener?.openRoomDirectory(currentFilter) }
holder.createRoomButton.onClick { listener?.createRoom(currentFilter) }
holder.createDirectChat.onClick { listener?.createDirectChat() }
holder.openRoomDirectory.onClick { listener?.openRoomDirectory(currentFilter) }
}
class Holder : VectorEpoxyHolder() {

View File

@ -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<RoomCategoryItem.Holder>() {
@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<RoomCategoryItem.Holder>() {
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() {

View File

@ -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<RoomInvitationItem.Holder>(
@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)

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

@ -22,12 +22,13 @@ import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.recyclerview.widget.RecyclerView
import im.vector.app.R
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.epoxy.onClick
import im.vector.app.databinding.ItemRoomCategoryBinding
import im.vector.app.features.themes.ThemeUtils
class SectionHeaderAdapter constructor(
private val onClickAction: (() -> Unit)
private val onClickAction: ClickListener
) : RecyclerView.Adapter<SectionHeaderAdapter.VH>() {
data class RoomsSectionData(
@ -59,7 +60,7 @@ class SectionHeaderAdapter constructor(
override fun getItemViewType(position: Int) = R.layout.item_room_category
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
return VH.create(parent, this.onClickAction)
return VH.create(parent, onClickAction)
}
override fun onBindViewHolder(holder: VH, position: Int) {
@ -70,13 +71,11 @@ class SectionHeaderAdapter constructor(
class VH constructor(
private val binding: ItemRoomCategoryBinding,
onClickAction: (() -> Unit)
onClickAction: ClickListener
) : RecyclerView.ViewHolder(binding.root) {
init {
binding.root.setOnClickListener(DebouncedClickListener({
onClickAction.invoke()
}))
binding.root.onClick(onClickAction)
}
fun bind(roomsSectionData: RoomsSectionData) {
@ -91,7 +90,7 @@ class SectionHeaderAdapter constructor(
}
companion object {
fun create(parent: ViewGroup, onClickAction: () -> Unit): VH {
fun create(parent: ViewGroup, onClickAction: ClickListener): VH {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_room_category, parent, false)
val binding = ItemRoomCategoryBinding.bind(view)

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

@ -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) {

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

@ -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 ->

View File

@ -63,13 +63,13 @@ class EmojiSearchResultController @Inject constructor(
}
} else {
// Build the search results
results.forEach {
results.forEach { emojiItem ->
emojiSearchResultItem {
id(it.name)
emojiItem(it)
id(emojiItem.name)
emojiItem(emojiItem)
emojiTypeFace(host.emojiTypeface)
currentQuery(data.query)
onClickListener(host.listener)
onClickListener { host.listener?.onReactionSelected(emojiItem.emoji) }
}
}
}

View File

@ -21,7 +21,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
import im.vector.app.features.reactions.data.EmojiItem
@ -34,8 +36,8 @@ abstract class EmojiSearchResultItem : EpoxyModelWithHolder<EmojiSearchResultIte
@EpoxyAttribute
var currentQuery: String? = null
@EpoxyAttribute
var onClickListener: ReactionClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onClickListener: ClickListener? = null
@EpoxyAttribute
var emojiTypeFace: Typeface? = null
@ -47,9 +49,7 @@ abstract class EmojiSearchResultItem : EpoxyModelWithHolder<EmojiSearchResultIte
holder.emojiText.typeface = emojiTypeFace ?: Typeface.DEFAULT
holder.emojiNameText.text = emojiItem.name
holder.emojiKeywordText.setTextOrHide(emojiItem.keywords.joinToString())
holder.view.setOnClickListener {
onClickListener?.onReactionSelected(emojiItem.emoji)
}
holder.view.onClick(onClickListener)
}
class Holder : VectorEpoxyHolder() {

View File

@ -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<PublicRoomItem.Holder>() {
@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<PublicRoomItem.Holder>() {
}
)
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() {

View File

@ -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<UnknownRoomItem.Holder>() {
@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
}

Some files were not shown because too many files have changed in this diff Show More