Created
September 27, 2012 18:33
-
-
Save twaddington/3795600 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// We imply that we expect a JSON response by using the SFJsonRequestHandler... | |
Future f = client.getPath("/foo/bar", new SFJsonRequesthandler() { | |
@Override | |
public void onStart() { | |
// Pass | |
} | |
@Override | |
public void onFinish() { | |
// Pass | |
} | |
@Override | |
public void onSuccess(SFJsonResponse response) { | |
// Get the plaintext response | |
String content = response.getContent(); | |
// Get the parsed JSON response | |
JSONObject json = response.getJSONObject(); | |
} | |
@Override | |
public void onComplete(SFJsonResponse response) { | |
// Request completed, but returned a non-success response code. | |
int code = response.getResponseCode(); | |
} | |
@Override | |
public void onFailure(Throwable e) { | |
// The request failed to complete due to a timeout, a | |
// networking exception or some other error condition. | |
} | |
}); | |
if (f.isDone()) { | |
// Get the result | |
Object o = f.get(); | |
} else { | |
// Cancel the request | |
f.cancel(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment