From 1afe00c0e4eef5170beba7bfe99106a5297b5460 Mon Sep 17 00:00:00 2001 From: roldenburg Date: Fri, 13 Oct 2017 15:31:54 -0700 Subject: Do not load every DialtactsActivity fragment on app open With this change we now only load the Favorites and Call Log Fragments when the app opens. Paging to the CallLogFragment makes the ContactsFragment load as we would want. This should result in a faster app start time. I'll need to verify the impact of this using the same method as http://cl/170422671 I verified the change in behavior by adding my own log line to the onCreate of each Fragment. I saw all of them get created before the change, and only the expected 2 with this change. Bug: 64541209,65460373 Test: manual PiperOrigin-RevId: 172154863 Change-Id: Iaf6e217df284e6df6f13688ac6aa677481a575e0 --- java/com/android/dialer/app/list/ListsFragment.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'java/com/android/dialer') diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java index 362997a5a..05c647aec 100644 --- a/java/com/android/dialer/app/list/ListsFragment.java +++ b/java/com/android/dialer/app/list/ListsFragment.java @@ -203,7 +203,11 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis mPrefs.getBoolean( VisualVoicemailEnabledChecker.PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, false)); mViewPager.setAdapter(mAdapter); - mViewPager.setOffscreenPageLimit(DialtactsPagerAdapter.TAB_COUNT_WITH_VOICEMAIL - 1); + + // This is deliberate. See cl/172018946 for the app startup implications of using 1 here + // versus loading more fragments upfront. + mViewPager.setOffscreenPageLimit(1); + mViewPager.addOnPageChangeListener(this); showTab(DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL); -- cgit v1.2.3