From c95223f5d24188363a4529d883ddf83ec88c72cf Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 28 Aug 2019 18:17:37 +0200 Subject: [PATCH] Add long click support on unsupported event --- .../room/detail/timeline/factory/DefaultItemFactory.kt | 1 + .../home/room/detail/timeline/item/DefaultItem.kt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/DefaultItemFactory.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/DefaultItemFactory.kt index 9adbfb8a..ec7d9e16 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/DefaultItemFactory.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/DefaultItemFactory.kt @@ -44,6 +44,7 @@ class DefaultItemFactory @Inject constructor(private val avatarRenderer: AvatarR .avatarRenderer(avatarRenderer) .highlighted(highlight) .informationData(informationData) + .baseCallback(callback) .readReceiptsCallback(callback) } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/DefaultItem.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/DefaultItem.kt index ea1aa064..b4919494 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/DefaultItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/DefaultItem.kt @@ -34,6 +34,13 @@ abstract class DefaultItem : BaseEventItem() { @EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer + @EpoxyAttribute + var baseCallback: TimelineEventController.BaseCallback? = null + + private var longClickListener = View.OnLongClickListener { + return@OnLongClickListener baseCallback?.onEventLongClicked(informationData, null, it) == true + } + @EpoxyAttribute var readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null @@ -47,6 +54,7 @@ abstract class DefaultItem : BaseEventItem() { override fun bind(holder: Holder) { holder.messageView.text = text + holder.view.setOnLongClickListener(longClickListener) holder.readReceiptsView.render(informationData.readReceipts, avatarRenderer, _readReceiptsClickListener) }