Using information data in message factory

This commit is contained in:
Maxime NATUREL 2022-04-29 17:00:32 +02:00
parent 90aad44edf
commit 0561fe5b08
2 changed files with 11 additions and 7 deletions

View File

@ -21,9 +21,11 @@ import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.home.room.detail.timeline.helper.AvatarSizeProvider
import im.vector.app.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
import im.vector.app.features.home.room.detail.timeline.item.AbsMessageItem
import im.vector.app.features.home.room.detail.timeline.item.LiveLocationShareSummaryData
import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocationStartItem
import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocationStartItem_
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.extensions.orTrue
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent
import javax.inject.Inject
@ -34,20 +36,22 @@ class LiveLocationMessageItemFactory @Inject constructor(
) {
fun create(
beaconInfoContent: MessageBeaconInfoContent,
liveLocationShareSummaryData: LiveLocationShareSummaryData?,
highlight: Boolean,
attributes: AbsMessageItem.Attributes,
): VectorEpoxyModel<*>? {
// TODO handle location received and stopped states
// TODO create a dedicated ViewState
return when {
isLiveRunning(beaconInfoContent) -> buildStartLiveItem(highlight, attributes)
else -> null
liveLocationShareSummaryData == null -> null
isLiveRunning(liveLocationShareSummaryData) -> buildStartLiveItem(highlight, attributes)
else -> null
}
}
private fun isLiveRunning(beaconInfoContent: MessageBeaconInfoContent): Boolean {
// TODO when we will use aggregatedSummary, check if the live has timed out as well
return beaconInfoContent.isLive.orFalse()
private fun isLiveRunning(liveLocationShareSummaryData: LiveLocationShareSummaryData): Boolean {
// TODO check if the live has timed out as well
return liveLocationShareSummaryData.isActive.orFalse()
}
private fun buildStartLiveItem(

View File

@ -216,7 +216,7 @@ class MessageItemFactory @Inject constructor(
buildMessageTextItem(messageContent.body, false, informationData, highlight, callback, attributes)
}
}
is MessageBeaconInfoContent -> liveLocationMessageItemFactory.create(messageContent, highlight, attributes)
is MessageBeaconInfoContent -> liveLocationMessageItemFactory.create(informationData.liveLocationShareSummaryData, highlight, attributes)
else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes)
}
return messageItem?.apply {