use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class TextWatcherHolder method createOnTextChanged.
private void createOnTextChanged() {
JPrimitiveType intClass = holder.getCodeModel().INT;
JMethod onTextChangedMethod = listenerClass.method(JMod.PUBLIC, holder.getCodeModel().VOID, "onTextChanged");
onTextChangedMethod.annotate(Override.class);
onTextChangedBody = onTextChangedMethod.body();
onTextChangedCharSequenceParam = onTextChangedMethod.param(holder.getClasses().CHAR_SEQUENCE, "s");
onTextChangedStartParam = onTextChangedMethod.param(intClass, "start");
onTextChangedBeforeParam = onTextChangedMethod.param(intClass, "before");
onTextChangedCountParam = onTextChangedMethod.param(intClass, "count");
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EActivityHandler method process.
@Override
public void process(Element element, EActivityHolder holder) {
List<JFieldRef> fieldRefs = annotationHelper.extractAnnotationFieldRefs(element, IRClass.Res.LAYOUT, false);
JFieldRef contentViewId = null;
if (fieldRefs.size() == 1) {
contentViewId = fieldRefs.get(0);
}
if (contentViewId != null) {
JBlock onCreateBody = holder.getOnCreate().body();
JMethod setContentView = holder.getSetContentViewLayout();
onCreateBody.invoke(setContentView).arg(contentViewId);
}
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EServiceHolder method setOnDestroy.
private void setOnDestroy() {
JMethod onDestroy = generatedClass.method(PUBLIC, getCodeModel().VOID, "onDestroy");
onDestroy.annotate(Override.class);
JBlock onDestroyBody = onDestroy.body();
onDestroyBeforeSuperBlock = onDestroyBody.blockSimple();
onDestroyBody.invoke(JExpr._super(), onDestroy);
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EViewHolder method createConstructorAndBuilder.
private void createConstructorAndBuilder() {
List<ExecutableElement> constructors = new ArrayList<>();
for (Element e : annotatedElement.getEnclosedElements()) {
if (e.getKind() == CONSTRUCTOR) {
constructors.add((ExecutableElement) e);
}
}
for (ExecutableElement userConstructor : constructors) {
JMethod copyConstructor = generatedClass.constructor(PUBLIC);
JMethod staticHelper = generatedClass.method(PUBLIC | STATIC, generatedClass._extends(), "build");
codeModelHelper.generify(staticHelper, getAnnotatedElement());
JBlock body = copyConstructor.body();
JInvocation superCall = body.invoke("super");
AbstractJClass narrowedGeneratedClass = narrow(generatedClass);
JInvocation newInvocation = JExpr._new(narrowedGeneratedClass);
for (VariableElement param : userConstructor.getParameters()) {
String paramName = param.getSimpleName().toString();
AbstractJClass paramType = codeModelHelper.typeMirrorToJClass(param.asType());
copyConstructor.param(paramType, paramName);
staticHelper.param(paramType, paramName);
superCall.arg(JExpr.ref(paramName));
newInvocation.arg(JExpr.ref(paramName));
}
JVar newCall = staticHelper.body().decl(narrowedGeneratedClass, "instance", newInvocation);
staticHelper.body().invoke(newCall, getOnFinishInflate());
staticHelper.body()._return(newCall);
body.invoke(getInit());
}
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class KeyEventCallbackMethodsDelegate method createOnKeyLongPressMethod.
private void createOnKeyLongPressMethod() {
JMethod method = getGeneratedClass().method(PUBLIC, codeModel().BOOLEAN, "onKeyLongPress");
method.annotate(Override.class);
JVar keyCode = method.param(codeModel().INT, "keyCode");
onKeyLongPressKeyEventParam = method.param(getClasses().KEY_EVENT, "keyEvent");
JBlock methodBody = method.body();
onKeyLongPressSwitchBody = methodBody._switch(keyCode);
methodBody._return(_super().invoke(method).arg(keyCode).arg(onKeyLongPressKeyEventParam));
}
Aggregations