Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0efa197c authored by Nancy Chen's avatar Nancy Chen
Browse files

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
parent 9fea7488
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -219,8 +219,9 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
        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 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
        }
    }

    /**
     * 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);