Created
September 27, 2012 18:47
-
-
Save jyaunches/3795675 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
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