use of com.helger.jcodemodel.JInvocation 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.JInvocation 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.JInvocation 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.JInvocation 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.JInvocation in project androidannotations by androidannotations.
the class RestHandler method setConverters.
private void setConverters(Element element, RestHolder holder) {
List<DeclaredType> converters = annotationHelper.extractAnnotationClassArrayParameter(element, getTarget(), "converters");
JFieldVar restTemplateField = holder.getRestTemplateField();
JBlock init = holder.getInit().body();
init.add(invoke(restTemplateField, "getMessageConverters").invoke("clear"));
for (DeclaredType converterType : converters) {
JInvocation newConverter = codeModelHelper.newBeanOrEBean(converterType, holder.getInitContextParam());
init.add(invoke(restTemplateField, "getMessageConverters").invoke("add").arg(newConverter));
}
}
Aggregations