From 5ea88df3c5d55d24683b8e5b10e63d256acc4643 Mon Sep 17 00:00:00 2001 From: GKF Date: Wed, 12 Jun 2019 10:29:01 +0800 Subject: [PATCH] up --- .../ui/main/myconfig/PreferenceFragment.kt | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt b/app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt index d3f862d20..98b399c1c 100644 --- a/app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt @@ -7,11 +7,13 @@ import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.ui.about.AboutActivity +import io.legado.app.ui.about.DonateActivity import io.legado.app.ui.config.ConfigActivity import io.legado.app.ui.config.ConfigViewModel import org.jetbrains.anko.startActivity -class PreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { +class PreferenceFragment : PreferenceFragmentCompat(), + SharedPreferences.OnSharedPreferenceChangeListener { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.pref_main) @@ -38,22 +40,18 @@ class PreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnShare override fun onPreferenceTreeClick(preference: Preference?): Boolean { preference?.let { when (preference.key) { - "setting" -> { - requireContext().startActivity( - Pair("configType", ConfigViewModel.TYPE_CONFIG) - ) - } - "web_dav_setting" -> { - requireContext().startActivity( - Pair("configType", ConfigViewModel.TYPE_WEB_DAV_CONFIG) - ) - } - "theme_setting" -> { - requireContext().startActivity( - Pair("configType", ConfigViewModel.TYPE_THEME_CONFIG) - ) - } - "about" -> requireContext().startActivity() + "setting" -> context?.startActivity( + Pair("configType", ConfigViewModel.TYPE_CONFIG) + ) + "web_dav_setting" -> context?.startActivity( + Pair("configType", ConfigViewModel.TYPE_WEB_DAV_CONFIG) + ) + "theme_setting" -> context?.startActivity( + Pair("configType", ConfigViewModel.TYPE_THEME_CONFIG) + ) + "donate" -> context?.startActivity() + "about" -> context?.startActivity() + else -> null } } return super.onPreferenceTreeClick(preference)