- 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)
Hi Kaushik,
I think it is better to start listening the event bus during the first
onResume
.After
onStart
onRestoreInstanceState
will be fired, so if you get an event duringonStart
and update your views the new view state will be erased by the previous state.