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

org.usergrid.android.client.callbacks.ClientAsyncTask Maven / Gradle / Ivy

There is a newer version: 0.0.6
Show newest version
package org.usergrid.android.client.callbacks;

import android.os.AsyncTask;

public abstract class ClientAsyncTask extends AsyncTask {

	ClientCallback callback;

	public ClientAsyncTask(ClientCallback callback) {
		this.callback = callback;
	}

	@Override
	protected T doInBackground(Void... v) {
		try {
			return doTask();
		} catch (Exception e) {
			this.publishProgress(e);
		}
		return null;
	}

	public abstract T doTask();

	@Override
	protected void onPostExecute(T response) {
		if (callback != null) {
			callback.onResponse(response);
		}
	}

	@Override
	protected void onProgressUpdate(Exception... e) {
		if ((callback != null) && (e != null) && (e.length > 0)) {
			callback.onException(e[0]);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy