mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 17:05:07 +01:00
Download from up to 5 different sources concurrently
This commit is contained in:
parent
f2fe1a7c23
commit
28cbbc3f14
@ -197,14 +197,28 @@ class Downloader(
|
|||||||
subscriptions.clear()
|
subscriptions.clear()
|
||||||
|
|
||||||
subscriptions += downloadsRelay.concatMapIterable { it }
|
subscriptions += downloadsRelay.concatMapIterable { it }
|
||||||
.concatMap { downloadChapter(it).subscribeOn(Schedulers.io()) }.onBackpressureBuffer()
|
// Concurrently download from 5 different sources
|
||||||
.observeOn(AndroidSchedulers.mainThread()).subscribe({
|
.groupBy { it.source }
|
||||||
|
.flatMap(
|
||||||
|
{ bySource ->
|
||||||
|
bySource.concatMap { download ->
|
||||||
|
downloadChapter(download).subscribeOn(Schedulers.io())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
5
|
||||||
|
)
|
||||||
|
.onBackpressureBuffer()
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(
|
||||||
|
{
|
||||||
completeDownload(it)
|
completeDownload(it)
|
||||||
}, { error ->
|
},
|
||||||
|
{ error ->
|
||||||
DownloadService.stop(context)
|
DownloadService.stop(context)
|
||||||
Timber.e(error)
|
Timber.e(error)
|
||||||
notifier.onError(error.message)
|
notifier.onError(error.message)
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user