Created
May 30, 2014 17:00
-
-
Save geovanisouza92/7283b5d8b48bac3be17c to your computer and use it in GitHub Desktop.
AndroidAnnotations + RoboBinding + Saripaar
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
| // (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