Skip to content

Instantly share code, notes, and snippets.

@jyaunches
Created September 27, 2012 18:47
Show Gist options
  • Save jyaunches/3795675 to your computer and use it in GitHub Desktop.
Save jyaunches/3795675 to your computer and use it in GitHub Desktop.
public class SendMessageTask extends SafeAsyncTask<Boolean> {
private final EventBus eventBus;
@Inject
public EndSessionTask(EventBus eventBus) {
this.eventBus = eventBus;
}
@Override
public Boolean call() throws Exception {
// make network call
// return true or false based on whether it was successful
// You could also make an object that wraps the response code or something
return true;
}
@Override
protected void onException(Exception e) {
eventBus.post(new EndSessionFailureEvent(SESSION_END_FAILED));
}
@Override
protected void onSuccess(Boolean wasSuccessful) {
if(wasSuccessful){
eventBus.post(new SentMessageEvent());
}else{
eventBus.post(new SentMessageFailureEvent());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment