Temporary workarounds to avoid some crashes.

This commit is contained in:
ganfra 2019-02-11 13:47:47 +01:00
parent 7a5ff282b6
commit 5e81fc8dc2
5 changed files with 34 additions and 13 deletions

View File

@ -24,6 +24,13 @@ def generateVersionCodeFromVersionName() {
return versionMajor * 10000 + versionMinor * 100 + versionPatch return versionMajor * 10000 + versionMinor * 100 + versionPatch
} }


project.android.buildTypes.all { buildType ->
buildType.javaCompileOptions.annotationProcessorOptions.arguments =
[
validateEpoxyModelUsage : String.valueOf(buildType.name == 'debug')
]
}

android { android {
compileSdkVersion 28 compileSdkVersion 28
defaultConfig { defaultConfig {

View File

@ -52,11 +52,11 @@ class HomeActivityViewModel(state: EmptyState,
get() = _openRoomLiveData get() = _openRoomLiveData


init { init {
val lastSelectedRoom = roomSelectionRepository.lastSelectedRoom() val lastSelectedRoomId = roomSelectionRepository.lastSelectedRoom()
if (lastSelectedRoom == null) { if (lastSelectedRoomId == null || session.getRoom(lastSelectedRoomId) == null) {
getTheFirstRoomWhenAvailable() getTheFirstRoomWhenAvailable()
} else { } else {
_openRoomLiveData.postValue(LiveEvent(lastSelectedRoom)) _openRoomLiveData.postValue(LiveEvent(lastSelectedRoomId))
} }
} }



View File

@ -20,8 +20,12 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent


class DefaultItemFactory { class DefaultItemFactory {


fun create(event: TimelineEvent): DefaultItem? { fun create(event: TimelineEvent, exception: Exception? = null): DefaultItem? {
val text = "${event.root.type} events are not yet handled" val text = if (exception == null) {
"${event.root.type} events are not yet handled"
} else {
"an exception occurred when rendering the event ${event.root.eventId}"
}
return DefaultItem(text = text) return DefaultItem(text = text)
} }



View File

@ -26,6 +26,7 @@ import im.vector.matrix.android.api.session.room.model.message.MessageContent
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
import im.vector.matrix.android.api.session.room.model.message.MessageTextContent import im.vector.matrix.android.api.session.room.model.message.MessageTextContent
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import im.vector.riotredesign.core.epoxy.KotlinModel
import im.vector.riotredesign.core.extensions.localDateTime import im.vector.riotredesign.core.extensions.localDateTime
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
import im.vector.riotredesign.features.media.MediaContentRenderer import im.vector.riotredesign.features.media.MediaContentRenderer
@ -38,7 +39,7 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
fun create(event: TimelineEvent, fun create(event: TimelineEvent,
nextEvent: TimelineEvent?, nextEvent: TimelineEvent?,
callback: TimelineEventController.Callback? callback: TimelineEventController.Callback?
): AbsMessageItem? { ): KotlinModel? {


val roomMember = event.roomMember val roomMember = event.roomMember
val nextRoomMember = nextEvent?.roomMember val nextRoomMember = nextEvent?.roomMember
@ -66,10 +67,15 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
return when (messageContent) { return when (messageContent) {
is MessageTextContent -> buildTextMessageItem(messageContent, informationData, callback) is MessageTextContent -> buildTextMessageItem(messageContent, informationData, callback)
is MessageImageContent -> buildImageMessageItem(messageContent, informationData) is MessageImageContent -> buildImageMessageItem(messageContent, informationData)
else -> null else -> buildNotHandledMessageItem(messageContent)
} }
} }


private fun buildNotHandledMessageItem(messageContent: MessageContent): KotlinModel? {
val text = "${messageContent.type} message events are not yet handled"
return DefaultItem(text = text)
}

private fun buildImageMessageItem(messageContent: MessageImageContent, private fun buildImageMessageItem(messageContent: MessageImageContent,
informationData: MessageInformationData): MessageImageItem? { informationData: MessageInformationData): MessageImageItem? {



View File

@ -30,12 +30,16 @@ class TimelineItemFactory(private val messageItemFactory: MessageItemFactory,
nextEvent: TimelineEvent?, nextEvent: TimelineEvent?,
callback: TimelineEventController.Callback?): KotlinModel? { callback: TimelineEventController.Callback?): KotlinModel? {


return when (event.root.type) { return try {
EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, callback) when (event.root.type) {
EventType.STATE_ROOM_NAME -> roomNameItemFactory.create(event) EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, callback)
EventType.STATE_ROOM_TOPIC -> roomTopicItemFactory.create(event) EventType.STATE_ROOM_NAME -> roomNameItemFactory.create(event)
EventType.STATE_ROOM_MEMBER -> roomMemberItemFactory.create(event) EventType.STATE_ROOM_TOPIC -> roomTopicItemFactory.create(event)
else -> defaultItemFactory.create(event) EventType.STATE_ROOM_MEMBER -> roomMemberItemFactory.create(event)
else -> defaultItemFactory.create(event)
}
} catch (e: Exception) {
defaultItemFactory.create(event, e)
} }
} }