diff --git a/app/build.gradle b/app/build.gradle index 1271c1ea4d..c5850ece1c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt index a08d455ba0..1f72d3824e 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt @@ -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)) } } diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt index 7c43d75cd9..03a631eaf1 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt @@ -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) } diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt index 35b55933fd..314bf77487 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt @@ -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? { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt index cc30b0105c..83a41cf65e 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt @@ -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) } }