From d79d93e5358c5d8e5cce40e3cfa6585ca9420581 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 3 Dec 2019 15:32:12 +0800 Subject: [PATCH] up --- .../java/io/legado/app/service/AudioPlayService.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index b46647f28..32af89cf9 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -30,7 +30,9 @@ import io.legado.app.service.help.AudioPlay import io.legado.app.ui.audio.AudioPlayActivity import io.legado.app.utils.postEvent import kotlinx.coroutines.Dispatchers.IO +import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import org.jetbrains.anko.toast @@ -256,10 +258,7 @@ class AudioPlayService : BaseService(), postEvent(Bus.AUDIO_SIZE, chapter.end?.toInt() ?: 0) postEvent(Bus.AUDIO_PROGRESS, position) } - BookHelp.getContent(book, chapter)?.let { - contentLoadFinish(chapter, it) - removeLoading(chapter.index) - } ?: download(chapter) + download(chapter) } ?: removeLoading(index) } } @@ -271,7 +270,9 @@ class AudioPlayService : BaseService(), AudioPlay.webBook?.getContent(book, chapter, scope = this) ?.onSuccess(IO) { content -> if (content.isNullOrEmpty()) { - contentLoadFinish(chapter, getString(R.string.content_empty)) + withContext(Main) { + toast("未获取到资源链接") + } removeLoading(chapter.index) } else { BookHelp.saveContent(book, chapter, content) @@ -307,7 +308,6 @@ class AudioPlayService : BaseService(), subtitle = chapter.title url = content play() - loadContent(AudioPlay.durChapterIndex + 1) } }