BaseFragment

pull/32/head
Invinciblelee 6 years ago
parent 7e05769497
commit d7dfb099a5
  1. 2
      app/src/main/java/io/legado/app/base/BaseFragment.kt
  2. 13
      app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt

@ -21,8 +21,8 @@ abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId
supportToolbar = toolbar supportToolbar = toolbar
supportToolbar?.let { supportToolbar?.let {
it.menu.apply { it.menu.apply {
setIconColor(requireContext())
onCompatCreateOptionsMenu(this) onCompatCreateOptionsMenu(this)
setIconColor(requireContext())
} }
it.setOnMenuItemClickListener { item -> it.setOnMenuItemClickListener { item ->

@ -3,13 +3,16 @@ package io.legado.app.ui.main.myconfig
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem
import android.view.View import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseFragment import io.legado.app.base.BaseFragment
import io.legado.app.ui.config.ConfigActivity 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.search.SearchActivity
import kotlinx.android.synthetic.main.fragment_my_config.* import kotlinx.android.synthetic.main.fragment_my_config.*
import kotlinx.android.synthetic.main.view_titlebar.* import kotlinx.android.synthetic.main.view_titlebar.*
import org.jetbrains.anko.startActivity
class MyConfigFragment : BaseFragment(R.layout.fragment_my_config) { class MyConfigFragment : BaseFragment(R.layout.fragment_my_config) {
@ -17,13 +20,17 @@ class MyConfigFragment : BaseFragment(R.layout.fragment_my_config) {
setSupportToolbar(toolbar) setSupportToolbar(toolbar)
tv_theme_config.setOnClickListener { tv_theme_config.setOnClickListener {
val intent = Intent(context, ConfigActivity::class.java) requireContext().startActivity<ConfigActivity>(Pair("configType", ConfigViewModel.TYPE_THEME_CONFIG))
intent.putExtra("configType", ConfigViewModel.TYPE_THEME_CONFIG)
startActivity(intent)
} }
} }
override fun onCompatCreateOptionsMenu(menu: Menu) { override fun onCompatCreateOptionsMenu(menu: Menu) {
menuInflater.inflate(R.menu.my_config, menu) menuInflater.inflate(R.menu.my_config, menu)
} }
override fun onCompatOptionsItemSelected(item: MenuItem) {
when (item.itemId) {
R.id.action_settings -> requireContext().startActivity<SearchActivity>()
}
}
} }
Loading…
Cancel
Save