Ability to update just one tab instead of all of them.
Sometimes we only want to update one of the tab title/icons without
updating the whole tab strip. For instance, when updating the unread
voicemail count.
Bug: 25124120
Change-Id: I4a53b3b2c2a870da845c6e4109dd184af9cf7e9d
diff --git a/src/com/android/contacts/common/list/ViewPagerTabs.java b/src/com/android/contacts/common/list/ViewPagerTabs.java
index 6ee1448..dd1fd9a 100644
--- a/src/com/android/contacts/common/list/ViewPagerTabs.java
+++ b/src/com/android/contacts/common/list/ViewPagerTabs.java
@@ -219,8 +219,9 @@
tabView.setOnLongClickListener(new OnTabLongClickListener(position));
tabView.setPadding(mSidePadding, 0, mSidePadding, 0);
- mTabStrip.addView(tabView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.MATCH_PARENT, 1));
+
+ mTabStrip.addView(tabView, position, new LinearLayout.LayoutParams(
+ LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1));
// Default to the first child being selected
if (position == 0) {
@@ -229,6 +230,17 @@
}
}
+ /**
+ * Refresh a tab at a certain index by removing it and reconstructing it.
+ *
+ * @param index The index of the tab view we wish to update.
+ */
+ public void updateTab(int index) {
+ View view = mTabStrip.getChildAt(index);
+ mTabStrip.removeView(view);
+ addTab(mPager.getAdapter().getPageTitle(index), index);
+ }
+
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
position = getRtlPosition(position);