use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EActivityHolder method setFindSupportFragmentByTag.
@Override
protected void setFindSupportFragmentByTag() {
JMethod method = generatedClass.method(PRIVATE, getClasses().SUPPORT_V4_FRAGMENT, "findSupportFragmentByTag");
JVar tagParam = method.param(getClasses().STRING, "tag");
JBlock body = method.body();
body._return(invoke("getSupportFragmentManager").invoke("findFragmentByTag").arg(tagParam));
findSupportFragmentByTag = method;
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EActivityHolder method setOnRetainNonConfigurationInstance.
private void setOnRetainNonConfigurationInstance() throws JClassAlreadyExistsException {
AnnotationHelper annotationHelper = new AnnotationHelper(getEnvironment());
TypeElement fragmentActivityTypeElement = annotationHelper.typeElementFromQualifiedName(CanonicalNameConstants.FRAGMENT_ACTIVITY);
TypeElement typeElement = annotationHelper.typeElementFromQualifiedName(generatedClass._extends().fullName());
String onRetainNonConfigurationInstanceName = "onRetainNonConfigurationInstance";
if (fragmentActivityTypeElement != null && annotationHelper.isSubtype(typeElement.asType(), fragmentActivityTypeElement.asType())) {
onRetainNonConfigurationInstanceName = "onRetainCustomNonConfigurationInstance";
}
NonConfigurationHolder ncHolder = getNonConfigurationHolder();
JDefinedClass ncHolderClass = ncHolder.getGeneratedClass();
JMethod onRetainNonConfigurationInstanceMethod = generatedClass.method(PUBLIC, ncHolderClass, onRetainNonConfigurationInstanceName);
onRetainNonConfigurationInstanceMethod.annotate(Override.class);
JBlock methodBody = onRetainNonConfigurationInstanceMethod.body();
onRetainNonConfigurationInstance = methodBody.decl(ncHolderClass, "nonConfigurationInstanceState_", _new(ncHolderClass));
IJExpression superCall = _super().invoke(onRetainNonConfigurationInstanceMethod);
methodBody.assign(onRetainNonConfigurationInstance.ref(ncHolder.getSuperNonConfigurationInstanceField()), superCall);
onRetainNonConfigurationInstanceBindBlock = methodBody.blockSimple();
methodBody._return(onRetainNonConfigurationInstance);
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EApplicationHolder method createSingleton.
private void createSingleton() {
AbstractJClass annotatedComponent = generatedClass._extends();
staticInstanceField = generatedClass.field(PRIVATE | STATIC, annotatedComponent, "INSTANCE" + generationSuffix());
// Static singleton getter and setter
JMethod getInstance = generatedClass.method(PUBLIC | STATIC, annotatedComponent, GET_APPLICATION_INSTANCE);
getInstance.body()._return(staticInstanceField);
JMethod setInstance = generatedClass.method(PUBLIC | STATIC, getCodeModel().VOID, "setForTesting");
setInstance.javadoc().append("Visible for testing purposes");
JVar applicationParam = setInstance.param(annotatedComponent, "application");
setInstance.body().assign(staticInstanceField, applicationParam);
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class RestHolder method implementGetCookie.
private void implementGetCookie(List<ExecutableElement> methods) {
JMethod getCookieMethod = codeModelHelper.implementMethod(this, methods, "getCookie", STRING, STRING);
if (getCookieMethod != null) {
JInvocation cookieValue = JExpr.invoke(getAvailableCookiesField(), "get").arg(getCookieMethod.params().get(0));
getCookieMethod.body()._return(cookieValue);
}
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class RestHolder method implementSetErrorHandler.
private void implementSetErrorHandler(List<ExecutableElement> methods) {
JMethod setErrorHandlerMethod = codeModelHelper.implementMethod(this, methods, "setRestErrorHandler", TypeKind.VOID.toString(), RestErrorHandler.class.getName());
if (setErrorHandlerMethod != null) {
setRestErrorHandlerField();
setErrorHandlerMethod.body().assign(_this().ref(getRestErrorHandlerField()), setErrorHandlerMethod.params().get(0));
}
}
Aggregations