use of com.helger.jcodemodel.JFieldRef in project androidannotations by androidannotations.
the class InstanceStateHandler method process.
@Override
public void process(Element element, HasInstanceState holder) {
AbstractJClass elementClass = codeModelHelper.typeMirrorToJClass(element.asType());
String fieldName = element.getSimpleName().toString();
JBlock saveStateBody = holder.getSaveStateMethodBody();
JVar saveStateBundleParam = holder.getSaveStateBundleParam();
JMethod restoreStateMethod = holder.getRestoreStateMethod();
JBlock restoreStateBody = holder.getRestoreStateMethodBody();
JVar restoreStateBundleParam = holder.getRestoreStateBundleParam();
TypeMirror type = codeModelHelper.getActualType(element, holder);
BundleHelper bundleHelper = new BundleHelper(getEnvironment(), type);
JFieldRef ref = ref(fieldName);
saveStateBody.add(bundleHelper.getExpressionToSaveFromField(saveStateBundleParam, JExpr.lit(fieldName), ref));
IJExpression restoreMethodCall = bundleHelper.getExpressionToRestoreFromBundle(elementClass, restoreStateBundleParam, JExpr.lit(fieldName), restoreStateMethod);
restoreStateBody.assign(ref, restoreMethodCall);
}
use of com.helger.jcodemodel.JFieldRef in project androidannotations by androidannotations.
the class ViewsByIdHandler method assignValue.
@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentWithViewSupportHolder holder, Element element, Element param) {
TypeMirror viewType = extractViewClass(param);
AbstractJClass viewClass = codeModelHelper.typeMirrorToJClass(viewType);
String listName = getListName(element, param);
IJExpression arrayList = instantiateArrayList(viewType, holder, "list_" + listName);
List<JFieldRef> idsRefs = annotationHelper.extractAnnotationFieldRefs(element, IRClass.Res.ID, true);
for (JFieldRef idRef : idsRefs) {
addViewToListIfNotNull(arrayList, viewClass, idRef, holder);
}
targetBlock.add(fieldRef.assign(arrayList));
}
use of com.helger.jcodemodel.JFieldRef in project androidannotations by androidannotations.
the class OptionsMenuHandler method process.
@Override
public void process(Element element, HasOptionsMenu holder) {
JBlock body = holder.getOnCreateOptionsMenuMethodInflateBody();
JVar menuInflater = holder.getOnCreateOptionsMenuMenuInflaterVar();
JVar menuParam = holder.getOnCreateOptionsMenuMenuParam();
List<JFieldRef> fieldRefs = annotationHelper.extractAnnotationFieldRefs(element, IRClass.Res.MENU, false);
for (JFieldRef optionsMenuRefId : fieldRefs) {
body.invoke(menuInflater, "inflate").arg(optionsMenuRefId).arg(menuParam);
}
}
Aggregations