Skip to content

Instantly share code, notes, and snippets.

@gnuton
Created May 21, 2013 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnuton/5623987 to your computer and use it in GitHub Desktop.
Save gnuton/5623987 to your computer and use it in GitHub Desktop.
Generic Android Async Task with internal interface
package com.example.toniotest.utils;
import android.os.AsyncTask;
/**
* Created by gnuton on 5/22/13.
*/
public class BoilerPipeTask extends AsyncTask<String, Void, String> {
private static final String TAG = "BOILER PIPE TASK";
private static OnBoilerplateRemovedListener listener;
public interface OnBoilerplateRemovedListener {
public void onBoilerplageRemoved(final String buffer);
}
public BoilerPipeTask(Object o) {
if (o instanceof OnBoilerplateRemovedListener) {
this.listener = (OnBoilerplateRemovedListener) o;
} else {
throw new ClassCastException(o.toString() + " must implement BoilerPipeTask.OnBoilerplateRemovedListener");
}
}
@Override
protected String doInBackground(String... strings) {
return null;
}
@Override
protected void onPostExecute(String s) {
listener.onBoilerplageRemoved(s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment