use of com.helger.jcodemodel.JVar in project androidannotations by androidannotations.
the class ItemSelectHandler method processParameters.
@Override
protected void processParameters(EComponentWithViewSupportHolder holder, JMethod listenerMethod, JInvocation itemSelectedCall, List<? extends VariableElement> parameters) {
AbstractJClass narrowAdapterViewClass = getClasses().ADAPTER_VIEW.narrow(getCodeModel().wildcard());
JVar onItemClickParentParam = listenerMethod.param(narrowAdapterViewClass, "parent");
listenerMethod.param(getClasses().VIEW, "view");
JVar onItemClickPositionParam = listenerMethod.param(getCodeModel().INT, "position");
listenerMethod.param(getCodeModel().LONG, "id");
itemSelectedCall.arg(JExpr.TRUE);
boolean hasItemParameter = parameters.size() == 2;
boolean secondParameterIsInt = false;
String secondParameterQualifiedName = null;
if (hasItemParameter) {
VariableElement secondParameter = parameters.get(1);
TypeMirror secondParameterType = secondParameter.asType();
secondParameterQualifiedName = secondParameterType.toString();
secondParameterIsInt = secondParameterType.getKind() == TypeKind.INT;
}
if (hasItemParameter) {
if (secondParameterIsInt) {
itemSelectedCall.arg(onItemClickPositionParam);
} else {
itemSelectedCall.arg(JExpr.cast(getJClass(secondParameterQualifiedName), invoke(onItemClickParentParam, "getAdapter").invoke("getItem").arg(onItemClickPositionParam)));
}
}
onNothingSelectedMethod.param(narrowAdapterViewClass, "parent");
IJExpression activityRef = holder.getGeneratedClass().staticRef("this");
JInvocation nothingSelectedCall = invoke(activityRef, getMethodName());
onNothingSelectedMethod.body().add(nothingSelectedCall);
nothingSelectedCall.arg(JExpr.FALSE);
if (hasItemParameter) {
if (secondParameterIsInt) {
nothingSelectedCall.arg(lit(-1));
} else {
nothingSelectedCall.arg(_null());
}
}
}
use of com.helger.jcodemodel.JVar in project androidannotations by androidannotations.
the class APTCodeModelHelper method getSuperCall.
public JInvocation getSuperCall(GeneratedClassHolder holder, JMethod superMethod) {
IJExpression activitySuper = holder.getGeneratedClass().staticRef("super");
JInvocation superCall = JExpr.invoke(activitySuper, superMethod);
for (JVar param : superMethod.params()) {
superCall.arg(param);
}
if (superMethod.hasVarArgs()) {
superCall.arg(superMethod.varParam());
}
return superCall;
}
use of com.helger.jcodemodel.JVar in project androidannotations by androidannotations.
the class InjectHelper method processMethod.
private void processMethod(Element element, T holder) {
ExecutableElement executableElement = (ExecutableElement) element;
VariableElement param = executableElement.getParameters().get(0);
String methodName = executableElement.getSimpleName().toString();
JBlock block = createBlock(holder, true);
AbstractJClass type = codeModelHelper.typeMirrorToJClass(param.asType());
JVar fieldRef = block.decl(type, param.getSimpleName().toString(), getDefault(param.asType()));
handler.assignValue(block, fieldRef, holder, element, param);
block.add(JExpr.invoke(methodName).arg(fieldRef));
}
use of com.helger.jcodemodel.JVar in project androidannotations by androidannotations.
the class PreferencesDelegate method setAddPreferencesFromResourceBlock.
private void setAddPreferencesFromResourceBlock() {
JMethod method = getGeneratedClass().method(PUBLIC, codeModel().VOID, "addPreferencesFromResource");
method.annotate(Override.class);
JVar preferencesResIdParam = method.param(int.class, "preferencesResId");
method.body().invoke(JExpr._super(), "addPreferencesFromResource").arg(preferencesResIdParam);
addPreferencesFromResourceInjectionBlock = method.body().blockVirtual();
addPreferencesFromResourceAfterInjectionBlock = method.body().blockVirtual();
}
use of com.helger.jcodemodel.JVar in project androidannotations by androidannotations.
the class KeyEventCallbackMethodsDelegate method createOnKeyMultipleMethod.
private void createOnKeyMultipleMethod() {
JMethod method = getGeneratedClass().method(PUBLIC, codeModel().BOOLEAN, "onKeyMultiple");
method.annotate(Override.class);
JVar keyCode = method.param(codeModel().INT, "keyCode");
onKeyMultipleCountParam = method.param(codeModel().INT, "count");
onKeyMultipleKeyEventParam = method.param(getClasses().KEY_EVENT, "keyEvent");
JBlock methodBody = method.body();
onKeyMultipleSwitchBody = methodBody._switch(keyCode);
methodBody._return(_super().invoke(method).arg(keyCode).arg(onKeyMultipleCountParam).arg(onKeyDownKeyEventParam));
}
Aggregations