-
-
Save secondsun/a7a92eea911884071aea 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
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