use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class EComponentWithViewSupportHolder method setFindSupportFragmentById.
protected void setFindSupportFragmentById() {
findSupportFragmentById = getGeneratedClass().method(PRIVATE, getClasses().SUPPORT_V4_FRAGMENT, "findSupportFragmentById");
JVar idParam = findSupportFragmentById.param(getCodeModel().INT, "id");
JBlock body = findSupportFragmentById.body();
body._if(getContextRef()._instanceof(getClasses().FRAGMENT_ACTIVITY).not())._then()._return(_null());
JVar activityVar = body.decl(getClasses().FRAGMENT_ACTIVITY, "activity_", cast(getClasses().FRAGMENT_ACTIVITY, getContextRef()));
body._return(activityVar.invoke("getSupportFragmentManager").invoke("findFragmentById").arg(idParam));
}
use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class EComponentWithViewSupportHolder method createPageChangeHolder.
private PageChangeHolder createPageChangeHolder(JFieldRef idRef, TypeMirror viewParameterType, boolean hasAddOnPageChangeListenerMethod) {
JDefinedClass onPageChangeListenerClass = getCodeModel().anonymousClass(getClasses().PAGE_CHANGE_LISTENER);
AbstractJClass viewClass = getClasses().VIEW_PAGER;
if (viewParameterType != null) {
viewClass = getJClass(viewParameterType.toString());
}
JBlock onViewChangedBody = getOnViewChangedBodyInjectionBlock().blockSimple();
JVar viewVariable = onViewChangedBody.decl(FINAL, viewClass, "view", cast(viewClass, findViewById(idRef)));
JBlock block = onViewChangedBody._if(viewVariable.ne(JExpr._null()))._then();
if (hasAddOnPageChangeListenerMethod) {
block.invoke(viewVariable, "addOnPageChangeListener").arg(_new(onPageChangeListenerClass));
} else {
block.invoke(viewVariable, "setOnPageChangeListener").arg(_new(onPageChangeListenerClass));
}
return new PageChangeHolder(this, viewVariable, onPageChangeListenerClass);
}
use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class EFragmentHolder method setOnDestroyView.
private void setOnDestroyView() {
JMethod onDestroyView = generatedClass.method(PUBLIC, getCodeModel().VOID, "onDestroyView");
onDestroyView.annotate(Override.class);
JBlock body = onDestroyView.body();
body.invoke(_super(), onDestroyView);
body.assign(contentView, _null());
onDestroyViewAfterSuperBlock = body.blockSimple();
}
use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class EActivityHolder method setOnCreateOptionsMenu.
private void setOnCreateOptionsMenu() {
JMethod method = generatedClass.method(PUBLIC, getCodeModel().BOOLEAN, "onCreateOptionsMenu");
method.annotate(Override.class);
JBlock methodBody = method.body();
onCreateOptionsMenuMenuParam = method.param(getClasses().MENU, "menu");
onCreateOptionsMenuMenuInflaterVar = methodBody.decl(getClasses().MENU_INFLATER, "menuInflater", invoke("getMenuInflater"));
onCreateOptionsMenuMethodInflateBody = methodBody.blockSimple();
onCreateOptionsMenuMethodBody = methodBody.blockSimple();
methodBody._return(_super().invoke(method).arg(onCreateOptionsMenuMenuParam));
}
use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class EActivityHolder method setOnNewIntent.
private void setOnNewIntent() {
onNewIntentMethod = generatedClass.method(JMod.PUBLIC, getCodeModel().VOID, "onNewIntent");
onNewIntentMethod.annotate(Override.class);
JVar intent = onNewIntentMethod.param(getClasses().INTENT, "intent");
JBlock body = onNewIntentMethod.body();
body.invoke(_super(), onNewIntentMethod).arg(intent);
onNewIntentAfterSuperBlock = body.blockSimple();
}
Aggregations