use of org.androidannotations.annotations.Receiver in project androidannotations by androidannotations.
the class ReceiverHandler method process.
@Override
public void process(Element element, HasReceiverRegistration holder) throws Exception {
String methodName = element.getSimpleName().toString();
String receiverName = methodName + "Receiver" + generationSuffix();
Receiver annotation = element.getAnnotation(Receiver.class);
String[] actions = annotation.actions();
String[] dataSchemes = annotation.dataSchemes();
Receiver.RegisterAt registerAt = annotation.registerAt();
boolean local = annotation.local();
JFieldVar intentFilterField = holder.getIntentFilterField(new IntentFilterData(actions, dataSchemes, registerAt));
JFieldVar receiverField = createReceiverField(holder, receiverName, methodName, (ExecutableElement) element);
registerAndUnregisterReceiver(holder, registerAt, intentFilterField, receiverField, local);
}
use of org.androidannotations.annotations.Receiver in project androidannotations by androidannotations.
the class CoreValidatorHelper method hasRightRegisterAtValueDependingOnEnclosingElement.
public void hasRightRegisterAtValueDependingOnEnclosingElement(Element element, ElementValidation valid) {
Element enclosingElement = element.getEnclosingElement();
Receiver.RegisterAt registerAt = element.getAnnotation(Receiver.class).registerAt();
Map<String, List<Receiver.RegisterAt>> validRegisterAts = new HashMap<>();
validRegisterAts.put(CanonicalNameConstants.ACTIVITY, VALID_ACTIVITY_REGISTER_AT);
validRegisterAts.put(CanonicalNameConstants.SERVICE, VALID_SERVICE_REGISTER_AT);
validRegisterAts.put(CanonicalNameConstants.FRAGMENT, VALID_FRAGMENT_REGISTER_AT);
validRegisterAts.put(CanonicalNameConstants.VIEW, VALID_VIEW_REGISTER_AT);
for (Map.Entry<String, List<Receiver.RegisterAt>> validRegisterAt : validRegisterAts.entrySet()) {
String enclosingType = validRegisterAt.getKey();
Collection<Receiver.RegisterAt> validRegisterAtValues = validRegisterAt.getValue();
if (extendsType(enclosingElement, enclosingType) && !validRegisterAtValues.contains(registerAt)) {
valid.addError("The parameter registerAt of @Receiver in " + enclosingType + " can only be one of the following values : " + validRegisterAtValues);
}
}
}
Aggregations