excilys/androidannotations — pull request #678 by tbruyelle (2013-07-26 07:40:51+00:00)
Title: Log a warning when a @RootContext field isn't populated

Related to #674

When a bean is injected in another class which has a different Context
from the required @RootContext field class, the field is left null. This
could produce hard to find bugs. The fix adds a log to warn the user.

The generated code from `EnhancedClass_` :

```java
@SuppressWarnings("all")
private void init_() {
if (context_ instanceof Activity) {
Activity activity = ((Activity) context_);
}
OnViewChangedNotifier.registerOnViewChangedListener(this);
Resources resources_ = context_.getResources();
hello = resources_.getString(string.hello);
activityManager = ((ActivityManager) context_.getSystemService(Context.ACTIVITY_SERVICE));
customApplication = SampleRoboApplication_.getInstance();
if (context_ instanceof ThreadActivity) {
threadActivity = ((ThreadActivity) context_);
} else {
Log.w("EnhancedClass_", (("Due to Context class "+ context_.getClass().getSimpleName())+", the @RootContext ThreadActivity won't be populated"));
}
context = context_;
if (context_ instanceof Service) {
service = ((Service) context_);
} else {
Log.w("EnhancedClass_", (("Due to Context class "+ context_.getClass().getSimpleName())+", the @RootContext Service won't be populated"));
}
if (context_ instanceof Activity) {
activity = ((Activity) context_);
} else {
Log.w("EnhancedClass_", (("Due to Context class "+ context_.getClass().getSimpleName())+", the @RootContext Activity won't be populated"));
}
secondDependency = SecondDependency_.getInstance_(context_);
calledAfterInjection();
}
```

I don't know very well Codemodel yet, please check if I used it well.