Skip to content

Instantly share code, notes, and snippets.

@geovanisouza92
Created May 30, 2014 17:00
Show Gist options
  • Select an option

  • Save geovanisouza92/7283b5d8b48bac3be17c to your computer and use it in GitHub Desktop.

Select an option

Save geovanisouza92/7283b5d8b48bac3be17c to your computer and use it in GitHub Desktop.
AndroidAnnotations + RoboBinding + Saripaar
// (AndroidAnnotations)
@EViewGroup(R.layout.view_foo)
class Foo extends LinearLayout implements PresentationModel<Bar> {
Bar model;
Listener listener;
// (Saripaar)
Validator validator;
// (AndroidAnnotations) + (Saripaar)
@ViewById @Required TextView foo_tv_goo;
public Foo(Context context, Bar model, Listener listener) {
this.model = model;
this.listener = listener;
}
@Override public Bar get() {
return model;
}
@AfterViews void setup() {
// (RoboBinding)
Binders.bindView(/* View */ this, /* PresentationModel */ this);
// (Saripaar)
validator = new Validator(this);
validator.setValidationListener(this);
}
@Click(R.id.foo_bt_save) void saveClicked() {
validator.validate();
}
/* ValidationListener methods */
public void onValidationSucceeded() {
// Listener use get() to peek updated model
listener.done();
}
public static interface Listener {
void done();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment