feat: 优化代码

pull/133/head
kunfei 5 years ago
parent 33ab365bfa
commit 9298638ead
  1. 9
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt

@ -23,6 +23,7 @@ import io.legado.app.ui.config.ConfigActivity
import io.legado.app.ui.config.ConfigViewModel import io.legado.app.ui.config.ConfigViewModel
import io.legado.app.ui.filechooser.FileChooserDialog import io.legado.app.ui.filechooser.FileChooserDialog
import io.legado.app.ui.replacerule.ReplaceRuleActivity import io.legado.app.ui.replacerule.ReplaceRuleActivity
import io.legado.app.ui.widget.prefs.NameListPreference
import io.legado.app.ui.widget.prefs.SwitchPreference import io.legado.app.ui.widget.prefs.SwitchPreference
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.android.synthetic.main.view_title_bar.* import kotlinx.android.synthetic.main.view_title_bar.*
@ -74,6 +75,13 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
observeEvent<Boolean>(EventBus.WEB_SERVICE_STOP) { observeEvent<Boolean>(EventBus.WEB_SERVICE_STOP) {
webServicePre?.isChecked = false webServicePre?.isChecked = false
} }
findPreference<NameListPreference>(PreferKey.themeMode)?.let {
it.setOnPreferenceChangeListener { _, newValue ->
App.INSTANCE.putPrefString(PreferKey.themeMode, newValue.toString())
App.INSTANCE.applyDayNight()
true
}
}
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -96,7 +104,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
key: String? key: String?
) { ) {
when (key) { when (key) {
PreferKey.themeMode -> App.INSTANCE.applyDayNight()
PreferKey.webService -> { PreferKey.webService -> {
if (requireContext().getPrefBoolean("webService")) { if (requireContext().getPrefBoolean("webService")) {
WebService.start(requireContext()) WebService.start(requireContext())

Loading…
Cancel
Save