|
|
@ -19,6 +19,7 @@ import io.legado.app.utils.msg |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import kotlinx.coroutines.Job |
|
|
|
import kotlinx.coroutines.Job |
|
|
|
import kotlinx.coroutines.delay |
|
|
|
import kotlinx.coroutines.delay |
|
|
|
|
|
|
|
import kotlinx.coroutines.isActive |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import splitties.systemservices.downloadManager |
|
|
|
import splitties.systemservices.downloadManager |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
@ -77,10 +78,12 @@ class DownloadService : BaseService() { |
|
|
|
private fun checkDownloadState() { |
|
|
|
private fun checkDownloadState() { |
|
|
|
upStateJob?.cancel() |
|
|
|
upStateJob?.cancel() |
|
|
|
upStateJob = launch { |
|
|
|
upStateJob = launch { |
|
|
|
|
|
|
|
while (isActive) { |
|
|
|
queryState() |
|
|
|
queryState() |
|
|
|
delay(1000) |
|
|
|
delay(1000) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//查询下载进度 |
|
|
|
//查询下载进度 |
|
|
|
private fun queryState() { |
|
|
|
private fun queryState() { |
|
|
|