pull/52/head
kunfei 5 years ago
parent a9221654f6
commit d79d93e535
  1. 12
      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.ui.audio.AudioPlayActivity
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
@ -256,10 +258,7 @@ class AudioPlayService : BaseService(),
postEvent(Bus.AUDIO_SIZE, chapter.end?.toInt() ?: 0) postEvent(Bus.AUDIO_SIZE, chapter.end?.toInt() ?: 0)
postEvent(Bus.AUDIO_PROGRESS, position) postEvent(Bus.AUDIO_PROGRESS, position)
} }
BookHelp.getContent(book, chapter)?.let { download(chapter)
contentLoadFinish(chapter, it)
removeLoading(chapter.index)
} ?: download(chapter)
} ?: removeLoading(index) } ?: removeLoading(index)
} }
} }
@ -271,7 +270,9 @@ class AudioPlayService : BaseService(),
AudioPlay.webBook?.getContent(book, chapter, scope = this) AudioPlay.webBook?.getContent(book, chapter, scope = this)
?.onSuccess(IO) { content -> ?.onSuccess(IO) { content ->
if (content.isNullOrEmpty()) { if (content.isNullOrEmpty()) {
contentLoadFinish(chapter, getString(R.string.content_empty)) withContext(Main) {
toast("未获取到资源链接")
}
removeLoading(chapter.index) removeLoading(chapter.index)
} else { } else {
BookHelp.saveContent(book, chapter, content) BookHelp.saveContent(book, chapter, content)
@ -307,7 +308,6 @@ class AudioPlayService : BaseService(),
subtitle = chapter.title subtitle = chapter.title
url = content url = content
play() play()
loadContent(AudioPlay.durChapterIndex + 1)
} }
} }

Loading…
Cancel
Save