Skip to content

Instantly share code, notes, and snippets.

@secondsun
Created February 5, 2013 17:27
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 secondsun/a7a92eea911884071aea to your computer and use it in GitHub Desktop.
Save secondsun/a7a92eea911884071aea to your computer and use it in GitHub Desktop.
class AGActivity extends Activity implements CallbackListener {
private Serializeable requestId = null;
public void onCreate(Bundle in) {
requestId = in.get("requestId");
}
public void onResume() {
if (requestId != null) {
if (pipe.isRunning(requestId)) {
pipe.addCallbackListener(this);
} else {
requestId = pipe.read(this);
}
} else {
requestId = pipe.read(this);
}
}
public void onPause() {
pipe.removeListener(this);
}
public void onSaveInstanceState(Bundle out) {
out.put("requestId", requestId);
}
//From CallbackListene
@Override
public void onSuccess(Object result, Serializeable requestId) {
if (requestId == this.requestId) {
this.requestId = -1;
doStuff();
}
}
//From CallbackListene
@Override
public void onFailure(Exception result, Serializeable requestId) {
if (requestId == this.requestId) {
this.requestId = -1;
doStuff();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment