Skip to content

Commit

Permalink
Fixed: The progress the not tracked when we resume the downloads.
Browse files Browse the repository at this point in the history
  • Loading branch information
MohitMaliDeveloper committed Dec 20, 2024
1 parent b4ba2ed commit 0f16730
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import com.tonyodev.fetch2.Download
import com.tonyodev.fetch2.Error
import com.tonyodev.fetch2.Fetch
import com.tonyodev.fetch2.FetchListener
import com.tonyodev.fetch2.Status
import com.tonyodev.fetch2core.DownloadBlock
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
import org.kiwix.kiwixmobile.core.CoreApp
import org.kiwix.kiwixmobile.core.dao.DownloadRoomDao
import org.kiwix.kiwixmobile.core.dao.entities.DownloadRoomEntity
import org.kiwix.kiwixmobile.core.utils.files.Log
import java.util.concurrent.TimeUnit
import javax.inject.Inject
Expand Down Expand Up @@ -72,8 +70,10 @@ class DownloadMonitorService : Service() {
{
try {
synchronized(lock) {
if (getActiveDownloads().isEmpty()) {
stopForegroundServiceForDownloads()
fetch.hasActiveDownloads(includeAddedDownloads = true) {
if (!it) {
stopForegroundServiceForDownloads()
}
}
}
} catch (ignore: Exception) {
Expand All @@ -87,9 +87,6 @@ class DownloadMonitorService : Service() {
)
}

private fun getActiveDownloads(): List<DownloadRoomEntity> =
downloadRoomDao.downloadRoomEntity().blockingFirst().filter { it.status != Status.PAUSED }

private fun setupUpdater() {
updaterDisposable = updater.subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(
{ it.invoke() },
Expand Down

0 comments on commit 0f16730

Please sign in to comment.