Fix refresh problem in the contact card
- Reset the contact data on the fragments after onLoadFinished() is called
so any editor changes will actually update the contact card now
- Fix the issue of the details list going blank by only creating max 1
ViewPagerAdapter per ContactDetailActivity. Check if the layout's already
been setup or not and then go ahead with setting the new contact data
Bug: 5011155
Bug: 4991868
Change-Id: I6ff0613413692212c9ffd23472450e9853b00f54
diff --git a/src/com/android/contacts/activities/ContactDetailActivity.java b/src/com/android/contacts/activities/ContactDetailActivity.java
index 800bfb1..47568b8 100644
--- a/src/com/android/contacts/activities/ContactDetailActivity.java
+++ b/src/com/android/contacts/activities/ContactDetailActivity.java
@@ -323,28 +323,40 @@
mContentView = (ViewGroup) mInflater.inflate(
R.layout.contact_detail_container_with_updates, mRootView, false);
mRootView.addView(mContentView);
+
+ // Make sure all needed views are retrieved. Note that narrow width screens have a
+ // {@link ViewPager} and {@link ContactDetailTabCarousel}, while wide width screens have
+ // a {@link ContactDetailFragmentCarousel}.
+ mViewPager = (ViewPager) findViewById(R.id.pager);
+ if (mViewPager != null) {
+ mViewPager.removeAllViews();
+ mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));
+ mViewPager.setOnPageChangeListener(mOnPageChangeListener);
+ }
+
+ mTabCarousel = (ContactDetailTabCarousel) findViewById(R.id.tab_carousel);
+ if (mTabCarousel != null) {
+ mTabCarousel.setListener(mTabCarouselListener);
+ }
+
+ mFragmentCarousel = (ContactDetailFragmentCarousel)
+ findViewById(R.id.fragment_carousel);
}
- // Narrow width screens have a {@link ViewPager} and {@link ContactDetailTabCarousel}
- mViewPager = (ViewPager) findViewById(R.id.pager);
- if (mViewPager != null) {
- mViewPager.removeAllViews();
- mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));
- mViewPager.setOnPageChangeListener(mOnPageChangeListener);
- }
-
- mTabCarousel = (ContactDetailTabCarousel) findViewById(R.id.tab_carousel);
+ // Then reset the contact data to the appropriate views
if (mTabCarousel != null) {
- mTabCarousel.setListener(mTabCarouselListener);
mTabCarousel.loadData(mContactData);
}
-
- // Otherwise, wide width screens have a {@link ContactDetailFragmentCarousel}
- mFragmentCarousel = (ContactDetailFragmentCarousel) findViewById(R.id.fragment_carousel);
if (mFragmentCarousel != null) {
if (mDetailFragment != null) mFragmentCarousel.setAboutFragment(mDetailFragment);
if (mUpdatesFragment != null) mFragmentCarousel.setUpdatesFragment(mUpdatesFragment);
}
+ if (mDetailFragment != null) {
+ mDetailFragment.setData(mLookupUri, mContactData);
+ }
+ if (mUpdatesFragment != null) {
+ mUpdatesFragment.setData(mLookupUri, mContactData);
+ }
}
private void setupContactWithoutUpdates() {
@@ -353,6 +365,10 @@
R.layout.contact_detail_container_without_updates, mRootView, false);
mRootView.addView(mContentView);
}
+ // Reset contact data
+ if (mDetailFragment != null) {
+ mDetailFragment.setData(mLookupUri, mContactData);
+ }
}
private final ContactDetailFragment.Listener mFragmentListener =