All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.stanfy.enroscar.async.internal.AsyncTaskWithDelegate Maven / Gradle / Ivy

Go to download

Helper classes and extended abstractions for Android loaders, content resolvers, and DB access.

There is a newer version: 2.1
Show newest version
package com.stanfy.enroscar.async.internal;

import android.os.AsyncTask;

import java.util.concurrent.Callable;

final class AsyncTaskWithDelegate extends AsyncTask {

  /** Delegate. */
  BaseAsync async;

  /** Task. */
  private Callable task;

  /** Caught error. */
  private Exception error;

  protected AsyncTaskWithDelegate(final Callable task) {
    this(task, null);
  }
  protected AsyncTaskWithDelegate(final Callable task, final BaseAsync async) {
    this.async = async;
    this.task = task;
  }

  @Override
  protected final D doInBackground(Void... params) {
    try {
      return task.call();
    } catch (Exception e) {
      error = e;
      return null;
    }
  }

  @Override
  protected final void onPostExecute(final D d) {
    if (error != null) {
      async.postError(error);
    } else {
      async.postResult(d);
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy