diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt index 714d8b20ae1c61649a9b1166ab0b3e599f06f1e0..a4a112975425eaff46be35ef1dcff81305eef106 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt @@ -661,7 +661,7 @@ open class MessageList : openFolderTransaction!!.commit() openFolderTransaction = null - messageListFragment!!.setFullyActive() + messageListFragment?.setFullyActive() onMessageListDisplayed() } @@ -807,15 +807,15 @@ open class MessageList : when (if (event.unicodeChar != 0) event.unicodeChar.toChar() else null) { 'c' -> { - messageListFragment!!.onCompose() + messageListFragment?.onCompose() return true } 'o' -> { - messageListFragment!!.onCycleSort() + messageListFragment?.onCycleSort() return true } 'i' -> { - messageListFragment!!.onReverseSort() + messageListFragment?.onReverseSort() return true } 'd' -> { @@ -823,12 +823,12 @@ open class MessageList : return true } 's' -> { - messageListFragment!!.toggleMessageSelect() + messageListFragment?.toggleMessageSelect() return true } 'g' -> { if (displayMode == DisplayMode.MESSAGE_LIST) { - messageListFragment!!.onToggleFlagged() + messageListFragment?.onToggleFlagged() } else if (messageViewContainerFragment != null) { messageViewContainerFragment!!.onToggleFlagged() } @@ -836,7 +836,7 @@ open class MessageList : } 'm' -> { if (displayMode == DisplayMode.MESSAGE_LIST) { - messageListFragment!!.onMove() + messageListFragment?.onMove() } else if (messageViewContainerFragment != null) { messageViewContainerFragment!!.onMove() } @@ -844,7 +844,7 @@ open class MessageList : } 'v' -> { if (displayMode == DisplayMode.MESSAGE_LIST) { - messageListFragment!!.onArchive() + messageListFragment?.onArchive() } else if (messageViewContainerFragment != null) { messageViewContainerFragment!!.onArchive() } @@ -852,7 +852,7 @@ open class MessageList : } 'y' -> { if (displayMode == DisplayMode.MESSAGE_LIST) { - messageListFragment!!.onCopy() + messageListFragment?.onCopy() } else if (messageViewContainerFragment != null) { messageViewContainerFragment!!.onCopy() } @@ -860,7 +860,7 @@ open class MessageList : } 'z' -> { if (displayMode == DisplayMode.MESSAGE_LIST) { - messageListFragment!!.onToggleRead() + messageListFragment?.onToggleRead() } else if (messageViewContainerFragment != null) { messageViewContainerFragment!!.onToggleRead() } @@ -903,7 +903,7 @@ open class MessageList : private fun onDeleteHotKey() { if (displayMode == DisplayMode.MESSAGE_LIST) { - messageListFragment!!.onDelete() + messageListFragment?.onDelete() } else if (messageViewContainerFragment != null) { messageViewContainerFragment!!.onDelete() } @@ -1158,7 +1158,7 @@ open class MessageList : fragmentTransaction.commit() } - messageListFragment!!.setActiveMessage(null) + messageListFragment?.setActiveMessage(null) } private fun removeMessageViewContainerFragment() { @@ -1173,10 +1173,12 @@ open class MessageList : } private fun removeMessageListFragment() { - val fragmentTransaction = supportFragmentManager.beginTransaction() - fragmentTransaction.remove(messageListFragment!!) - messageListFragment = null - fragmentTransaction.commit() + messageListFragment?.let { + val fragmentTransaction = supportFragmentManager.beginTransaction() + fragmentTransaction.remove(it) + messageListFragment = null + fragmentTransaction.commit() + } } override fun goBack() { @@ -1247,8 +1249,8 @@ open class MessageList : displayMode = DisplayMode.MESSAGE_LIST messageViewContainerFragment?.isActive = false - messageListFragment!!.isActive = true - messageListFragment!!.setActiveMessage(null) + messageListFragment?.isActive = true + messageListFragment?.setActiveMessage(null) viewSwitcher!!.showFirstView() @@ -1289,9 +1291,7 @@ open class MessageList : } private fun showDefaultTitleView() { - if (messageListFragment != null) { - messageListFragment!!.updateTitle() - } + messageListFragment?.updateTitle() } private fun showMessageTitleView() {