use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EActivityHolder method setOnConfigurationChanged.
private void setOnConfigurationChanged() {
JMethod method = generatedClass.method(JMod.PUBLIC, getCodeModel().VOID, "onConfigurationChanged");
method.annotate(Override.class);
AbstractJClass configurationClass = getClasses().CONFIGURATION;
onConfigurationChangedNewConfigParam = method.param(configurationClass, "newConfig");
JBlock body = method.body();
onConfigurationChangedBeforeSuperBlock = body.blockSimple();
body.invoke(_super(), method).arg(onConfigurationChangedNewConfigParam);
onConfigurationChangedAfterSuperBlock = body.blockSimple();
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EBeanHolder method createRebindMethod.
public void createRebindMethod() {
JMethod rebindMethod = generatedClass.method(PUBLIC, getCodeModel().VOID, "rebind");
JVar contextParam = rebindMethod.param(getClasses().CONTEXT, "context");
JBlock body = rebindMethod.body();
body.assign(getContextField(), contextParam);
body.invoke(getInit());
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EBeanHolder method createFactoryMethod.
public void createFactoryMethod(boolean hasSingletonScope) {
AbstractJClass narrowedGeneratedClass = codeModelHelper.narrowGeneratedClass(generatedClass, annotatedElement.asType());
JMethod factoryMethod = generatedClass.method(PUBLIC | STATIC, narrowedGeneratedClass, GET_INSTANCE_METHOD_NAME);
codeModelHelper.generify(factoryMethod, annotatedElement);
JVar factoryMethodContextParam = factoryMethod.param(getClasses().CONTEXT, "context");
JBlock factoryMethodBody = factoryMethod.body();
/*
* Singletons are bound to the application context
*/
if (hasSingletonScope) {
JFieldVar instanceField = generatedClass.field(PRIVATE | STATIC, generatedClass, "instance" + generationSuffix());
JBlock creationBlock = //
factoryMethodBody._if(//
instanceField.eq(_null()))._then();
JVar previousNotifier = viewNotifierHelper.replacePreviousNotifierWithNull(creationBlock);
creationBlock.assign(instanceField, _new(narrowedGeneratedClass).arg(factoryMethodContextParam.invoke("getApplicationContext")));
creationBlock.invoke(instanceField, getInit());
viewNotifierHelper.resetPreviousNotifier(creationBlock, previousNotifier);
factoryMethodBody._return(instanceField);
} else {
factoryMethodBody._return(_new(narrowedGeneratedClass).arg(factoryMethodContextParam));
}
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EFragmentHolder method setOnResume.
private void setOnResume() {
JMethod onResume = generatedClass.method(PUBLIC, getCodeModel().VOID, "onResume");
onResume.annotate(Override.class);
JBlock onResumeBody = onResume.body();
onResumeBody.invoke(_super(), onResume);
onResumeAfterSuperBlock = onResumeBody.blockSimple();
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EFragmentHolder method setFragmentBuilderCreate.
private void setFragmentBuilderCreate() {
JMethod method = generatedClass.method(STATIC | PUBLIC, narrowBuilderClass, "builder");
codeModelHelper.generify(method, annotatedElement);
method.body()._return(_new(narrowBuilderClass));
}
Aggregations