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())
downloadManager.query(query).use { cursor ->
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 {
val id = cursor.getLong(cursor.getColumnIndex(DownloadManager.COLUMN_ID))
val progress = cursor
.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR))
val max = cursor
.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))
val status =
when (cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS))) {
val id = cursor.getLong(idIndex)
val progress = cursor.getInt(progressIndex)
val max = cursor.getInt(fileSizeIndex)
val status = when (cursor.getInt(statusIndex)) {
DownloadManager.STATUS_PAUSED -> getString(R.string.pause)
DownloadManager.STATUS_PENDING -> getString(R.string.wait_download)
DownloadManager.STATUS_RUNNING -> getString(R.string.downloading)

Loading…
Cancel
Save