From 9444a3d74b773b109e91e9bc8a284919e046a721 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Tue, 10 Dec 2024 16:54:37 +0530 Subject: [PATCH] Fixed: `IllegalStateException` while setting the toolbar in `SearchFragment` which i accidentally faced while navigating very frequently to other screens. --- .../org/kiwix/kiwixmobile/core/search/SearchFragment.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/search/SearchFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/search/SearchFragment.kt index d3bc7d308..a028247d2 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/search/SearchFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/search/SearchFragment.kt @@ -192,11 +192,12 @@ class SearchFragment : BaseFragment() { ) } + @Suppress("UnnecessarySafeCall") private fun setupToolbar(view: View) { view.post { - with(requireActivity() as CoreMainActivity) { - setSupportActionBar(view.findViewById(R.id.toolbar)) - supportActionBar?.apply { + with(activity as? CoreMainActivity) { + this?.setSupportActionBar(view.findViewById(R.id.toolbar)) + this?.supportActionBar?.apply { setHomeButtonEnabled(true) title = getString(R.string.menu_search_in_text) }