From e3942cf858e01589dbcaf3732b0cc1cd88fd0d29 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Mon, 18 Jul 2022 18:40:14 +0600 Subject: [PATCH] 5825-Fix_crash_on_rotation issue: https://gitlab.e.foundation/e/backlog/-/issues/5825 ActionBar can be null after rotation comleted in messageList activity. Switched to optional ActionBar type to resolve this. --- .../java/com/fsck/k9/activity/MessageList.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 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 b8ca57ad9a..d82501ae9f 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 @@ -120,7 +120,7 @@ open class MessageList : private val permissionUiHelper: PermissionUiHelper = K9PermissionUiHelper(this) - private lateinit var actionBar: ActionBar + private var actionBar: ActionBar? = null private lateinit var searchView: SearchView private var drawer: K9Drawer? = null private var openFolderTransaction: FragmentTransaction? = null @@ -587,7 +587,7 @@ open class MessageList : private fun initializeActionBar() { actionBar = supportActionBar!! - actionBar.setDisplayHomeAsUpEnabled(true) + actionBar?.setDisplayHomeAsUpEnabled(true) } private fun initializeDrawer(savedInstanceState: Bundle?) { @@ -1250,8 +1250,8 @@ open class MessageList : } fun setActionBarTitle(title: String, subtitle: String? = null) { - actionBar.title = title - actionBar.subtitle = subtitle + actionBar?.title = title + actionBar?.subtitle = subtitle } override fun setMessageListTitle(title: String, subtitle: String?) { @@ -1261,11 +1261,11 @@ open class MessageList : } override fun setMessageListProgressEnabled(enable: Boolean) { - progressBar!!.visibility = if (enable) View.VISIBLE else View.INVISIBLE + progressBar?.visibility = if (enable) View.VISIBLE else View.INVISIBLE } override fun setMessageListProgress(progress: Int) { - progressBar!!.progress = progress + progressBar?.progress = progress } override fun openMessage(messageReference: MessageReference) { @@ -1276,9 +1276,7 @@ open class MessageList : if (draftsFolderId != null && folderId == draftsFolderId) { MessageActions.actionEditDraft(this, messageReference) } else { - if (messageListFragment != null) { - messageListFragment!!.setActiveMessage(messageReference) - } + messageListFragment?.setActiveMessage(messageReference) val fragment = MessageViewFragment.newInstance(messageReference) val fragmentTransaction = supportFragmentManager.beginTransaction() @@ -1600,12 +1598,12 @@ open class MessageList : private fun lockDrawer() { drawer!!.lock() - actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back) + actionBar?.setHomeAsUpIndicator(R.drawable.ic_arrow_back) } private fun unlockDrawer() { drawer!!.unlock() - actionBar.setHomeAsUpIndicator(getResId(R.attr.iconMenu)) + actionBar?.setHomeAsUpIndicator(getResId(R.attr.iconMenu)) } private fun initializeFromLocalSearch(search: LocalSearch?) { -- GitLab