excilys/androidannotations — pull request #119 by nycholas (2012-02-25 23:55:13+00:00)
Title: Add GreenDroid support (issues #117)

New implementation
------------------

Adding GreenDroid support[1] in @EActivity.

Inspiration
-----------

Solution[2] of the problem is when we use the annotation @AfterViews and how it is executed after setContentView in the generated code, so it will never run.

```java
@Override
public void onCreate(Bundle savedInstanceState) {
init_(savedInstanceState);
super.onCreate(savedInstanceState);
}

@Override
public void setActionBarContentView(int layoutResID) {
super.setActionBarContentView(layoutResID);
afterSetContentView_();
}

@Override
public void setActionBarContentView(View view, LayoutParams params) {
super.setActionBarContentView(view, params);
afterSetContentView_();
}

@Override
public void setActionBarContentView(View view) {
super.setActionBarContentView(view);
afterSetContentView_();
}
```

How to use
----------

```java
@EActivity(value = R.layout.main, greendroid = true)
public class MainWindowActivity extends GDActivity {

}
```

Generated code
--------------

```java
@Override
public void onCreate(Bundle savedInstanceState) {
init_(savedInstanceState);
super.onCreate(savedInstanceState);
setActionBarContentView(layout.main);
}

@Override
public void setActionBarContentView(int layoutResID) {
super.setActionBarContentView(layoutResID);
afterSetContentView_();
}

@Override
public void setActionBarContentView(View view, LayoutParams params) {
super.setActionBarContentView(view, params);
afterSetContentView_();
}

@Override
public void setActionBarContentView(View view) {
super.setActionBarContentView(view);
afterSetContentView_();
}
```

[1] - https://github.com/excilys/androidannotations/issues/117
[2] - https://github.com/excilys/androidannotations/issues/117#issuecomment-4161606

So long and good luck,
Nycholas de Oliveira e Oliveira.