优化
This commit is contained in:
@@ -114,28 +114,30 @@ object AudioPlay {
|
|||||||
fun prev(context: Context) {
|
fun prev(context: Context) {
|
||||||
Coroutine.async {
|
Coroutine.async {
|
||||||
book?.let { book ->
|
book?.let { book ->
|
||||||
if (book.durChapterIndex <= 0) {
|
if (book.durChapterIndex > 0) {
|
||||||
return@let
|
book.durChapterIndex = book.durChapterIndex - 1
|
||||||
|
book.durChapterPos = 0
|
||||||
|
durChapter = null
|
||||||
|
saveRead()
|
||||||
|
play(context)
|
||||||
|
} else {
|
||||||
|
stop(context)
|
||||||
}
|
}
|
||||||
book.durChapterIndex = book.durChapterIndex - 1
|
|
||||||
book.durChapterPos = 0
|
|
||||||
durChapter = null
|
|
||||||
saveRead()
|
|
||||||
play(context)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun next(context: Context) {
|
fun next(context: Context) {
|
||||||
book?.let { book ->
|
book?.let { book ->
|
||||||
if (book.durChapterIndex >= book.totalChapterNum) {
|
if (book.durChapterIndex + 1 < book.totalChapterNum) {
|
||||||
return@let
|
book.durChapterIndex = book.durChapterIndex + 1
|
||||||
|
book.durChapterPos = 0
|
||||||
|
durChapter = null
|
||||||
|
saveRead()
|
||||||
|
play(context)
|
||||||
|
} else {
|
||||||
|
stop(context)
|
||||||
}
|
}
|
||||||
book.durChapterIndex = book.durChapterIndex + 1
|
|
||||||
book.durChapterPos = 0
|
|
||||||
durChapter = null
|
|
||||||
saveRead()
|
|
||||||
play(context)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -269,6 +269,10 @@ class AudioPlayActivity :
|
|||||||
}
|
}
|
||||||
observeEventSticky<String>(EventBus.AUDIO_SUB_TITLE) {
|
observeEventSticky<String>(EventBus.AUDIO_SUB_TITLE) {
|
||||||
binding.tvSubTitle.text = it
|
binding.tvSubTitle.text = it
|
||||||
|
AudioPlay.book?.let { book ->
|
||||||
|
binding.ivSkipPrevious.isEnabled = book.durChapterIndex > 0
|
||||||
|
binding.ivSkipNext.isEnabled = book.durChapterIndex < book.totalChapterNum - 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
observeEventSticky<Int>(EventBus.AUDIO_SIZE) {
|
observeEventSticky<Int>(EventBus.AUDIO_SIZE) {
|
||||||
binding.playerProgress.max = it
|
binding.playerProgress.max = it
|
||||||
|
|||||||
Reference in New Issue
Block a user