Skip to content

Instantly share code, notes, and snippets.

@mrmans0n
Last active January 1, 2017 15:06
Show Gist options
  • Save mrmans0n/b1efdc0a7c4ea72056ed2f9136371773 to your computer and use it in GitHub Desktop.
Save mrmans0n/b1efdc0a7c4ea72056ed2f9136371773 to your computer and use it in GitHub Desktop.
Binder template for Drebin
#parse("File Header.java")
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.ViewFactory;
import drebin.core.ViewHost;
public class ${Model}Binder implements Binder<${ViewClass}, ${Model}Binder.${Model}ViewHost, ${Model}, BinderEnvironment> {
private static final ViewFactory<${ViewClass}> VIEW_FACTORY = ViewFactory.INFLATE.fromLayout(R.layout.${LayoutRes});
public ${Model}Binder() {
}
@Override public ViewFactory<${ViewClass}> getViewFactory() {
return VIEW_FACTORY;
}
@Override public ${Model}ViewHost createViewHost(${ViewClass} view) {
return new ${Model}ViewHost(view);
}
@Override public void bind(${Model} model, ${Model}ViewHost viewHost, BinderEnvironment environment) {
// Bind your model here
}
@Override public void unbind(${Model}ViewHost viewHost, BinderEnvironment environment) {
}
static class ${Model}ViewHost extends ViewHost<${ViewClass}> {
public ${Model}ViewHost(${ViewClass} view) {
super(view);
// Inject your views here, i.e.:
// ButterKnife.bind(this, view);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment