Search in sources :

Example 1 with AndroidSystemServices

use of org.androidannotations.internal.core.model.AndroidSystemServices in project androidannotations by androidannotations.

the class SystemServiceHandler method assignValue.

@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentHolder holder, Element element, Element param) {
    TypeMirror serviceType = param.asType();
    String fieldTypeQualifiedName = serviceType.toString();
    JFieldRef serviceRef = new AndroidSystemServices(getEnvironment()).getServiceConstantRef(serviceType);
    if (CanonicalNameConstants.APP_WIDGET_MANAGER.equals(fieldTypeQualifiedName)) {
        targetBlock.add(fieldRef.assign(createSpecialInjection(holder, fieldTypeQualifiedName, serviceRef, 21, "LOLLIPOP", getClasses().APP_WIDGET_MANAGER, "getInstance", true)));
    } else {
        targetBlock.add(fieldRef.assign(createNormalInjection(holder, fieldTypeQualifiedName, serviceRef)));
    }
}
Also used : JFieldRef(com.helger.jcodemodel.JFieldRef) TypeMirror(javax.lang.model.type.TypeMirror) AndroidSystemServices(org.androidannotations.internal.core.model.AndroidSystemServices)

Example 2 with AndroidSystemServices

use of org.androidannotations.internal.core.model.AndroidSystemServices in project androidannotations by androidannotations.

the class ValidatorHelper method androidService.

public void androidService(Element element, ElementValidation valid) {
    Element targetElement = findTargetElement(element, valid);
    if (targetElement == null) {
        return;
    }
    AndroidSystemServices androidSystemServices = new AndroidSystemServices(environment());
    TypeMirror serviceType = targetElement.asType();
    if (!androidSystemServices.contains(serviceType)) {
        valid.addError("Unknown service type: " + serviceType.toString());
    }
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) VariableElement(javax.lang.model.element.VariableElement) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) Element(javax.lang.model.element.Element) AndroidSystemServices(org.androidannotations.internal.core.model.AndroidSystemServices)

Aggregations

TypeMirror (javax.lang.model.type.TypeMirror)2 AndroidSystemServices (org.androidannotations.internal.core.model.AndroidSystemServices)2 JFieldRef (com.helger.jcodemodel.JFieldRef)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1 VariableElement (javax.lang.model.element.VariableElement)1