Java Code Examples for org.chromium.ui.base.LocalizationUtils#isLayoutRtl()

The following examples show how to use org.chromium.ui.base.LocalizationUtils#isLayoutRtl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayoutManagerChrome.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void didAddTab(Tab tab, TabLaunchType launchType) {
    int tabId = tab.getId();
    if (launchType == TabLaunchType.FROM_RESTORE) {
        getActiveLayout().onTabRestored(time(), tabId);
    } else {
        boolean incognito = tab.isIncognito();
        boolean willBeSelected = launchType != TabLaunchType.FROM_LONGPRESS_BACKGROUND
                || (!getTabModelSelector().isIncognitoSelected() && incognito);
        float lastTapX = LocalizationUtils.isLayoutRtl() ? mLastContentWidthDp : 0.f;
        float lastTapY = 0.f;
        if (launchType != TabLaunchType.FROM_CHROME_UI) {
            float heightDelta =
                    mLastFullscreenViewportDp.height() - mLastVisibleViewportDp.height();
            lastTapX = mPxToDp * mLastTapX;
            lastTapY = mPxToDp * mLastTapY - heightDelta;
        }

        tabCreated(tabId, getTabModelSelector().getCurrentTabId(), launchType, incognito,
                willBeSelected, lastTapX, lastTapY);
    }
}
 
Example 2
Source File: StripLayoutHelper.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void updateNewTabButtonState() {
    // 1. Don't display the new tab button if we're in reorder mode.
    if (mInReorderMode || mStripTabs.length == 0) {
        mNewTabButton.setVisible(false);
        return;
    }

    // 1. Get offset from strip stacker.
    float offset = mStripStacker.computeNewTabButtonOffset(mStripTabs,
            mTabOverlapWidth, mLeftMargin, mRightMargin, mWidth, mNewTabButtonWidth);

    // 2. Hide the new tab button if it's not visible on the screen.
    boolean isRtl = LocalizationUtils.isLayoutRtl();
    if ((isRtl && offset + mNewTabButtonWidth < 0) || (!isRtl && offset > mWidth)) {
        mNewTabButton.setVisible(false);
        return;
    }
    mNewTabButton.setVisible(true);

    // 3. Position the new tab button.
    mNewTabButton.setX(offset);
}
 
Example 3
Source File: LocationBarTablet.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Updates completion percentage for the location bar width change animation.
 * @param percent How complete the animation is, where 0 represents the normal width (toolbar
 *                buttons fully visible) and 1.f represents the expanded width (toolbar buttons
 *                fully hidden).
 */
private void setWidthChangeAnimationPercent(float percent) {
    mWidthChangePercent = percent;
    float offset = (mToolbarButtonsWidth + mToolbarStartPaddingDifference) * percent;

    if (LocalizationUtils.isLayoutRtl()) {
        // The location bar's right edge is its regular layout position when toolbar buttons are
        // completely visible and its layout position + mToolbarButtonsWidth when toolbar
        // buttons are completely hidden.
        setRight((int) (mLayoutRight + offset));
    } else {
        // The location bar's left edge is it's regular layout position when toolbar buttons are
        // completely visible and its layout position - mToolbarButtonsWidth when they are
        // completely hidden.
        setLeft((int) (mLayoutLeft - offset));
    }

    // As the location bar's right edge moves right (increases) or left edge moves left
    // (decreases), the child views' translation X increases, keeping them visually in the same
    // location for the duration of the animation.
    int deleteOffset = (int) (mMicButtonWidth * percent);
    setChildTranslationsForWidthChangeAnimation((int) offset, deleteOffset);
}
 
Example 4
Source File: StripLayoutHelperManager.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onSizeChanged(
        float width, float height, float visibleViewportOffsetY, int orientation) {
    mWidth = width;
    mOrientation = orientation;
    if (!LocalizationUtils.isLayoutRtl()) {
        mModelSelectorButton.setX(
                mWidth - MODEL_SELECTOR_BUTTON_WIDTH_DP - MODEL_SELECTOR_BUTTON_END_PADDING_DP);
    } else {
        mModelSelectorButton.setX(MODEL_SELECTOR_BUTTON_END_PADDING_DP);
    }

    mNormalHelper.onSizeChanged(mWidth, mHeight);
    mIncognitoHelper.onSizeChanged(mWidth, mHeight);

    mStripFilterArea.set(0, 0, mWidth, Math.min(getHeight(), visibleViewportOffsetY));
    mEventFilter.setEventArea(mStripFilterArea);
}
 
Example 5
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void didAddTab(Tab tab, TabLaunchType launchType) {
    int tabId = tab.getId();
    if (launchType != TabLaunchType.FROM_RESTORE) {
        boolean incognito = tab.isIncognito();
        boolean willBeSelected = launchType != TabLaunchType.FROM_LONGPRESS_BACKGROUND
                || (!getTabModelSelector().isIncognitoSelected() && incognito);
        float lastTapX = LocalizationUtils.isLayoutRtl() ? mLastContentWidthDp : 0.f;
        float lastTapY = 0.f;
        if (launchType != TabLaunchType.FROM_CHROME_UI) {
            float heightDelta =
                    mLastFullscreenViewportDp.height() - mLastVisibleViewportDp.height();
            lastTapX = mPxToDp * mLastTapX;
            lastTapY = mPxToDp * mLastTapY - heightDelta;
        }

        tabCreated(tabId, getTabModelSelector().getCurrentTabId(), launchType, incognito,
                willBeSelected, lastTapX, lastTapY);
    }
}
 
Example 6
Source File: ScrollingStripStacker.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public float computeNewTabButtonOffset(StripLayoutTab[] indexOrderedTabs,
        float tabOverlapWidth, float stripLeftMargin, float stripRightMargin, float stripWidth,
        float newTabButtonWidth) {
    return LocalizationUtils.isLayoutRtl()
            ? computeNewTabButtonOffsetRtl(indexOrderedTabs, tabOverlapWidth, stripRightMargin,
                    stripWidth, newTabButtonWidth)
                            : computeNewTabButtonOffsetLtr(indexOrderedTabs, tabOverlapWidth,
                                    stripLeftMargin, stripWidth);
}
 
Example 7
Source File: StripLayoutTab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private RectF getCloseRect() {
    if (!LocalizationUtils.isLayoutRtl()) {
        mClosePlacement.left = getWidth() - CLOSE_BUTTON_WIDTH_DP;
        mClosePlacement.right = mClosePlacement.left + CLOSE_BUTTON_WIDTH_DP;
    } else {
        mClosePlacement.left = 0;
        mClosePlacement.right = CLOSE_BUTTON_WIDTH_DP;
    }

    mClosePlacement.top = 0;
    mClosePlacement.bottom = getHeight();

    float xOffset = 0;
    ResourceManager manager = mRenderHost.getResourceManager();
    if (manager != null) {
        LayoutResource resource =
                manager.getResource(AndroidResourceType.STATIC, getResourceId(false));
        if (resource != null) {
            xOffset = LocalizationUtils.isLayoutRtl()
                    ? resource.getPadding().left
                    : -(resource.getBitmapSize().width() - resource.getPadding().right);
        }
    }

    mClosePlacement.offset(getDrawX() + xOffset, getDrawY());
    return mClosePlacement;
}
 
Example 8
Source File: OverlayPanelBase.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return The left X coordinate of the close icon.
 */
public float getCloseIconX() {
    if (LocalizationUtils.isLayoutRtl()) {
        return getOffsetX() + getBarMarginSide();
    } else {
        return getOffsetX() + getWidth() - getBarMarginSide() - getCloseIconDimension();
    }
}
 
Example 9
Source File: ContextualSearchBarControl.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param x The x-position of the touch in px.
 * @return Whether the touch occurred on the search Bar's end button.
 */
private boolean isTouchOnEndButton(float x) {
    if (getDividerLineVisibilityPercentage() == 0.f) return false;

    float xPx = x * mDpToPx;
    if (LocalizationUtils.isLayoutRtl()) return xPx <= getDividerLineXOffset();
    return xPx > getDividerLineXOffset();
}
 
Example 10
Source File: ContextualSearchBarControl.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return The x-offset for the divider line relative to the x-position of the Bar in px.
 */
public float getDividerLineXOffset() {
    if (LocalizationUtils.isLayoutRtl()) {
        return mEndButtonWidth;
    } else {
        return mOverlayPanel.getContentViewWidthPx() - mEndButtonWidth - getDividerLineWidth();
    }
}
 
Example 11
Source File: ContextualSearchPanel.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private boolean isCoordinateInsideActionTarget(float x) {
    if (LocalizationUtils.isLayoutRtl()) {
        return x >= getContentX() + mEndButtonWidthDp;
    } else {
        return x <= getContentX() + getWidth() - mEndButtonWidthDp;
    }
}
 
Example 12
Source File: OverlayPanel.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param x The x coordinate in dp.
 * @return Whether the given |x| coordinate is inside the close button.
 */
protected boolean isCoordinateInsideCloseButton(float x) {
    if (LocalizationUtils.isLayoutRtl()) {
        return x <= (getCloseIconX() + getCloseIconDimension() + CLOSE_BUTTON_TOUCH_SLOP_DP);
    } else {
        return x >= (getCloseIconX() - CLOSE_BUTTON_TOUCH_SLOP_DP);
    }
}
 
Example 13
Source File: ContextualSearchPromoControl.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the Promo Android View. By making the Android View visible, we are allowing the
 * Promo to be interactive. Since snapshots are not interactive (they are just a bitmap),
 * we need to temporarily show the Android View on top of the snapshot, so the user will
 * be able to click in the Promo buttons and/or link.
 */
private void showPromoView() {
    float y = getYPx();
    View view = getView();
    if (view == null
            || !mIsVisible
            || (mIsShowingView && mPromoViewY == y)
            || mHeightPx == 0.f) return;

    float offsetX = mOverlayPanel.getOffsetX() * mDpToPx;
    if (LocalizationUtils.isLayoutRtl()) {
        offsetX = -offsetX;
    }

    view.setTranslationX(offsetX);
    view.setTranslationY(y);
    view.setVisibility(View.VISIBLE);

    // NOTE(pedrosimonetti): We need to call requestLayout, otherwise
    // the Promo View will not become visible.
    view.requestLayout();

    mIsShowingView = true;
    mPromoViewY = y;

    // The Promo can only be interacted when the View is being displayed.
    mWasInteractive = true;
}
 
Example 14
Source File: StackAnimationPortrait.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean isDefaultDiscardDirectionPositive() {
    // On clicking the close button, discard the tab to the right on LTR, to the left on RTL.
    return !LocalizationUtils.isLayoutRtl();
}
 
Example 15
Source File: StackLayout.java    From delion with Apache License 2.0 4 votes vote down vote up
float getStack0Left() {
    return LocalizationUtils.isLayoutRtl()
            ? getInnerMargin() - getClampedRenderedScrollOffset() * getFullScrollDistance()
            : getClampedRenderedScrollOffset() * getFullScrollDistance();
}
 
Example 16
Source File: StackAnimationLandscape.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
protected ChromeAnimation<?> createTabFocusedAnimatorSet(
        StackTab[] tabs, int focusIndex, int spacing, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();
    for (int i = 0; i < tabs.length; ++i) {
        StackTab tab = tabs[i];
        LayoutTab layoutTab = tab.getLayoutTab();

        addTiltScrollAnimation(set, layoutTab, 0.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
        addAnimation(set, tab, DISCARD_AMOUNT, tab.getDiscardAmount(), 0.0f,
                TAB_FOCUSED_ANIMATION_DURATION, 0);

        if (i < focusIndex) {
            // For tabs left of the focused tab move them left to 0.
            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(),
                    Math.max(0.0f, tab.getScrollOffset() - mWidth - spacing),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
        } else if (i > focusIndex) {
            // We also need to animate the X Translation to move them right
            // off the screen.
            float coveringTabPosition = layoutTab.getX();
            float distanceToBorder = LocalizationUtils.isLayoutRtl()
                    ? coveringTabPosition + layoutTab.getScaledContentWidth()
                    : mWidth - coveringTabPosition;
            float clampedDistanceToBorder = MathUtils.clamp(distanceToBorder, 0, mWidth);
            float delay = TAB_FOCUSED_MAX_DELAY * clampedDistanceToBorder / mWidth;
            addAnimation(set, tab, X_IN_STACK_OFFSET, tab.getXInStackOffset(),
                    tab.getXInStackOffset()
                            + (LocalizationUtils.isLayoutRtl() ? -mWidth : mWidth),
                    (TAB_FOCUSED_ANIMATION_DURATION - (long) delay), (long) delay);
        } else {
            // This is the focused tab.  We need to scale it back to
            // 1.0f, move it to the top of the screen, and animate the
            // X Translation so that it looks like it is zooming into the
            // full screen view.  We move the card to the top left and extend it out so
            // it becomes a full card.
            tab.setXOutOfStack(0);
            tab.setYOutOfStack(0.0f);
            layoutTab.setBorderScale(1.f);

            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(),
                    StackTab.screenToScroll(0, warpSize), TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(
                    set, tab, SCALE, tab.getScale(), 1.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(set, tab, X_IN_STACK_INFLUENCE, tab.getXInStackInfluence(), 0.0f,
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(set, tab, Y_IN_STACK_INFLUENCE, tab.getYInStackInfluence(), 0.0f,
                    TAB_FOCUSED_Y_STACK_DURATION, 0);

            addAnimation(set, tab.getLayoutTab(), MAX_CONTENT_HEIGHT,
                    tab.getLayoutTab().getMaxContentHeight(),
                    tab.getLayoutTab().getUnclampedOriginalContentHeight(),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            tab.setYOutOfStack(mHeight - mHeightMinusBrowserControls - mBorderTopHeight);

            if (layoutTab.shouldStall()) {
                addAnimation(set, layoutTab, SATURATION, 1.0f, 0.0f,
                        TAB_FOCUSED_BORDER_ALPHA_DURATION, TAB_FOCUSED_BORDER_ALPHA_DELAY);
            }
            addAnimation(set, tab.getLayoutTab(), TOOLBAR_ALPHA, layoutTab.getToolbarAlpha(),
                    1.f, TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
            addAnimation(set, tab.getLayoutTab(), TOOLBAR_Y_OFFSET,
                    getToolbarOffsetToLineUpWithBorder(), 0.f,
                    TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
            addAnimation(set, tab.getLayoutTab(), SIDE_BORDER_SCALE, 1.f, 0.f,
                    TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
        }
    }

    return set;
}
 
Example 17
Source File: StripLayoutHelper.java    From delion with Apache License 2.0 4 votes vote down vote up
private void updateReorderPosition(float deltaX) {
    if (!mInReorderMode || mInteractingTab == null) return;

    float offset = mInteractingTab.getOffsetX() + deltaX;
    int curIndex = findIndexForTab(mInteractingTab.getId());

    // 1. Compute the reorder threshold values.
    final float flipWidth = mCachedTabWidth - mTabOverlapWidth;
    final float flipThreshold = REORDER_OVERLAP_SWITCH_PERCENTAGE * flipWidth;

    // 2. Check if we should swap tabs and track the new destination index.
    int destIndex = TabModel.INVALID_TAB_INDEX;
    boolean pastLeftThreshold = offset < -flipThreshold;
    boolean pastRightThreshold = offset > flipThreshold;
    boolean isNotRightMost = curIndex < mStripTabs.length - 1;
    boolean isNotLeftMost = curIndex > 0;

    if (LocalizationUtils.isLayoutRtl()) {
        boolean oldLeft = pastLeftThreshold;
        pastLeftThreshold = pastRightThreshold;
        pastRightThreshold = oldLeft;
    }

    if (pastRightThreshold && isNotRightMost) {
        destIndex = curIndex + 2;
    } else if (pastLeftThreshold && isNotLeftMost) {
        destIndex = curIndex - 1;
    }

    // 3. If we should swap tabs, make the swap.
    if (destIndex != TabModel.INVALID_TAB_INDEX) {
        // 3.a. Since we're about to move the tab we're dragging, adjust it's offset so it
        // stays in the same apparent position.
        boolean shouldFlip =
                LocalizationUtils.isLayoutRtl() ? destIndex < curIndex : destIndex > curIndex;
        offset += MathUtils.flipSignIf(flipWidth, shouldFlip);

        // 3.b. Swap the tabs.
        reorderTab(mInteractingTab.getId(), curIndex, destIndex, true);
        mModel.moveTab(mInteractingTab.getId(), destIndex);

        // 3.c. Update our curIndex as we have just moved the tab.
        curIndex += destIndex > curIndex ? 1 : -1;

        // 3.d. Update visual tab ordering.
        updateVisualTabOrdering();
    }

    // 4. Limit offset based on tab position.  First tab can't drag left, last tab can't drag
    // right.
    if (curIndex == 0) {
        offset =
                LocalizationUtils.isLayoutRtl() ? Math.min(0.f, offset) : Math.max(0.f, offset);
    }
    if (curIndex == mStripTabs.length - 1) {
        offset =
                LocalizationUtils.isLayoutRtl() ? Math.max(0.f, offset) : Math.min(0.f, offset);
    }

    // 5. Set the new offset.
    mInteractingTab.setOffsetX(offset);
}
 
Example 18
Source File: ToolbarProgressBarAnimatingView.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @param context The Context for this view.
 * @param height The LayoutParams for this view.
 */
public ToolbarProgressBarAnimatingView(Context context, LayoutParams layoutParams) {
    super(context);
    setLayoutParams(layoutParams);
    mIsRtl = LocalizationUtils.isLayoutRtl();
    mDpToPx = getResources().getDisplayMetrics().density;

    mAnimationDrawable = new ColorDrawable(Color.WHITE);

    setImageDrawable(mAnimationDrawable);

    mListener = new ProgressBarUpdateListener();
    mAnimatorSet = new AnimatorSet();

    mSlowAnimation = new ValueAnimator();
    mSlowAnimation.setFloatValues(0.0f, 1.0f);
    mSlowAnimation.addUpdateListener(mListener);

    mFastAnimation = new ValueAnimator();
    mFastAnimation.setFloatValues(0.0f, 1.0f);
    mFastAnimation.addUpdateListener(mListener);

    updateAnimationDuration();

    mAnimatorSet.playSequentially(mSlowAnimation, mFastAnimation);

    AnimatorListener listener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator a) {
            // Replay the animation if it has not been canceled.
            if (mIsCanceled) return;
            // Repeats of the animation should have a start delay.
            mAnimatorSet.setStartDelay(ANIMATION_DELAY_MS);
            updateAnimationDuration();
            // Only restart the animation if the last animation is ending.
            if (a == mFastAnimation) mAnimatorSet.start();
        }
    };

    mSlowAnimation.addListener(listener);
    mFastAnimation.addListener(listener);
}
 
Example 19
Source File: ToolbarPhone.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    if (child == mLocationBar) return drawLocationBar(canvas, drawingTime);
    boolean clipped = false;

    if (mLocationBarBackground != null
            && ((mTabSwitcherState == STATIC_TAB && !mTabSwitcherModeViews.contains(child))
                    || (mTabSwitcherState != STATIC_TAB
                            && mBrowsingModeViews.contains(child)))) {
        canvas.save();

        int translationY = (int) mLocationBar.getTranslationY();
        int clipTop = mLocationBarBackgroundBounds.top - mLocationBarBackgroundPadding.top
                + translationY;
        if (mUrlExpansionPercent != 0f && clipTop < child.getBottom()) {
            // For other child views, use the inverse clipping of the URL viewport.
            // Only necessary during animations.
            // Hardware mode does not support unioned clip regions, so clip using the
            // appropriate bounds based on whether the child is to the left or right of the
            // location bar.
            boolean isLeft = (child == mNewTabButton
                    || child == mHomeButton) ^ LocalizationUtils.isLayoutRtl();

            int clipBottom = mLocationBarBackgroundBounds.bottom
                    + mLocationBarBackgroundPadding.bottom + translationY;
            boolean verticalClip = false;
            if (translationY > 0f) {
                clipTop = child.getTop();
                clipBottom = clipTop;
                verticalClip = true;
            }

            if (isLeft) {
                int clipRight = verticalClip ? child.getMeasuredWidth()
                        : mLocationBarBackgroundBounds.left
                                - mLocationBarBackgroundPadding.left;
                canvas.clipRect(0, clipTop, clipRight, clipBottom);
            } else {
                int clipLeft = verticalClip ? 0 : mLocationBarBackgroundBounds.right
                        + mLocationBarBackgroundPadding.right;
                canvas.clipRect(clipLeft, clipTop, getMeasuredWidth(), clipBottom);
            }
        }
        clipped = true;
    }
    boolean retVal = super.drawChild(canvas, child, drawingTime);
    if (clipped) canvas.restore();
    return retVal;
}
 
Example 20
Source File: ToolbarSwipeLayout.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void swipeStarted(long time, ScrollDirection direction, float x, float y) {
    if (mTabModelSelector == null || mToTab != null || direction == ScrollDirection.DOWN) {
        return;
    }

    boolean dragFromLeftEdge = direction == ScrollDirection.RIGHT;
    // Finish off any other animations.
    forceAnimationToFinish();

    // Determine which tabs we're showing.
    TabModel model = mTabModelSelector.getCurrentModel();
    if (model == null) return;
    int fromIndex = model.index();
    if (fromIndex == TabModel.INVALID_TAB_INDEX) return;

    // On RTL, edge-dragging to the left is the next tab.
    int toIndex = (LocalizationUtils.isLayoutRtl() ^ dragFromLeftEdge) ? fromIndex - 1
                                                                       : fromIndex + 1;
    int leftIndex = dragFromLeftEdge ? toIndex : fromIndex;
    int rightIndex = !dragFromLeftEdge ? toIndex : fromIndex;

    List<Integer> visibleTabs = new ArrayList<Integer>();
    if (0 <= leftIndex && leftIndex < model.getCount()) {
        int leftTabId = model.getTabAt(leftIndex).getId();
        mLeftTab = createLayoutTab(leftTabId, model.isIncognito(), NO_CLOSE_BUTTON, NEED_TITLE);
        prepareLayoutTabForSwipe(mLeftTab, leftIndex != fromIndex);
        visibleTabs.add(leftTabId);
    }
    if (0 <= rightIndex && rightIndex < model.getCount()) {
        int rightTabId = model.getTabAt(rightIndex).getId();
        mRightTab =
                createLayoutTab(rightTabId, model.isIncognito(), NO_CLOSE_BUTTON, NEED_TITLE);
        prepareLayoutTabForSwipe(mRightTab, rightIndex != fromIndex);
        visibleTabs.add(rightTabId);
    }

    updateCacheVisibleIds(visibleTabs);

    mToTab = null;

    // Reset the tab offsets.
    mOffsetStart = dragFromLeftEdge ? 0 : getWidth();
    mOffset = 0;
    mOffsetTarget = 0;

    if (mLeftTab != null && mRightTab != null) {
        mLayoutTabs = new LayoutTab[] {mLeftTab, mRightTab};
    } else if (mLeftTab != null) {
        mLayoutTabs = new LayoutTab[] {mLeftTab};
    } else if (mRightTab != null) {
        mLayoutTabs = new LayoutTab[] {mRightTab};
    } else {
        mLayoutTabs = null;
    }

    requestUpdate();
}