Working with Fragments and Keeping Your Sanity - DroidCon Zagreb 2016
At a first glance fragments may seem simple enough to use, however diving deeper reveals that fragments have a complex lifecycle (~ 14 lifecycle methods), and a lot of edge cases and pitfalls that need to be given special attention.
Fragment { onCreateView(...) { View view = inflater.inflate(...); mMoneyView = (MoneyView) view.findViewById(...); if (state != null) { // can be overridden with null! mSelectedCurrency = state.getState("state_currency"); } mMoneyView.setCurrency(mSelectedCurrency); } } class AmountFragment extends Fragment { if (state != null) { // can be overridden with null! mSelectedCurrency = state.getState("state_currency"); } } }
at android.support.v4.app.FragmentManagerImpl.enqueueAction at android.support.v4.app.BackStackRecord.commitInternal at android.support.v4.app.BackStackRecord.commit