diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt index 94492e36..045bb1c7 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt @@ -19,6 +19,7 @@ package im.vector.riotredesign.features.home.room.detail.timeline.item import android.os.Build import android.view.View import android.view.ViewGroup +import android.view.ViewStub import android.widget.ImageView import android.widget.TextView import androidx.constraintlayout.helper.widget.Flow @@ -76,14 +77,19 @@ abstract class AbsMessageItem : BaseEventItem() { holder.view.setOnLongClickListener(longClickListener) if (informationData.orderedReactionList.isNullOrEmpty()) { - holder.reactionWrapper.isVisible = false + holder.reactionWrapper?.isVisible = false } else { - holder.reactionWrapper.isVisible = true + //inflate if needed + if (holder.reactionFlowHelper == null) { + holder.reactionWrapper = holder.view.findViewById(R.id.messageBottomInfo).inflate() as? ViewGroup + holder.reactionFlowHelper = holder.view.findViewById(R.id.reactionsFlowHelper) + } + holder.reactionWrapper?.isVisible = true //clear all reaction buttons (but not the Flow helper!) - holder.reactionWrapper.children.forEach { (it as? ReactionButton)?.isGone = true } + holder.reactionWrapper?.children?.forEach { (it as? ReactionButton)?.isGone = true } val idToRefInFlow = ArrayList() informationData.orderedReactionList?.forEachIndexed { index, reaction -> - (holder.reactionWrapper.children.elementAt(index) as? ReactionButton)?.let { reactionButton -> + (holder.reactionWrapper?.children?.elementAt(index) as? ReactionButton)?.let { reactionButton -> reactionButton.isVisible = true idToRefInFlow.add(reactionButton.id) reactionButton.reactionString = reaction.first @@ -93,9 +99,9 @@ abstract class AbsMessageItem : BaseEventItem() { } // Just setting the view as gone will break the FlowHelper (and invisible will take too much space), // so have to update ref ids - holder.reactionFlowHelper.referencedIds = idToRefInFlow.toIntArray() + holder.reactionFlowHelper?.referencedIds = idToRefInFlow.toIntArray() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && !holder.view.isInLayout) { - holder.reactionFlowHelper.requestLayout() + holder.reactionFlowHelper?.requestLayout() } } @@ -112,8 +118,8 @@ abstract class AbsMessageItem : BaseEventItem() { val memberNameView by bind(R.id.messageMemberNameView) val timeView by bind(R.id.messageTimeView) - val reactionWrapper: ViewGroup by bind(R.id.messageBottomInfo) - val reactionFlowHelper: Flow by bind(R.id.reactionsFlowHelper) + var reactionWrapper: ViewGroup? = null + var reactionFlowHelper: Flow? = null } } \ No newline at end of file diff --git a/vector/src/main/res/layout/item_timeline_event_base.xml b/vector/src/main/res/layout/item_timeline_event_base.xml index 89c3b318..dc2e2ed6 100644 --- a/vector/src/main/res/layout/item_timeline_event_base.xml +++ b/vector/src/main/res/layout/item_timeline_event_base.xml @@ -82,116 +82,23 @@ tools:ignore="MissingConstraints" /> + - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/vector/src/main/res/layout/item_timeline_event_bottom_reactions_stub.xml b/vector/src/main/res/layout/item_timeline_event_bottom_reactions_stub.xml new file mode 100644 index 00000000..13ca78ae --- /dev/null +++ b/vector/src/main/res/layout/item_timeline_event_bottom_reactions_stub.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/values/styles_riot.xml b/vector/src/main/res/values/styles_riot.xml index 7ab2caa1..530108f3 100644 --- a/vector/src/main/res/values/styles_riot.xml +++ b/vector/src/main/res/values/styles_riot.xml @@ -252,7 +252,7 @@ wrap_content 8dp 8dp - 8dp + 4dp 4dp parent parent