From 151fec5ce0c021c07bff5ec6cc915c4703e3559f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 28 Feb 2020 11:38:30 +0100 Subject: [PATCH] Fix crash on attachment preview screen (#1088) --- CHANGES.md | 2 +- .../features/attachments/preview/AttachmentsPreviewFragment.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 65f6e96f69..4f8838deb6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Improvements 🙌: - Bugfix 🐛: - - + - Fix crash on attachment preview screen (#1088) Translations 🗣: - diff --git a/vector/src/main/java/im/vector/riotx/features/attachments/preview/AttachmentsPreviewFragment.kt b/vector/src/main/java/im/vector/riotx/features/attachments/preview/AttachmentsPreviewFragment.kt index 1d525dddf7..e52b497df4 100644 --- a/vector/src/main/java/im/vector/riotx/features/attachments/preview/AttachmentsPreviewFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/attachments/preview/AttachmentsPreviewFragment.kt @@ -39,6 +39,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import com.yalantis.ucrop.UCrop import com.yalantis.ucrop.UCropActivity +import im.vector.matrix.android.api.extensions.orFalse import im.vector.matrix.android.api.session.content.ContentAttachmentData import im.vector.riotx.R import im.vector.riotx.core.extensions.cleanup @@ -115,7 +116,7 @@ class AttachmentsPreviewFragment @Inject constructor( override fun onPrepareOptionsMenu(menu: Menu) { withState(viewModel) { state -> val editMenuItem = menu.findItem(R.id.attachmentsPreviewEditAction) - val showEditMenuItem = state.attachments[state.currentAttachmentIndex].isEditable() + val showEditMenuItem = state.attachments.getOrNull(state.currentAttachmentIndex)?.isEditable().orFalse() editMenuItem.setVisible(showEditMenuItem) }