Search in sources :

Example 1 with FoundPreferenceHolder

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

the class AbstractPreferenceListenerHandler method assignListeners.

@Override
protected final void assignListeners(HasPreferences holder, List<JFieldRef> idsRefs, JDefinedClass listenerAnonymousClass) {
    for (JFieldRef idRef : idsRefs) {
        FoundPreferenceHolder foundPreferenceHolder = holder.getFoundPreferenceHolder(idRef, getListenerTargetClass(holder));
        foundPreferenceHolder.getIfNotNullBlock().invoke(foundPreferenceHolder.getRef(), getSetterName()).arg(_new(listenerAnonymousClass));
    }
}
Also used : JFieldRef(com.helger.jcodemodel.JFieldRef) FoundPreferenceHolder(org.androidannotations.holder.FoundPreferenceHolder)

Example 2 with FoundPreferenceHolder

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

Aggregations

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