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

Commit e09b8e2c authored by Nancy Chen's avatar Nancy Chen Committed by Android (Google) Code Review
Browse files

Merge "Ability to update just one tab instead of all of them." into ub-contactsdialer-a-dev

parents e8862171 0efa197c
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);