Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ private void onLoggedOn(LoggedOnCallback callback) {

KeyValue result = api.call("GetNewsForApp", 2, args);

// todo 10-11-2021 - It seems newsitems is returning null for this example.
// When it should return at least 20 items.
for (KeyValue item : result.getChildren()) {
System.out.println("Item: " + item);
}
printKeyValue(result, 1);

} catch (IOException e) {
e.printStackTrace();
Expand All @@ -168,4 +164,21 @@ private void onLoggedOff(LoggedOffCallback callback) {

isRunning = false;
}

// Recursively print out child KeyValues.
private void printKeyValue(KeyValue keyValue, int depth) {
StringBuilder spacePadding = new StringBuilder();
for (int x = 0; x < depth; x++) {
spacePadding.append(" ");
}

if (keyValue.getChildren().size() == 0) {
System.out.println(spacePadding + keyValue.getName() + ": " + keyValue.getValue());
} else {
System.out.println(spacePadding + keyValue.getName() + ":");
for (KeyValue child : keyValue.getChildren()) {
printKeyValue(child, depth + 1);
}
}
}
}