Created
April 8, 2011 23:22
-
-
Save jbrechtel/910921 to your computer and use it in GitHub Desktop.
This file contains 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.foo.bar; | |
import android.os.AsyncTask; | |
import android.util.Log; | |
public abstract class SimpleTask extends AsyncTask<Void, Void, Boolean> { | |
private final AsyncTask waitTask; | |
public SimpleTask(AsyncTask waitTask) { | |
this.waitTask = waitTask; | |
} | |
public SimpleTask() { | |
this(null); | |
} | |
abstract protected Boolean background(); | |
abstract protected void foreground(); | |
@Override | |
protected Boolean doInBackground(Void... voids) { | |
if(waitTask != null) { | |
try { | |
waitTask.get(); | |
} catch (Exception e) { | |
Log.d("telephone_game", e.toString()); | |
} | |
} | |
return background(); | |
} | |
@Override | |
protected void onPostExecute(Boolean success) { | |
if(success) | |
foreground(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment