|
|
|
@ -58,6 +58,7 @@ class DownloadService : BaseService() { |
|
|
|
|
intent.getIntExtra("start", 0), |
|
|
|
|
intent.getIntExtra("end", 0) |
|
|
|
|
) |
|
|
|
|
IntentAction.remove -> removeDownload(intent.getStringExtra("bookUrl")) |
|
|
|
|
IntentAction.stop -> stopDownload() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -91,6 +92,11 @@ class DownloadService : BaseService() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun removeDownload(bookUrl: String?) { |
|
|
|
|
downloadMap.remove(bookUrl) |
|
|
|
|
finalMap.remove(bookUrl) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun download() { |
|
|
|
|
val task = Coroutine.async(this, context = searchPool) { |
|
|
|
|
downloadMap.forEach { entry -> |
|
|
|
@ -102,8 +108,14 @@ class DownloadService : BaseService() { |
|
|
|
|
val webBook = WebBook(bookSource) |
|
|
|
|
entry.value.forEach { chapter -> |
|
|
|
|
if (!isActive) return@async |
|
|
|
|
if (downloadMap.containsKey(book.bookUrl)) { |
|
|
|
|
if (!BookHelp.hasContent(book, chapter)) { |
|
|
|
|
webBook.getContent(book, chapter, scope = this, context = searchPool) |
|
|
|
|
webBook.getContent( |
|
|
|
|
book, |
|
|
|
|
chapter, |
|
|
|
|
scope = this, |
|
|
|
|
context = searchPool |
|
|
|
|
) |
|
|
|
|
.onStart { |
|
|
|
|
notificationContent = chapter.title |
|
|
|
|
} |
|
|
|
@ -129,6 +141,7 @@ class DownloadService : BaseService() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|