private void haveAfterTextChangedMethodParameters( ExecutableElement executableElement, IsValid valid) { List<? extends VariableElement> parameters = executableElement.getParameters(); boolean editableParameterFound = false; boolean textViewParameterFound = false; for (VariableElement parameter : parameters) { String parameterType = parameter.asType().toString(); if (parameterType.equals("android.text.Editable")) { if (editableParameterFound) { annotationHelper.printAnnotationError( executableElement, "Unrecognized parameter declaration. you can declare only one parameter of type android.text.Editable"); valid.invalidate(); } editableParameterFound = true; continue; } if (parameterType.equals("android.widget.TextView")) { if (textViewParameterFound) { annotationHelper.printAnnotationError( executableElement, "Unrecognized parameter declaration. you can declare only one parameter of type android.widget.TextView"); valid.invalidate(); } textViewParameterFound = true; continue; } valid.invalidate(); annotationHelper.printAnnotationError( executableElement, "Unrecognized parameter type. %s can only have a android.widget.TextView parameter and/or an android.text.Editable parameter. See android.text.TextWatcher.afterTextChanged() for more informations."); } }
@Override public void process(Element element, JCodeModel codeModel, EBeanHolder holder) { Classes classes = holder.classes(); String fieldName = element.getSimpleName().toString(); Res resInnerClass = androidValue.getRInnerClass(); JFieldRef idRef = annotationHelper.extractOneAnnotationFieldRef(holder, element, resInnerClass, true); JBlock methodBody = holder.init.body(); TypeMirror fieldTypeMirror = element.asType(); String fieldType = fieldTypeMirror.toString(); // Special case for loading animations if (CanonicalNameConstants.ANIMATION.equals(fieldType)) { methodBody.assign( ref(fieldName), classes.ANIMATION_UTILS.staticInvoke("loadAnimation").arg(holder.contextRef).arg(idRef)); } else { if (holder.resources == null) { holder.resources = methodBody.decl( classes.RESOURCES, "resources_", holder.contextRef.invoke("getResources")); } String resourceMethodName = androidValue.getResourceMethodName(); // Special case for @HtmlRes if (element.getAnnotation(HtmlRes.class) != null) { methodBody.assign( ref(fieldName), classes .HTML .staticInvoke("fromHtml") .arg(invoke(holder.resources, resourceMethodName).arg(idRef))); } else { methodBody.assign(ref(fieldName), invoke(holder.resources, resourceMethodName).arg(idRef)); } } }