Skip to content

Commit

Permalink
Bug fix for priority queue
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyofrancis committed Apr 30, 2018
1 parent c692c0e commit 8e6f7b9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ class PriorityListProcessorImpl constructor(private val handler: Handler,

private val priorityIteratorRunnable = Runnable {
if (canContinueToProcess()) {
if (networkInfoProvider.isNetworkAvailable) {
if (networkInfoProvider.isNetworkAvailable && downloadManager.canAccommodateNewDownload()) {
val priorityList = getPriorityList()
for (index in 0..priorityList.lastIndex) {
if (downloadManager.canAccommodateNewDownload() && canContinueToProcess()) {
if (canContinueToProcess()) {
val download = priorityList[index]
val networkType = when {
globalNetworkType != NetworkType.GLOBAL_OFF -> globalNetworkType
download.networkType == NetworkType.GLOBAL_OFF -> NetworkType.ALL
else -> download.networkType
}
if (networkInfoProvider.isOnAllowedNetwork(networkType) && canContinueToProcess()) {
if (networkInfoProvider.isOnAllowedNetwork(networkType) && canContinueToProcess()
&& !downloadManager.contains(download.id)) {
downloadManager.start(download)
}
} else {
Expand Down

0 comments on commit 8e6f7b9

Please sign in to comment.