use of com.helger.jcodemodel.IJAssignmentTarget in project androidannotations by androidannotations.
the class ViewByIdHandler method assignValue.
@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentWithViewSupportHolder holder, Element element, Element param) {
TypeMirror uiFieldTypeMirror = param.asType();
JFieldRef idRef = annotationHelper.extractOneAnnotationFieldRef(element, IRClass.Res.ID, true);
AbstractJClass viewClass = codeModelHelper.typeMirrorToJClass(uiFieldTypeMirror);
IJAssignmentTarget viewHolderTarget = null;
if (element.getKind() == ElementKind.FIELD) {
viewHolderTarget = fieldRef;
}
FoundViewHolder viewHolder = holder.getFoundViewHolder(idRef, viewClass, viewHolderTarget);
if (!viewHolder.getRef().equals(viewHolderTarget)) {
targetBlock.add(fieldRef.assign(viewHolder.getOrCastRef(viewClass)));
}
}
use of com.helger.jcodemodel.IJAssignmentTarget in project androidannotations by androidannotations.
the class PreferenceByKeyHandler method assignValue.
@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, HasPreferences holder, Element element, Element param) {
TypeMirror prefFieldTypeMirror = param.asType();
String typeQualifiedName = prefFieldTypeMirror.toString();
JFieldRef idRef = annotationHelper.extractOneAnnotationFieldRef(element, IRClass.Res.STRING, true);
AbstractJClass preferenceClass = getJClass(typeQualifiedName);
IJAssignmentTarget preferenceHolderTarget = null;
if (element.getKind() == ElementKind.FIELD) {
preferenceHolderTarget = fieldRef;
}
FoundPreferenceHolder preferenceHolder = holder.getFoundPreferenceHolder(idRef, preferenceClass, preferenceHolderTarget);
if (!preferenceHolder.getRef().equals(preferenceHolderTarget)) {
targetBlock.add(fieldRef.assign(preferenceHolder.getOrCastRef(preferenceClass)));
}
}
use of com.helger.jcodemodel.IJAssignmentTarget in project androidannotations by androidannotations.
the class EComponentWithViewSupportHolder method createFoundViewAndIfNotNullBlock.
protected FoundViewHolder createFoundViewAndIfNotNullBlock(JFieldRef idRef, AbstractJClass viewClass, IJAssignmentTarget fieldRef) {
IJExpression findViewExpression = findViewById(idRef);
JBlock block = getOnViewChangedBodyBeforeInjectionBlock();
if (viewClass == null) {
viewClass = getClasses().VIEW;
}
IJAssignmentTarget foundView = fieldRef;
if (foundView == null) {
JVar view = block.decl(viewClass, "view_" + idRef.name(), findViewExpression);
if (viewClass.isParameterized()) {
codeModelHelper.addSuppressWarnings(view, "unchecked");
}
foundView = view;
} else {
block.add(foundView.assign(findViewExpression));
}
return new FoundViewHolder(this, viewClass, foundView, getOnViewChangedBodyViewHolderBlock());
}
use of com.helger.jcodemodel.IJAssignmentTarget in project androidannotations by androidannotations.
the class PreferencesDelegate method createFoundPreferenceAndIfNotNullBlock.
private FoundPreferenceHolder createFoundPreferenceAndIfNotNullBlock(JFieldRef idRef, AbstractJClass preferenceClass, IJAssignmentTarget fieldRef) {
IJExpression findPreferenceExpression = findPreferenceByKey(idRef);
JBlock block = getAddPreferencesFromResourceInjectionBlock();
if (preferenceClass == null) {
preferenceClass = basePreferenceClass;
} else if (!preferenceClass.equals(basePreferenceClass)) {
findPreferenceExpression = cast(preferenceClass, findPreferenceExpression);
}
IJAssignmentTarget foundPref = fieldRef;
if (foundPref == null) {
foundPref = block.decl(preferenceClass, "preference_" + idRef.name(), findPreferenceExpression);
} else {
block.add(foundPref.assign(findPreferenceExpression));
}
return new FoundPreferenceHolder(this, preferenceClass, foundPref, block);
}
Aggregations