final void updateTextPositions(int paramInt, float paramFloat, boolean paramBoolean) {
   Rect localRect = mTempRect;
   int i = getHeight();
   int j = mCurrText.getLeft();
   int k = mTabPadding;
   int m = mCurrText.getRight();
   int n = mTabPadding;
   int i1 = i - mIndicatorHeight;
   localRect.set(j - k, i1, m + n, i);
   super.updateTextPositions(paramInt, paramFloat, paramBoolean);
   mTabAlpha = ((int) (Math.abs(paramFloat - 0.5F) * 2.0F * 255.0F));
   localRect.union(mCurrText.getLeft() - mTabPadding, i1, mCurrText.getRight() + mTabPadding, i);
   invalidate(localRect);
 }
  @Override
  void updateTextPositions(int position, float positionOffset, boolean force) {
    final Rect r = mTempRect;
    int bottom = getHeight();
    int left = mCurrText.getLeft() - mTabPadding;
    int right = mCurrText.getRight() + mTabPadding;
    int top = bottom - mIndicatorHeight;

    r.set(left, top, right, bottom);

    super.updateTextPositions(position, positionOffset, force);
    mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF);

    left = mCurrText.getLeft() - mTabPadding;
    right = mCurrText.getRight() + mTabPadding;
    r.union(left, top, right, bottom);

    invalidate(r);
  }
예제 #3
0
  void updateText(int currentItem, PagerAdapter adapter) {
    final int itemCount = adapter != null ? adapter.getCount() : 0;
    mUpdatingText = true;

    CharSequence text = null;
    if (currentItem >= 1 && adapter != null) {
      text = adapter.getPageTitle(currentItem - 1);
    }
    mPrevText.setText(text);

    mCurrText.setText(adapter != null ? adapter.getPageTitle(currentItem) : null);

    text = null;
    if (currentItem + 1 < itemCount && adapter != null) {
      text = adapter.getPageTitle(currentItem + 1);
    }
    mNextText.setText(text);

    // Measure everything
    final int width = getWidth() - getPaddingLeft() - getPaddingRight();
    final int childHeight = getHeight() - getPaddingTop() - getPaddingBottom();
    final int childWidthSpec =
        MeasureSpec.makeMeasureSpec((int) (width * 0.8f), MeasureSpec.AT_MOST);
    final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY);
    mPrevText.measure(childWidthSpec, childHeightSpec);
    mCurrText.measure(childWidthSpec, childHeightSpec);
    mNextText.measure(childWidthSpec, childHeightSpec);

    mLastKnownCurrentPage = currentItem;

    if (!mUpdatingPositions) {
      updateTextPositions(currentItem, mLastKnownPositionOffset);
    }

    mUpdatingText = false;
  }
예제 #4
0
 @Override
 protected void onLayout(boolean changed, int l, int t, int r, int b) {
   if (mPager != null) {
     updateTextPositions(mPager.getCurrentItem(), 0.f);
   }
 }