|
|
|
@ -98,9 +98,7 @@ object AudioPlay { |
|
|
|
|
durChapterIndex = index |
|
|
|
|
durChapterPos = 0 |
|
|
|
|
durChapter = null |
|
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
|
|
book.durChapterPos = 0 |
|
|
|
|
saveRead() |
|
|
|
|
saveRead(book) |
|
|
|
|
play(context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -115,16 +113,13 @@ object AudioPlay { |
|
|
|
|
durChapterIndex-- |
|
|
|
|
durChapterPos = 0 |
|
|
|
|
durChapter = null |
|
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
|
|
book.durChapterPos = 0 |
|
|
|
|
saveRead() |
|
|
|
|
saveRead(book) |
|
|
|
|
play(context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun next(context: Context) { |
|
|
|
|
Coroutine.async { |
|
|
|
|
book?.let { book -> |
|
|
|
|
if (book.durChapterIndex >= book.totalChapterNum) { |
|
|
|
|
return@let |
|
|
|
@ -132,13 +127,10 @@ object AudioPlay { |
|
|
|
|
durChapterIndex++ |
|
|
|
|
durChapterPos = 0 |
|
|
|
|
durChapter = null |
|
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
|
|
book.durChapterPos = 0 |
|
|
|
|
saveRead() |
|
|
|
|
saveRead(book) |
|
|
|
|
play(context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun addTimer(context: Context) { |
|
|
|
|
val intent = Intent(context, AudioPlayService::class.java) |
|
|
|
@ -146,18 +138,16 @@ object AudioPlay { |
|
|
|
|
context.startService(intent) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun saveRead() { |
|
|
|
|
Coroutine.async { |
|
|
|
|
book?.let { book -> |
|
|
|
|
fun saveRead(book: Book) { |
|
|
|
|
book.lastCheckCount = 0 |
|
|
|
|
book.durChapterTime = System.currentTimeMillis() |
|
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
|
|
book.durChapterPos = durChapterPos |
|
|
|
|
Coroutine.async { |
|
|
|
|
appDb.bookChapterDao.getChapter(book.bookUrl, book.durChapterIndex)?.let { |
|
|
|
|
book.durChapterTitle = it.title |
|
|
|
|
} |
|
|
|
|
appDb.bookDao.update(book) |
|
|
|
|
} |
|
|
|
|
book.save() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|