Created
August 22, 2012 23:40
-
-
Save fearofcode/3430600 to your computer and use it in GitHub Desktop.
Relations workaround for Java/Android SDK
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
| final Dummy dummy = new Dummy("Test 2 - Valdemar"); | |
| StackMob.getLogger().setLogging(true); | |
| final SimpleUser user = new SimpleUser("jonh", null); | |
| user.fetchWithDepth(2, new StackMobCallback() { | |
| @Override | |
| public void success(String responseBody) { | |
| StackMob.getLogger().logInfo("Response body when fetching: " + responseBody); | |
| // append to user.dummies array | |
| Dummy[] newDummies = new Dummy[user.dummies.length+1]; | |
| System.arraycopy(user.dummies, 0, newDummies, 0, user.dummies.length); | |
| newDummies[newDummies.length-1] = dummy; | |
| user.dummies = newDummies; | |
| user.saveWithDepth(2, new StackMobCallback() { | |
| @Override | |
| public void success(String responseBody) { | |
| StackMob.getLogger().logInfo("Got response body after saving: " + responseBody); | |
| } | |
| @Override | |
| public void failure(StackMobException e) { | |
| StackMob.getLogger().logWarning("Saving failed"); | |
| } | |
| }); | |
| } | |
| @Override | |
| public void failure(StackMobException e) { | |
| StackMob.getLogger().logWarning("Fetching information failed"); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment