mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-12 17:08:59 -04:00
Fixed: The progress the not tracked when we resume the downloads.
This commit is contained in:
parent
b4ba2ed848
commit
0f16730120
@ -25,7 +25,6 @@ import com.tonyodev.fetch2.Download
|
|||||||
import com.tonyodev.fetch2.Error
|
import com.tonyodev.fetch2.Error
|
||||||
import com.tonyodev.fetch2.Fetch
|
import com.tonyodev.fetch2.Fetch
|
||||||
import com.tonyodev.fetch2.FetchListener
|
import com.tonyodev.fetch2.FetchListener
|
||||||
import com.tonyodev.fetch2.Status
|
|
||||||
import com.tonyodev.fetch2core.DownloadBlock
|
import com.tonyodev.fetch2core.DownloadBlock
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
@ -33,7 +32,6 @@ import io.reactivex.schedulers.Schedulers
|
|||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import org.kiwix.kiwixmobile.core.CoreApp
|
import org.kiwix.kiwixmobile.core.CoreApp
|
||||||
import org.kiwix.kiwixmobile.core.dao.DownloadRoomDao
|
import org.kiwix.kiwixmobile.core.dao.DownloadRoomDao
|
||||||
import org.kiwix.kiwixmobile.core.dao.entities.DownloadRoomEntity
|
|
||||||
import org.kiwix.kiwixmobile.core.utils.files.Log
|
import org.kiwix.kiwixmobile.core.utils.files.Log
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -72,8 +70,10 @@ class DownloadMonitorService : Service() {
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
if (getActiveDownloads().isEmpty()) {
|
fetch.hasActiveDownloads(includeAddedDownloads = true) {
|
||||||
stopForegroundServiceForDownloads()
|
if (!it) {
|
||||||
|
stopForegroundServiceForDownloads()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ignore: Exception) {
|
} catch (ignore: Exception) {
|
||||||
@ -87,9 +87,6 @@ class DownloadMonitorService : Service() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getActiveDownloads(): List<DownloadRoomEntity> =
|
|
||||||
downloadRoomDao.downloadRoomEntity().blockingFirst().filter { it.status != Status.PAUSED }
|
|
||||||
|
|
||||||
private fun setupUpdater() {
|
private fun setupUpdater() {
|
||||||
updaterDisposable = updater.subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(
|
updaterDisposable = updater.subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(
|
||||||
{ it.invoke() },
|
{ it.invoke() },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user