From 033efd223e87656e0cd1297dcf98b7ab95214cc2 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 28 Sep 2023 11:34:10 +0600 Subject: [PATCH] 7320-Improve_null_check_on_messageListFragment issue: https://gitlab.e.foundation/e/backlog/-/issues/7320 --- .../java/com/fsck/k9/activity/MessageList.kt | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) 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 714d8b20ae..a4a1129754 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() { -- GitLab