pull/71/head
kunfei 5 years ago
parent 1e3f5ec23b
commit 528c8b42bb
  1. 13
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 11
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -24,6 +24,7 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
get() = getViewModel(ReadRssViewModel::class.java) get() = getViewModel(ReadRssViewModel::class.java)
private var starMenuItem: MenuItem? = null private var starMenuItem: MenuItem? = null
private var ttsMenuItem: MenuItem? = null
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
viewModel.callBack = this viewModel.callBack = this
@ -36,6 +37,7 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.rss_read, menu) menuInflater.inflate(R.menu.rss_read, menu)
starMenuItem = menu.findItem(R.id.menu_rss_star) starMenuItem = menu.findItem(R.id.menu_rss_star)
ttsMenuItem = menu.findItem(R.id.menu_aloud)
upStarMenu() upStarMenu()
return super.onCompatCreateOptionsMenu(menu) return super.onCompatCreateOptionsMenu(menu)
} }
@ -97,6 +99,17 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
DrawableUtils.setTint(starMenuItem?.icon, primaryTextColor) DrawableUtils.setTint(starMenuItem?.icon, primaryTextColor)
} }
override fun upTtsMenu(isPlaying: Boolean) {
if (isPlaying) {
ttsMenuItem?.setIcon(R.drawable.ic_stop_black_24dp)
ttsMenuItem?.setTitle(R.string.aloud_stop)
} else {
ttsMenuItem?.setIcon(R.drawable.ic_volume_up)
ttsMenuItem?.setTitle(R.string.read_aloud)
}
DrawableUtils.setTint(ttsMenuItem?.icon, primaryTextColor)
}
override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean { override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) { when (keyCode) {
KeyEvent.KEYCODE_BACK -> { KeyEvent.KEYCODE_BACK -> {

@ -125,16 +125,11 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
private inner class TTSUtteranceListener : UtteranceProgressListener() { private inner class TTSUtteranceListener : UtteranceProgressListener() {
override fun onStart(s: String) { override fun onStart(s: String) {
callBack?.upTtsMenu(true)
} }
override fun onDone(s: String) { override fun onDone(s: String) {
callBack?.upTtsMenu(false)
}
override fun onRangeStart(utteranceId: String?, start: Int, end: Int, frame: Int) {
super.onRangeStart(utteranceId, start, end, frame)
} }
override fun onError(s: String) { override fun onError(s: String) {
@ -142,7 +137,9 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
} }
} }
interface CallBack { interface CallBack {
fun upStarMenu() fun upStarMenu()
fun upTtsMenu(isPlaying: Boolean)
} }
} }
Loading…
Cancel
Save