use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class KeyEventCallbackMethodsDelegate method createOnKeyDownMethod.
private void createOnKeyDownMethod() {
JMethod method = getGeneratedClass().method(PUBLIC, codeModel().BOOLEAN, "onKeyDown");
method.annotate(Override.class);
JVar keyCode = method.param(codeModel().INT, "keyCode");
onKeyDownKeyEventParam = method.param(getClasses().KEY_EVENT, "keyEvent");
JBlock methodBody = method.body();
onKeyDownSwitchBody = methodBody._switch(keyCode);
methodBody._return(_super().invoke(method).arg(keyCode).arg(onKeyDownKeyEventParam));
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class APTCodeModelHelper method implementMethod.
public JMethod implementMethod(GeneratedClassHolder holder, List<ExecutableElement> methods, String methodName, String returnType, boolean finalParams, String... parameterTypes) {
// First get the ExecutableElement method object from the util function.
ExecutableElement method = getMethod(methods, methodName, returnType, parameterTypes);
JMethod jmethod = null;
if (method != null) {
// Get the return type or VOID if none.
AbstractJType jcReturnType = returnType.equals(TypeKind.VOID.toString()) ? environment.getCodeModel().VOID : environment.getJClass(returnType);
// Create the implementation and annotate it with the Override
// annotation.
jmethod = holder.getGeneratedClass().method(JMod.PUBLIC, jcReturnType, method.getSimpleName().toString());
jmethod.annotate(Override.class);
// Create the parameters.
int paramMods = finalParams ? JMod.FINAL : JMod.NONE;
for (int i = 0; i < method.getParameters().size(); i++) {
VariableElement param = method.getParameters().get(i);
jmethod.param(paramMods, environment.getJClass(parameterTypes[i]), param.getSimpleName().toString());
}
}
return jmethod;
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EActivityHolder method setContentViewMethod.
private JMethod setContentViewMethod(AbstractJType[] paramTypes, String[] paramNames) {
JMethod method = generatedClass.method(JMod.PUBLIC, getCodeModel().VOID, "setContentView");
method.annotate(Override.class);
List<JVar> params = new ArrayList<>();
for (int i = 0; i < paramTypes.length; i++) {
JVar param = method.param(paramTypes[i], paramNames[i]);
params.add(param);
}
JBlock body = method.body();
JInvocation superCall = body.invoke(JExpr._super(), method);
for (JVar arg : params) {
superCall.arg(arg);
}
viewNotifierHelper.invokeViewChanged(body);
return method;
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EActivityHolder method setOnResume.
private void setOnResume() {
JMethod method = generatedClass.method(JMod.PUBLIC, getCodeModel().VOID, "onResume");
method.annotate(Override.class);
JBlock body = method.body();
onResumeBeforeSuperBlock = body.blockSimple();
body.invoke(_super(), method);
onResumeAfterSuperBlock = body.blockSimple();
}
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();
}
Aggregations