project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadService.java
changeset 6461 c476061f0466
parent 6446 a49d01b96185
child 6566 bc1214f66ee4
equal deleted inserted replaced
6459:2ca787ac8fc3 6461:c476061f0466
    17  */
    17  */
    18 
    18 
    19 
    19 
    20 package org.hedgewars.hedgeroid.Downloader;
    20 package org.hedgewars.hedgeroid.Downloader;
    21 
    21 
    22 import java.util.Deque;
       
    23 import java.util.LinkedList;
    22 import java.util.LinkedList;
    24 import java.util.List;
    23 import java.util.List;
    25 
    24 
    26 import org.hedgewars.hedgeroid.R;
    25 import org.hedgewars.hedgeroid.R;
    27 
    26 
    55 	private final Messenger messenger = new Messenger(handler);
    54 	private final Messenger messenger = new Messenger(handler);
    56 
    55 
    57 	private NotificationManager nM;
    56 	private NotificationManager nM;
    58 	private RemoteViews contentView;
    57 	private RemoteViews contentView;
    59 
    58 
    60 	private Deque<DownloadTask> downloadTasks = new LinkedList<DownloadTask>();
    59 	private LinkedList<DownloadTask> downloadTasks = new LinkedList<DownloadTask>();
    61 	private DownloadTask currentTask = null;
    60 	private DownloadTask currentTask = null;
    62 
    61 
    63 	public class DownloadHandler extends Handler{
    62 	public class DownloadHandler extends Handler{
    64 
    63 
    65 		public void handleMessage(Message msg){
    64 		public void handleMessage(Message msg){
   110 		return messenger.getBinder();
   109 		return messenger.getBinder();
   111 	}
   110 	}
   112 
   111 
   113 	private void runNextTask(){
   112 	private void runNextTask(){
   114 		if(asyncExecutor == null){//if (task isnt running right now) ...
   113 		if(asyncExecutor == null){//if (task isnt running right now) ...
   115 			currentTask = downloadTasks.pollFirst();
   114 			currentTask = downloadTasks.poll();
   116 			if(currentTask != null){
   115 			if(currentTask != null){
   117 				asyncExecutor = new DownloadAsyncTask(currentTask);
   116 				asyncExecutor = new DownloadAsyncTask(currentTask);
   118 				asyncExecutor.execute(currentTask.getPackage());
   117 				asyncExecutor.execute(currentTask.getPackage());
   119 			}
   118 			}
   120 		}
   119 		}