mirror of
https://github.com/NeoApplications/Neo-Store.git
synced 2025-03-14 10:17:08 +00:00
Fix: Crash on stopping download
This commit is contained in:
@ -18,7 +18,6 @@ import androidx.work.WorkerParameters
|
|||||||
import androidx.work.workDataOf
|
import androidx.work.workDataOf
|
||||||
import com.anggrayudi.storage.file.children
|
import com.anggrayudi.storage.file.children
|
||||||
import com.anggrayudi.storage.file.toDocumentFile
|
import com.anggrayudi.storage.file.toDocumentFile
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
|
||||||
import com.machiav3lli.fdroid.ARG_AUTHENTICATION
|
import com.machiav3lli.fdroid.ARG_AUTHENTICATION
|
||||||
import com.machiav3lli.fdroid.ARG_NAME
|
import com.machiav3lli.fdroid.ARG_NAME
|
||||||
import com.machiav3lli.fdroid.ARG_PACKAGE_NAME
|
import com.machiav3lli.fdroid.ARG_PACKAGE_NAME
|
||||||
@ -90,7 +89,7 @@ class DownloadWorker(
|
|||||||
|
|
||||||
val callback: suspend (read: Long, total: Long?, downloadID: Long) -> Unit =
|
val callback: suspend (read: Long, total: Long?, downloadID: Long) -> Unit =
|
||||||
{ read, total, downloadID ->
|
{ read, total, downloadID ->
|
||||||
setProgress(
|
setProgressData(
|
||||||
workDataOf(
|
workDataOf(
|
||||||
ARG_PROGRESS to if (total != null) (100f * read / total).roundToInt() else -1,
|
ARG_PROGRESS to if (total != null) (100f * read / total).roundToInt() else -1,
|
||||||
ARG_READ to read,
|
ARG_READ to read,
|
||||||
@ -161,8 +160,8 @@ class DownloadWorker(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setProgressAsync(data: Data): ListenableFuture<Void> {
|
fun setProgressData(data: Data) {
|
||||||
return super.setProgressAsync(
|
setProgressAsync(
|
||||||
Data.Builder()
|
Data.Builder()
|
||||||
.putAll(data)
|
.putAll(data)
|
||||||
.putLong(ARG_STARTED, task.started)
|
.putLong(ARG_STARTED, task.started)
|
||||||
|
@ -120,6 +120,7 @@ class InstallWorker(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO replace with setProgressData and make use of it
|
||||||
override fun setProgressAsync(data: Data): ListenableFuture<Void> {
|
override fun setProgressAsync(data: Data): ListenableFuture<Void> {
|
||||||
return super.setProgressAsync(
|
return super.setProgressAsync(
|
||||||
Data.Builder()
|
Data.Builder()
|
||||||
|
Reference in New Issue
Block a user