From 0a21bd4b78b00c10a130f619ff92887a673d39e3 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 3 May 2022 12:02:05 +0200 Subject: [PATCH] Fix crash when mixing static and live location --- .../room/detail/timeline/item/AbsMessageLocationItem.kt | 8 ++------ .../room/detail/timeline/item/MessageLiveLocationItem.kt | 8 +++++++- .../room/detail/timeline/item/MessageLocationItem.kt | 9 ++++++++- .../layout/item_timeline_event_view_stubs_container.xml | 6 ++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt index ad18759fc6..b502d82829 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt @@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail.timeline.item import android.graphics.drawable.Drawable import android.widget.ImageView import android.widget.TextView +import androidx.annotation.IdRes import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams import com.airbnb.epoxy.EpoxyAttribute @@ -101,15 +102,10 @@ abstract class AbsMessageLocationItem : AbsMe .into(holder.staticMapImageView) } - override fun getViewStubId() = STUB_ID - - open class Holder : AbsMessageItem.Holder(STUB_ID) { + abstract class Holder(@IdRes stubId: Int) : AbsMessageItem.Holder(stubId) { val staticMapImageView by bind(R.id.staticMapImageView) val staticMapPinImageView by bind(R.id.staticMapPinImageView) val staticMapErrorTextView by bind(R.id.staticMapErrorTextView) } - companion object { - private const val STUB_ID = R.id.messageContentLocationStub - } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt index d68e091564..daca48e7aa 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt @@ -110,7 +110,13 @@ abstract class MessageLiveLocationItem : AbsMessageLocationItem(R.id.locationLiveMessageBanner) } + + companion object { + private const val STUB_ID = R.id.messageContentLiveLocationStub + } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLocationItem.kt index 7da9149dc4..37f728407b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLocationItem.kt @@ -21,5 +21,12 @@ import im.vector.app.R @EpoxyModelClass(layout = R.layout.item_timeline_event_base) abstract class MessageLocationItem : AbsMessageLocationItem() { - class Holder : AbsMessageLocationItem.Holder() + + override fun getViewStubId() = STUB_ID + + class Holder : AbsMessageLocationItem.Holder(STUB_ID) + + companion object { + private const val STUB_ID = R.id.messageContentLocationStub + } } diff --git a/vector/src/main/res/layout/item_timeline_event_view_stubs_container.xml b/vector/src/main/res/layout/item_timeline_event_view_stubs_container.xml index 3f08fae131..0d45a48b9b 100644 --- a/vector/src/main/res/layout/item_timeline_event_view_stubs_container.xml +++ b/vector/src/main/res/layout/item_timeline_event_view_stubs_container.xml @@ -59,6 +59,12 @@ android:layout_height="wrap_content" android:layout="@layout/item_timeline_event_location_stub" /> + +