excilys/androidannotations — pull request #355 by pyricau (2012-10-25 08:59:38+00:00)
Title: Recreating bean instance only if NonConfigurationInstance Bean is null

See #354

* Moved the processing order so that the `@NonConfigurationInstance` code is written in the `init_` body **before** the injection of beans
* Added a not null guard to the bean creation instance if it is annotated with `@NonConfigurationInstance`

So, for instance, the following code:

```java
@EActivity
public class NonConfigurationActivity extends Activity {

@Bean
@NonConfigurationInstance
EmptyDependency maintainedDependency;

@Bean
EmptyDependency recreatedDependency;

@NonConfigurationInstance
Object someObject;

}
```

Now generates the following `init_()` method:

```java
private void init_(Bundle savedInstanceState) {
NonConfigurationActivity_.NonConfigurationInstancesHolder nonConfigurationInstance = ((NonConfigurationActivity_.NonConfigurationInstancesHolder) super.getLastNonConfigurationInstance());
if (nonConfigurationInstance!= null) {
maintainedDependency = nonConfigurationInstance.maintainedDependency;
((EmptyDependency_) maintainedDependency).rebind(this);
someObject = nonConfigurationInstance.someObject;
}
if (maintainedDependency == null) {
maintainedDependency = EmptyDependency_.getInstance_(this);
}
recreatedDependency = EmptyDependency_.getInstance_(this);
}
```