Skip to content

Commit 38ce56b

Browse files
committed
Removing the warning when a receiver is not registered. androidannotations#123
1 parent 84593d2 commit 38ce56b

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/ValidatorHelper.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,10 @@ private boolean isKnowInstanceStateType(String type) {
949949
}
950950

951951
public void componentRegistered(Element element, AndroidManifest androidManifest, IsValid valid) {
952+
componentRegistered(element, androidManifest, true, valid);
953+
}
954+
955+
public void componentRegistered(Element element, AndroidManifest androidManifest, boolean printWarning, IsValid valid) {
952956
TypeElement typeElement = (TypeElement) element;
953957

954958
if (typeElement.getModifiers().contains(Modifier.ABSTRACT)) {
@@ -966,7 +970,9 @@ public void componentRegistered(Element element, AndroidManifest androidManifest
966970
valid.invalidate();
967971
annotationHelper.printAnnotationError(element, "The AndroidManifest.xml file contains the original component, and not the AndroidAnnotations generated component. Please register " + generatedSimpleName + " instead of " + simpleName);
968972
} else {
969-
annotationHelper.printAnnotationWarning(element, "The component " + generatedSimpleName + " is not registered in the AndroidManifest.xml file.");
973+
if (printWarning) {
974+
annotationHelper.printAnnotationWarning(element, "The component " + generatedSimpleName + " is not registered in the AndroidManifest.xml file.");
975+
}
970976
}
971977
}
972978

AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/EReceiverValidator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public boolean validate(Element element, AnnotationElements validatedElements) {
5454

5555
validatorHelper.isNotAbstract(element, valid);
5656

57-
validatorHelper.componentRegistered(element, androidManifest, valid);
57+
final boolean NO_WARNING = false;
58+
validatorHelper.componentRegistered(element, androidManifest, NO_WARNING, valid);
5859

5960
return valid.isValid();
6061
}

AndroidAnnotations/functional-test-1-5/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<activity android:name="com.googlecode.androidannotations.test15.instancestate.SaveInstanceStateActivity_" />
6060
<activity android:name="com.googlecode.androidannotations.test15.afterinject.AfterInjectActivity_" />
6161
<activity android:name="com.googlecode.androidannotations.test15.greendroid.MyGreenDroidActivity_" />
62+
6263
<receiver android:name="com.googlecode.androidannotations.test15.ereceiver.MyReceiver_" />
6364

6465
<provider

AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/ereceiver/MyReceiver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public void onReceive(Context context, Intent intent) {
4545
showToast(context);
4646
workInBackground();
4747
}
48-
48+
49+
4950
@Trace
5051
@UiThread
5152
void showToast(Context context) {

0 commit comments

Comments
 (0)