Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* POJO for Activity JSON objects.
*/
public final static class Activity {
public String id;
public String label;
public Date created;
public Date modified;
public boolean is_visible;
@Override public String toString() {
return "{id: " + id + ", created: " + created + ", label: " + label + ", is_visible: " + is_visible + "}";
}
}
mAutobahn.call("pt:list-activities", new TypeReference<List<Activities.Activity>>(){}, new Autobahn.CallHandler() {
@Override
public void onResult(Object result) {
@SuppressWarnings("unchecked")
List<Activities.Activity> activities = (List<Activities.Activity>) result;
Log.d(TAG, "Got activities! " + activities.size());
mActivitiesAdapter.setActivities(activities);
}
@Override
public void onError(String errorId, String errorInfo) {
Log.d(TAG, "RPC Error - " + errorInfo);
}
});
// Activities.Activity.class
mAutobahn.subscribe("event:on-activity-created", Activities.Activity.class, new Autobahn.EventHandler() {
@Override
public void onEvent(String topicUri, Object event) {
Activities.Activity activity = (Activities.Activity) event;
Log.d(TAG, "Got new activity : " + activity.toString());
mActivitiesAdapter.createActivity(activity);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment