-
Notifications
You must be signed in to change notification settings - Fork 1
InfinitumFragmentActivity
tylertreat edited this page Dec 31, 2012
·
1 revision
InfinitumFragmentActivity is an extension of Android's FragmentActivity which takes care of framework initialization, provides support for resource injection and event binding, and exposes an InfinitumContext.
When building a FragmentActivity that relies on Infinitum, it's typically good practice to extend InfinitumFragmentActivity rather than manually configuring the framework through the ContextFactory. InfinitumFragmentActivity also allows you to perform bean autowiring within the FragmentActivity as well as injecting layouts, views, and resources. Lastly, it allows you to bind event listeners to views so that you don't have to implement anonymous inner classes in your code.
@InjectLayout(R.layout.my_layout)
public class MyFragmentActivity extends InfinitumFragmentActivity {
@Autowired
private MyBean mMyBean;
@InjectResource(R.string.my_string)
private String mMyString;
@InjectView(R.id.my_button)
@Bind("buttonClicked")
private Button mMyButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initializeFragments();
InfinitumContext context = getInfinitumContext();
mMyBean.doStuff(context);
}
private void buttonClicked(View view) {
Toast.makeText(this, "Button clicked: " + mMyString, Toast.LENGTH_LONG).show();
}
// ...
}