diff --git a/app/src/main/java/io/legado/app/base/BaseFragment.kt b/app/src/main/java/io/legado/app/base/BaseFragment.kt index 651bfb830..22a86adb0 100644 --- a/app/src/main/java/io/legado/app/base/BaseFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseFragment.kt @@ -21,8 +21,8 @@ abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId supportToolbar = toolbar supportToolbar?.let { it.menu.apply { - setIconColor(requireContext()) onCompatCreateOptionsMenu(this) + setIconColor(requireContext()) } it.setOnMenuItemClickListener { item -> diff --git a/app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt b/app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt index 4852bf066..5fa49bdb4 100644 --- a/app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt @@ -3,13 +3,16 @@ package io.legado.app.ui.main.myconfig import android.content.Intent import android.os.Bundle import android.view.Menu +import android.view.MenuItem import android.view.View import io.legado.app.R import io.legado.app.base.BaseFragment import io.legado.app.ui.config.ConfigActivity import io.legado.app.ui.config.ConfigViewModel +import io.legado.app.ui.search.SearchActivity import kotlinx.android.synthetic.main.fragment_my_config.* import kotlinx.android.synthetic.main.view_titlebar.* +import org.jetbrains.anko.startActivity class MyConfigFragment : BaseFragment(R.layout.fragment_my_config) { @@ -17,13 +20,17 @@ class MyConfigFragment : BaseFragment(R.layout.fragment_my_config) { setSupportToolbar(toolbar) tv_theme_config.setOnClickListener { - val intent = Intent(context, ConfigActivity::class.java) - intent.putExtra("configType", ConfigViewModel.TYPE_THEME_CONFIG) - startActivity(intent) + requireContext().startActivity(Pair("configType", ConfigViewModel.TYPE_THEME_CONFIG)) } } override fun onCompatCreateOptionsMenu(menu: Menu) { menuInflater.inflate(R.menu.my_config, menu) } + + override fun onCompatOptionsItemSelected(item: MenuItem) { + when (item.itemId) { + R.id.action_settings -> requireContext().startActivity() + } + } } \ No newline at end of file