mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-24 13:48:55 +03:00
Merge pull request #2 from lmj0011/dev-settings-search
initialize SearchResultCollection once in Activity.onCreate
This commit is contained in:
commit
d7cfe1990c
4 changed files with 9 additions and 6 deletions
|
@ -10,6 +10,8 @@ import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
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 eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
|
@ -76,6 +78,8 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
secureActivityDelegate.onCreate()
|
secureActivityDelegate.onCreate()
|
||||||
|
|
||||||
|
launchNow { SettingsSearchHelper.initPreferenceSearchResultCollection(this@BaseActivity) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.ui.download.DownloadController
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||||
import eu.kanade.tachiyomi.ui.setting.settingssearch.SettingsSearchController
|
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.add
|
||||||
import eu.kanade.tachiyomi.util.preference.iconRes
|
import eu.kanade.tachiyomi.util.preference.iconRes
|
||||||
import eu.kanade.tachiyomi.util.preference.iconTint
|
import eu.kanade.tachiyomi.util.preference.iconTint
|
||||||
|
@ -49,7 +48,6 @@ class MoreController :
|
||||||
private var downloadQueueSize: Int = 0
|
private var downloadQueueSize: Int = 0
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||||
SettingsSearchHelper.initPreferenceSearchResultCollection(context, preferenceManager)
|
|
||||||
titleRes = R.string.label_more
|
titleRes = R.string.label_more
|
||||||
|
|
||||||
val tintColor = context.getResourceColor(R.attr.colorAccent)
|
val tintColor = context.getResourceColor(R.attr.colorAccent)
|
||||||
|
|
|
@ -7,7 +7,6 @@ import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.setting.settingssearch.SettingsSearchController
|
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.iconRes
|
||||||
import eu.kanade.tachiyomi.util.preference.iconTint
|
import eu.kanade.tachiyomi.util.preference.iconTint
|
||||||
import eu.kanade.tachiyomi.util.preference.onClick
|
import eu.kanade.tachiyomi.util.preference.onClick
|
||||||
|
@ -23,8 +22,6 @@ import reactivecircus.flowbinding.appcompat.queryTextEvents
|
||||||
class SettingsMainController : SettingsController() {
|
class SettingsMainController : SettingsController() {
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||||
SettingsSearchHelper.initPreferenceSearchResultCollection(context, preferenceManager)
|
|
||||||
|
|
||||||
titleRes = R.string.label_settings
|
titleRes = R.string.label_settings
|
||||||
|
|
||||||
val tintColor = context.getResourceColor(R.attr.colorAccent)
|
val tintColor = context.getResourceColor(R.attr.colorAccent)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.ui.setting.settingssearch
|
package eu.kanade.tachiyomi.ui.setting.settingssearch
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceCategory
|
import androidx.preference.PreferenceCategory
|
||||||
|
@ -48,7 +49,10 @@ object SettingsSearchHelper {
|
||||||
/**
|
/**
|
||||||
* Must be called to populate `prefSearchResultList`
|
* Must be called to populate `prefSearchResultList`
|
||||||
*/
|
*/
|
||||||
fun initPreferenceSearchResultCollection(context: Context, preferenceManager: PreferenceManager) {
|
@SuppressLint("RestrictedApi")
|
||||||
|
fun initPreferenceSearchResultCollection(context: Context) {
|
||||||
|
val preferenceManager = PreferenceManager(context)
|
||||||
|
|
||||||
prefSearchResultList.clear()
|
prefSearchResultList.clear()
|
||||||
|
|
||||||
settingControllersList.forEach { kClass ->
|
settingControllersList.forEach { kClass ->
|
||||||
|
|
Loading…
Reference in a new issue