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