Skip to content

Instantly share code, notes, and snippets.

@firexel
Created April 25, 2012 14:09
Show Gist options
  • Save firexel/2489970 to your computer and use it in GitHub Desktop.
Save firexel/2489970 to your computer and use it in GitHub Desktop.
public class NewCallbackClient implements SimpleDispatcher.Listener {
public void onItemSetChanged(SimpleDispatcher dispatcher) {
System.out.println("onItemSetChanged");
}
public void onItemDataChanged(SimpleDispatcher dispatcher, int itemId, int changeMask) {
if ((changeMask & Item.FIELD_1) != 0) {
System.out.println("onItemDataChanged: " + dispatcher.getItemById(itemId));
}
}
}
class SimpleDispatcher {
private SparseArray<Item> array = new SparseArray<Item>();
public Item getItemById(int id) {
return array.get(id);
}
public Collection<Item> enumItems() {
...
}
public interface Listener {
void onItemSetChanged(SimpleDispatcher dispatcher);
void onItemDataChanged(SimpleDispatcher dispatcher, int itemId, int changeMask);
}
}
class Item {
public static final int FIELD_1 = 1, FIELD_2 = 2, FIELD_3 = 4;
int field1, field2;
String field3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment