Use new "deferred fragments" feature on People
Apply the same technique which was recently introduced in
FragmentPagerAdapter in Ied454a6f.
Bug 5543639
Change-Id: If059589e0b1bfe2292c04eebb709800c1a41071a
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index b4ad78a..12f7e8c 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -739,6 +739,8 @@
private boolean mTabPagerAdapterSearchMode;
+ private Fragment mCurrentPrimaryItem;
+
public TabPagerAdapter() {
mFragmentManager = getFragmentManager();
}
@@ -809,6 +811,9 @@
}
Fragment f = getFragment(position);
mCurTransaction.show(f);
+
+ // Non primary pages should be deferred.
+ f.setStartDeferred(f != mCurrentPrimaryItem);
return f;
}
@@ -835,6 +840,20 @@
}
@Override
+ public void setPrimaryItem(View container, int position, Object object) {
+ Fragment fragment = (Fragment) object;
+ if (mCurrentPrimaryItem != fragment) {
+ if (mCurrentPrimaryItem != null) {
+ mCurrentPrimaryItem.setStartDeferred(true);
+ }
+ if (fragment != null) {
+ fragment.setStartDeferred(false);
+ }
+ mCurrentPrimaryItem = fragment;
+ }
+ }
+
+ @Override
public Parcelable saveState() {
return null;
}