use of org.androidannotations.annotations.IgnoreWhen in project androidannotations by androidannotations.
the class IgnoreWhenHandler method process.
@Override
public void process(Element element, EFragmentHolder holder) throws Exception {
ExecutableElement executableElement = (ExecutableElement) element;
JMethod delegatingMethod = codeModelHelper.overrideAnnotatedMethod(executableElement, holder);
JBlock previousMethodBody = codeModelHelper.removeBody(delegatingMethod);
IgnoreWhen ignoreWhen = element.getAnnotation(IgnoreWhen.class);
JBlock methodBody = delegatingMethod.body();
JConditional conditional = null;
switch(ignoreWhen.value()) {
case VIEW_DESTROYED:
conditional = methodBody._if(holder.getViewDestroyedField().not());
break;
case DETACHED:
conditional = methodBody._if(invoke(holder.getGeneratedClass().staticRef("this"), "getActivity").ne(_null()));
break;
}
conditional._then().add(previousMethodBody);
}
Aggregations