Ejemplo n.º 1
0
 /** Cancel all registered tasks. */
 public void cancellAllInterrupt() {
   synchronized (mTasks) {
     for (EmailAsyncTask<?, ?, ?> task : mTasks) {
       task.cancel(true);
     }
     mTasks.clear();
   }
 }
Ejemplo n.º 2
0
 @Override
 public void onPostExecute(Result2 result) {
   mOwner.unregisterSelf();
   if (mOwner.mCancelled) {
     mOwner.onCancelled(result);
   } else {
     mOwner.onSuccess(result);
   }
 }
Ejemplo n.º 3
0
 private static EmailAsyncTask<Void, Void, Void> runAsyncInternal(
     Executor executor, final Runnable runnable) {
   EmailAsyncTask<Void, Void, Void> task =
       new EmailAsyncTask<Void, Void, Void>(null) {
         @Override
         protected Void doInBackground(Void... params) {
           runnable.run();
           return null;
         }
       };
   return task.executeInternal(executor, false, (Void[]) null);
 }
Ejemplo n.º 4
0
 /**
  * Cancel all instances of the same class as {@code current} other than {@code current} itself.
  */
 /* package */ void cancelOthers(EmailAsyncTask<?, ?, ?> current) {
   final Class<?> clazz = current.getClass();
   synchronized (mTasks) {
     final ArrayList<EmailAsyncTask<?, ?, ?>> toRemove =
         new ArrayList<EmailAsyncTask<?, ?, ?>>();
     for (EmailAsyncTask<?, ?, ?> task : mTasks) {
       if ((task != current) && task.getClass().equals(clazz)) {
         task.cancel(true);
         toRemove.add(task);
       }
     }
     for (EmailAsyncTask<?, ?, ?> task : toRemove) {
       mTasks.remove(task);
     }
   }
 }
Ejemplo n.º 5
0
 @Override
 public void onCancelled(Result2 result) {
   mOwner.unregisterSelf();
   mOwner.onCancelled(result);
 }
Ejemplo n.º 6
0
 @Override
 protected Result2 doInBackground(Params2... params) {
   return mOwner.doInBackground(params);
 }