mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
216de91ce0
commit
078a42d0d8
@ -141,7 +141,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
private var autoPageJob: Job? = null
|
||||
private var backupJob: Job? = null
|
||||
private var keepScreenJon: Job? = null
|
||||
private val tts by lazy { TTS() }
|
||||
private var tts: TTS? = null
|
||||
val textActionMenu: TextActionMenu by lazy {
|
||||
TextActionMenu(this, this)
|
||||
}
|
||||
@ -633,7 +633,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
when (itemId) {
|
||||
R.id.menu_aloud -> when (AppConfig.contentSelectSpeakMod) {
|
||||
1 -> binding.readView.aloudStartSelect()
|
||||
else -> tts.speak(binding.readView.getSelectText())
|
||||
else -> speak(binding.readView.getSelectText())
|
||||
}
|
||||
R.id.menu_bookmark -> binding.readView.curPage.let {
|
||||
val bookmark = it.createBookmark()
|
||||
@ -683,6 +683,13 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
readView.isTextSelected = false
|
||||
}
|
||||
|
||||
private fun speak(text: String) {
|
||||
if (tts == null) {
|
||||
tts = TTS()
|
||||
}
|
||||
tts?.speak(text)
|
||||
}
|
||||
|
||||
/**
|
||||
* 鼠标滚轮翻页
|
||||
*/
|
||||
@ -1196,7 +1203,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
tts.clearTts()
|
||||
tts?.clearTts()
|
||||
textActionMenu.dismiss()
|
||||
popupAction.dismiss()
|
||||
binding.readView.onDestroy()
|
||||
|
Loading…
Reference in New Issue
Block a user