Fix crash when mixing static and live location

This commit is contained in:
Maxime NATUREL 2022-05-03 12:02:05 +02:00
parent f2b66c5fb5
commit 0a21bd4b78
4 changed files with 23 additions and 8 deletions

View File

@ -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<H : AbsMessageLocationItem.Holder> : 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<ImageView>(R.id.staticMapImageView)
val staticMapPinImageView by bind<ImageView>(R.id.staticMapPinImageView)
val staticMapErrorTextView by bind<TextView>(R.id.staticMapErrorTextView)
}
companion object {
private const val STUB_ID = R.id.messageContentLocationStub
}
}

View File

@ -110,7 +110,13 @@ abstract class MessageLiveLocationItem : AbsMessageLocationItem<MessageLiveLocat
private fun getRemainingTimeOfLiveInMillis() =
(endOfLiveDateTime?.toTimestamp() ?: 0) - LocalDateTime.now().toTimestamp()
class Holder : AbsMessageLocationItem.Holder() {
override fun getViewStubId() = STUB_ID
class Holder : AbsMessageLocationItem.Holder(STUB_ID) {
val locationLiveMessageBanner by bind<LocationLiveMessageBannerView>(R.id.locationLiveMessageBanner)
}
companion object {
private const val STUB_ID = R.id.messageContentLiveLocationStub
}
}

View File

@ -21,5 +21,12 @@ import im.vector.app.R
@EpoxyModelClass(layout = R.layout.item_timeline_event_base)
abstract class MessageLocationItem : AbsMessageLocationItem<MessageLocationItem.Holder>() {
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
}
}

View File

@ -59,6 +59,12 @@
android:layout_height="wrap_content"
android:layout="@layout/item_timeline_event_location_stub" />
<ViewStub
android:id="@+id/messageContentLiveLocationStub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout="@layout/item_timeline_event_location_stub" />
<ViewStub
android:id="@+id/messageContentLiveLocationStartStub"
android:layout_width="match_parent"