- In general you want to try and put things in
onStart
andonStop
for logical start and stops.
- Dagger inject self into graph
- setContentView(R.layout.xxx)
- Butterknife.bind(this)
- RxJava CompositeSubscription.add (if NON UI related work being done)
- realm = Realm.getDefaultInstance();
- EventBus register // why not onResume + onPause you ask?
- RxJava CompositeSubscription.add (if ui related work being done)
- RxJava CompositeSubscription.clear (if ui related work being done)
- EventBus unregister
- Dagger "Activity" scoped graph destruction
- RxJava CompositeSubscription.clear (if NON UI related work being done)
- realm.close();
- Dagger inject self into graph
- setCallbackOrListener(activity) - when you want to communicate back to the activity
Warning: lifecycle callpoint is subtly different now. onAttach(Context) is called later than onAttach(Activity) and so if you expected the injection to have happened before certain callbacks like onViewCreated this is not the case (e.g. API 19)
- view = Inflate.inflation
- ButterKnife.bind(this, view);
- realm = Realm.getDefaultInstance();
- EventBus register
- RxJava CompositeSubscription.add (if ui related work being done)
- RxJava CompositeSubscription.clear (if ui related work being done)
- EventBus unregister
- LeakCanary MyApp.getRefWatcher().watch(this);
- ButterKnife.unbind(this);
- realm.close();
- Butterknife.bind(this)
- RxJava CompositeSubscription.add
- RxJava CompositeSubscription.clear
- LeakCanary Refwatcher = LeakCanary.install(this);
- Dagger ObjectGraph.create
- Butterknife.bind(this. itemView)
Technicality aside, I'm genuinely interested in what capacity you use EventBus and for what? Since you do agree that RxJava > EventBus. I'd like not to go on a big tangent here, but would just like to say that I find EB useful only in stateless environments, such as very long running tasks which are rare in Android (like background services, EB is a cool way to notify the service about news, like POST in REST).
Additionally, I'd just add
onAttach
in Fragment for fragment callback listener.Thoughts?