Exemplo n.º 1
0
 /** Pause all task */
 public void pauseAll() {
   FileDownloadEventPool.getImpl().shutdownSendPool();
   final BaseDownloadTask[] downloadList = FileDownloadList.getImpl().copy();
   synchronized (pauseLock) {
     for (BaseDownloadTask baseDownloadTask : downloadList) {
       baseDownloadTask.pause();
     }
   }
   // double check, for case: File Download progress alive but ui progress has died and relived,
   // so FileDownloadList not always contain all running task exactly.
   if (FileDownloadServiceUIGuard.getImpl().isConnected()) {
     FileDownloadServiceUIGuard.getImpl().pauseAllTasks();
   } else {
     if (pauseAllRunnable == null) {
       pauseAllRunnable =
           new Runnable() {
             @Override
             public void run() {
               FileDownloadServiceUIGuard.getImpl().pauseAllTasks();
             }
           };
     }
     FileDownloadServiceUIGuard.getImpl()
         .bindStartByContext(FileDownloadHelper.getAppContext(), pauseAllRunnable);
   }
 }
Exemplo n.º 2
0
 /**
  * Pause the download task by the downloadId
  *
  * @param downloadId pause download by download id
  * @see #pause(FileDownloadListener)
  */
 public void pause(final int downloadId) {
   BaseDownloadTask downloadTask = FileDownloadList.getImpl().get(downloadId);
   if (downloadTask == null) {
     FileDownloadLog.w(this, "request pause but not exist %d", downloadId);
     return;
   }
   downloadTask.pause();
 }
Exemplo n.º 3
0
 /**
  * Pause the download queue by the same listener
  *
  * @param listener paused download by same listener
  * @see #pause(int)
  */
 public void pause(final FileDownloadListener listener) {
   FileDownloadEventPool.getImpl().shutdownSendPool(listener);
   final List<BaseDownloadTask> downloadList = FileDownloadList.getImpl().copy(listener);
   synchronized (pauseLock) {
     for (BaseDownloadTask baseDownloadTask : downloadList) {
       baseDownloadTask.pause();
     }
   }
 }