Created
May 21, 2013 23:04
-
-
Save gnuton/5623987 to your computer and use it in GitHub Desktop.
Generic Android Async Task with internal interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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