pull/1352/head
gedoor 3 years ago
parent 813f45dc05
commit 1d04dea4ac
  1. 16
      app/src/main/java/io/legado/app/service/DownloadService.kt

@ -146,14 +146,16 @@ class DownloadService : BaseService() {
query.setFilterById(*ids.toLongArray()) query.setFilterById(*ids.toLongArray())
downloadManager.query(query).use { cursor -> downloadManager.query(query).use { cursor ->
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
val idIndex = cursor.getColumnIndex(DownloadManager.COLUMN_ID)
val progressIndex =
cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)
val fileSizeIndex = cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)
val statusIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)
do { do {
val id = cursor.getLong(cursor.getColumnIndex(DownloadManager.COLUMN_ID)) val id = cursor.getLong(idIndex)
val progress = cursor val progress = cursor.getInt(progressIndex)
.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)) val max = cursor.getInt(fileSizeIndex)
val max = cursor val status = when (cursor.getInt(statusIndex)) {
.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))
val status =
when (cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS))) {
DownloadManager.STATUS_PAUSED -> getString(R.string.pause) DownloadManager.STATUS_PAUSED -> getString(R.string.pause)
DownloadManager.STATUS_PENDING -> getString(R.string.wait_download) DownloadManager.STATUS_PENDING -> getString(R.string.wait_download)
DownloadManager.STATUS_RUNNING -> getString(R.string.downloading) DownloadManager.STATUS_RUNNING -> getString(R.string.downloading)

Loading…
Cancel
Save