- initialize SearchResultCollection once in Activity.onCreate

This commit is contained in:
lmj0011 2020-08-27 00:53:50 -05:00
parent 3ebea4c305
commit 437a34b5dc
4 changed files with 9 additions and 6 deletions

View File

@ -10,6 +10,8 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.setting.settingssearch.SettingsSearchHelper
import eu.kanade.tachiyomi.util.lang.launchNow
import eu.kanade.tachiyomi.util.system.LocaleHelper
import uy.kohesive.injekt.injectLazy
@ -76,6 +78,8 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
super.onCreate(savedInstanceState)
secureActivityDelegate.onCreate()
launchNow { SettingsSearchHelper.initPreferenceSearchResultCollection(this@BaseActivity) }
}
override fun onResume() {

View File

@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.ui.download.DownloadController
import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
import eu.kanade.tachiyomi.ui.setting.settingssearch.SettingsSearchController
import eu.kanade.tachiyomi.ui.setting.settingssearch.SettingsSearchHelper
import eu.kanade.tachiyomi.util.preference.add
import eu.kanade.tachiyomi.util.preference.iconRes
import eu.kanade.tachiyomi.util.preference.iconTint
@ -49,7 +48,6 @@ class MoreController :
private var downloadQueueSize: Int = 0
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
SettingsSearchHelper.initPreferenceSearchResultCollection(context, preferenceManager)
titleRes = R.string.label_more
val tintColor = context.getResourceColor(R.attr.colorAccent)

View File

@ -7,7 +7,6 @@ import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.setting.settingssearch.SettingsSearchController
import eu.kanade.tachiyomi.ui.setting.settingssearch.SettingsSearchHelper
import eu.kanade.tachiyomi.util.preference.iconRes
import eu.kanade.tachiyomi.util.preference.iconTint
import eu.kanade.tachiyomi.util.preference.onClick
@ -23,8 +22,6 @@ import reactivecircus.flowbinding.appcompat.queryTextEvents
class SettingsMainController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
SettingsSearchHelper.initPreferenceSearchResultCollection(context, preferenceManager)
titleRes = R.string.label_settings
val tintColor = context.getResourceColor(R.attr.colorAccent)

View File

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.ui.setting.settingssearch
import android.annotation.SuppressLint
import android.content.Context
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
@ -48,7 +49,10 @@ object SettingsSearchHelper {
/**
* Must be called to populate `prefSearchResultList`
*/
fun initPreferenceSearchResultCollection(context: Context, preferenceManager: PreferenceManager) {
@SuppressLint("RestrictedApi")
fun initPreferenceSearchResultCollection(context: Context) {
val preferenceManager = PreferenceManager(context)
prefSearchResultList.clear()
settingControllersList.forEach { kClass ->