修复下载进度问题

pull/300/head
gedoor 4 years ago
parent c06deb1e59
commit 645319e5a1
  1. 1
      app/src/main/java/io/legado/app/service/DownloadService.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/download/DownloadAdapter.kt

@ -275,7 +275,6 @@ class DownloadService : BaseService() {
startForeground(AppConst.notificationIdDownload, notification)
}
class DownloadCount {
@Volatile
var downloadFinishedCount = 0 // 下载完成的条目数量

@ -30,6 +30,8 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.toast
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArraySet
class DownloadActivity : VMBaseActivity<DownloadViewModel>(R.layout.activity_download),
@ -172,7 +174,7 @@ class DownloadActivity : VMBaseActivity<DownloadViewModel>(R.layout.activity_dow
}
override fun observeLiveBus() {
observeEvent<HashMap<String, LinkedHashSet<BookChapter>>>(EventBus.UP_DOWNLOAD) {
observeEvent<ConcurrentHashMap<String, CopyOnWriteArraySet<BookChapter>>>(EventBus.UP_DOWNLOAD) {
if (it.isEmpty()) {
menu?.findItem(R.id.menu_download)?.setIcon(R.drawable.ic_play_24dp)
menu?.applyTint(this)

@ -10,13 +10,15 @@ import io.legado.app.data.entities.BookChapter
import io.legado.app.service.help.Download
import kotlinx.android.synthetic.main.item_download.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArraySet
class DownloadAdapter(context: Context, private val callBack: CallBack) :
SimpleRecyclerAdapter<Book>(context, R.layout.item_download) {
val cacheChapters = hashMapOf<String, HashSet<String>>()
var downloadMap: HashMap<String, LinkedHashSet<BookChapter>>? = null
var downloadMap: ConcurrentHashMap<String, CopyOnWriteArraySet<BookChapter>>? = null
override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) {
with(holder.itemView) {

Loading…
Cancel
Save