Add long click support on unsupported event

This commit is contained in:
Benoit Marty 2019-08-28 18:17:37 +02:00
parent ef0362ba9c
commit c95223f5d2
2 changed files with 9 additions and 0 deletions

View File

@ -44,6 +44,7 @@ class DefaultItemFactory @Inject constructor(private val avatarRenderer: AvatarR
.avatarRenderer(avatarRenderer) .avatarRenderer(avatarRenderer)
.highlighted(highlight) .highlighted(highlight)
.informationData(informationData) .informationData(informationData)
.baseCallback(callback)
.readReceiptsCallback(callback) .readReceiptsCallback(callback)
} }



View File

@ -34,6 +34,13 @@ abstract class DefaultItem : BaseEventItem<DefaultItem.Holder>() {
@EpoxyAttribute @EpoxyAttribute
lateinit var avatarRenderer: AvatarRenderer lateinit var avatarRenderer: AvatarRenderer


@EpoxyAttribute
var baseCallback: TimelineEventController.BaseCallback? = null

private var longClickListener = View.OnLongClickListener {
return@OnLongClickListener baseCallback?.onEventLongClicked(informationData, null, it) == true
}

@EpoxyAttribute @EpoxyAttribute
var readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null var readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null


@ -47,6 +54,7 @@ abstract class DefaultItem : BaseEventItem<DefaultItem.Holder>() {
override fun bind(holder: Holder) { override fun bind(holder: Holder) {
holder.messageView.text = text holder.messageView.text = text


holder.view.setOnLongClickListener(longClickListener)
holder.readReceiptsView.render(informationData.readReceipts, avatarRenderer, _readReceiptsClickListener) holder.readReceiptsView.render(informationData.readReceipts, avatarRenderer, _readReceiptsClickListener)
} }