From 774f818bbb7928ac875412c114d29711086689d8 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 18 Sep 2021 16:28:58 -0400 Subject: [PATCH] Fix setting search re-animating on activity recreation (fixes #5882) --- .../eu/kanade/tachiyomi/ui/setting/SettingsController.kt | 3 +++ .../ui/setting/search/SettingsSearchController.kt | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt index 1eb724527..b340bf1c7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt @@ -68,6 +68,9 @@ abstract class SettingsController : PreferenceController() { animatePreferenceHighlight(it.itemView) } } + + // Explicitly clear it to avoid re-scrolling/animating on activity recreations + preferenceKey = null } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchController.kt index 5dc4e1d05..b891c6f7f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchController.kt @@ -25,7 +25,7 @@ class SettingsSearchController : /** * Adapter containing search results grouped by lang. */ - protected var adapter: SettingsSearchAdapter? = null + private var adapter: SettingsSearchAdapter? = null private lateinit var searchView: SearchView init { @@ -54,15 +54,12 @@ class SettingsSearchController : * @param inflater used to load the menu xml. */ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { - // Inflate menu. inflater.inflate(R.menu.settings_main, menu) // Initialize search menu val searchItem = menu.findItem(R.id.action_search) searchView = searchItem.actionView as SearchView searchView.maxWidth = Int.MAX_VALUE - - // Change hint to show "search settings." searchView.queryHint = applicationContext?.getString(R.string.action_search_settings) searchItem.expandActionView() @@ -102,8 +99,6 @@ class SettingsSearchController : super.onViewCreated(view) adapter = SettingsSearchAdapter(this) - - // Create recycler and set adapter. binding.recycler.layoutManager = LinearLayoutManager(view.context) binding.recycler.adapter = adapter