Search in sources :

Example 1 with FoundViewHolder

use of org.androidannotations.holder.FoundViewHolder in project androidannotations by androidannotations.

the class ViewsByIdHandler method addViewToListIfNotNull.

private void addViewToListIfNotNull(IJExpression elementRef, AbstractJClass viewClass, JFieldRef idRef, EComponentWithViewSupportHolder holder) {
    FoundViewHolder foundViewHolder = holder.getFoundViewHolder(idRef, viewClass);
    foundViewHolder.getIfNotNullBlock().invoke(elementRef, "add").arg(foundViewHolder.getOrCastRef(viewClass));
}
Also used : FoundViewHolder(org.androidannotations.holder.FoundViewHolder)

Example 2 with FoundViewHolder

use of org.androidannotations.holder.FoundViewHolder 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)));
    }
}
Also used : JFieldRef(com.helger.jcodemodel.JFieldRef) TypeMirror(javax.lang.model.type.TypeMirror) IJAssignmentTarget(com.helger.jcodemodel.IJAssignmentTarget) FoundViewHolder(org.androidannotations.holder.FoundViewHolder) AbstractJClass(com.helger.jcodemodel.AbstractJClass)

Example 3 with FoundViewHolder

use of org.androidannotations.holder.FoundViewHolder in project androidannotations by androidannotations.

the class AbstractViewListenerHandler method assignListeners.

@Override
protected final void assignListeners(EComponentWithViewSupportHolder holder, List<JFieldRef> idsRefs, JDefinedClass listenerAnonymousClass) {
    for (JFieldRef idRef : idsRefs) {
        AbstractJClass listenerTargetClass = getListenerTargetClass(holder);
        FoundViewHolder foundViewHolder = holder.getFoundViewHolder(idRef, listenerTargetClass);
        foundViewHolder.getIfNotNullBlock().invoke(foundViewHolder.getOrCastRef(listenerTargetClass), getSetterName()).arg(_new(listenerAnonymousClass));
    }
}
Also used : JFieldRef(com.helger.jcodemodel.JFieldRef) FoundViewHolder(org.androidannotations.holder.FoundViewHolder) AbstractJClass(com.helger.jcodemodel.AbstractJClass)

Aggregations

FoundViewHolder (org.androidannotations.holder.FoundViewHolder)3 AbstractJClass (com.helger.jcodemodel.AbstractJClass)2 JFieldRef (com.helger.jcodemodel.JFieldRef)2 IJAssignmentTarget (com.helger.jcodemodel.IJAssignmentTarget)1 TypeMirror (javax.lang.model.type.TypeMirror)1