Fix recyclerview issues on async map functions.
This commit is contained in:
parent
9ea30445ef
commit
ae8ca5356f
|
@ -73,7 +73,6 @@ import im.vector.app.features.html.PillsPostProcessor
|
|||
import im.vector.app.features.html.SpanUtils
|
||||
import im.vector.app.features.html.VectorHtmlCompressor
|
||||
import im.vector.app.features.location.LocationData
|
||||
import im.vector.app.features.location.VectorMapView
|
||||
import im.vector.app.features.media.ImageContentRenderer
|
||||
import im.vector.app.features.media.VideoContentRenderer
|
||||
import me.gujun.android.span.span
|
||||
|
@ -192,11 +191,9 @@ class MessageItemFactory @Inject constructor(
|
|||
val locationData = LocationData.create(geoUri)
|
||||
|
||||
val mapCallback: MessageLocationItem.Callback = object : MessageLocationItem.Callback {
|
||||
override fun onMapReady(mapView: VectorMapView) {
|
||||
mapView.onClick {
|
||||
locationData?.let {
|
||||
callback?.onTimelineItemAction(RoomDetailAction.ShowLocation(it, informationData.senderId))
|
||||
}
|
||||
override fun onMapClicked() {
|
||||
locationData?.let {
|
||||
callback?.onTimelineItemAction(RoomDetailAction.ShowLocation(it, informationData.senderId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,21 +16,22 @@
|
|||
|
||||
package im.vector.app.features.home.room.detail.timeline.item
|
||||
|
||||
import android.widget.FrameLayout
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvider
|
||||
import im.vector.app.features.location.LocationData
|
||||
import im.vector.app.features.location.MapTilerMapView
|
||||
import im.vector.app.features.location.VectorMapListener
|
||||
import im.vector.app.features.location.VectorMapView
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_timeline_event_base)
|
||||
abstract class MessageLocationItem : AbsMessageItem<MessageLocationItem.Holder>() {
|
||||
|
||||
interface Callback {
|
||||
fun onMapReady(mapView: VectorMapView)
|
||||
fun onMapClicked()
|
||||
}
|
||||
|
||||
@EpoxyAttribute
|
||||
|
@ -52,6 +53,10 @@ abstract class MessageLocationItem : AbsMessageItem<MessageLocationItem.Holder>(
|
|||
val location = locationData ?: return
|
||||
val locationOwnerId = userId ?: return
|
||||
|
||||
holder.clickableMapArea.onClick {
|
||||
callback?.onMapClicked()
|
||||
}
|
||||
|
||||
holder.mapView.apply {
|
||||
initialize(object : VectorMapListener {
|
||||
override fun onMapReady() {
|
||||
|
@ -61,8 +66,6 @@ abstract class MessageLocationItem : AbsMessageItem<MessageLocationItem.Holder>(
|
|||
addPinToMap(locationOwnerId, pinDrawable)
|
||||
updatePinLocation(locationOwnerId, location.latitude, location.longitude)
|
||||
}
|
||||
|
||||
callback?.onMapReady(this@apply)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -73,6 +76,7 @@ abstract class MessageLocationItem : AbsMessageItem<MessageLocationItem.Holder>(
|
|||
class Holder : AbsMessageItem.Holder(STUB_ID) {
|
||||
val mapViewContainer by bind<ConstraintLayout>(R.id.mapViewContainer)
|
||||
val mapView by bind<MapTilerMapView>(R.id.mapView)
|
||||
val clickableMapArea by bind<FrameLayout>(R.id.clickableMapArea)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -14,4 +14,13 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/clickableMapArea"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/mapView"
|
||||
app:layout_constraintEnd_toEndOf="@id/mapView"
|
||||
app:layout_constraintStart_toStartOf="@id/mapView"
|
||||
app:layout_constraintTop_toTopOf="@id/mapView" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
Loading…
Reference in New Issue