コード例 #1
0
  public void handleRetainedTask(Task task, OnTaskCompleteListener taskCompleteListener) {
    this.taskCompleteListener = taskCompleteListener;
    setupProgressDialog(taskCompleteListener.getContext());

    // Restore retained task and attach it to tracker (this)
    mAsyncTask = task;
    mAsyncTask.setProgressTracker(this);
  }
コード例 #2
0
 @Override
 public void onCancel(DialogInterface dialog) {
   if (mAsyncTask == null) {
     return;
   }
   // Cancel task
   mAsyncTask.cancel(true);
   // Notify activity about completion
   taskCompleteListener.onTaskComplete(mAsyncTask);
   // Reset task
   mAsyncTask = null;
 }
コード例 #3
0
  @Override
  public void onComplete() {
    // Close progress dialog
    try {
      mProgressDialog.cancel();
    } catch (IllegalArgumentException e) {
      Logger.e(TAG, "View not attached to window manager");
    }

    // Reset task
    Task completedTask = mAsyncTask;
    mAsyncTask = null;

    // Notify activity about completion
    taskCompleteListener.onTaskComplete(completedTask);
  }
コード例 #4
0
 public AsyncTaskManager(OnTaskCompleteListener taskCompleteListener) {
   this.taskCompleteListener = taskCompleteListener;
   Context context = taskCompleteListener.getContext();
   this.weakContext = new WeakReference<Context>(context);
   setupProgressDialog(context);
 }