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
}

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

android {
compileSdkVersion 28
defaultConfig {

View File

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

init {
val lastSelectedRoom = roomSelectionRepository.lastSelectedRoom()
if (lastSelectedRoom == null) {
val lastSelectedRoomId = roomSelectionRepository.lastSelectedRoom()
if (lastSelectedRoomId == null || session.getRoom(lastSelectedRoomId) == null) {
getTheFirstRoomWhenAvailable()
} 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 {

fun create(event: TimelineEvent): DefaultItem? {
val text = "${event.root.type} events are not yet handled"
fun create(event: TimelineEvent, exception: Exception? = null): DefaultItem? {
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)
}


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.MessageTextContent
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.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
import im.vector.riotredesign.features.media.MediaContentRenderer
@ -38,7 +39,7 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
fun create(event: TimelineEvent,
nextEvent: TimelineEvent?,
callback: TimelineEventController.Callback?
): AbsMessageItem? {
): KotlinModel? {

val roomMember = event.roomMember
val nextRoomMember = nextEvent?.roomMember
@ -66,10 +67,15 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
return when (messageContent) {
is MessageTextContent -> buildTextMessageItem(messageContent, informationData, callback)
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,
informationData: MessageInformationData): MessageImageItem? {


View File

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

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