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

Commit 286c7db3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Handle null left and right tab strip drawables" into oc-mr1-dev

parents 7a59a622 00e9401e
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -61,7 +61,10 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
    // This value will be set to 0 as soon as the first tab is added to TabHost.
    private int mSelectedTab = -1;

    @Nullable
    private Drawable mLeftStrip;

    @Nullable
    private Drawable mRightStrip;

    private boolean mDrawBottomStrips = true;
@@ -374,24 +377,37 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
        final Drawable leftStrip = mLeftStrip;
        final Drawable rightStrip = mRightStrip;

        if (leftStrip != null) {
            leftStrip.setState(selectedChild.getDrawableState());
        }
        if (rightStrip != null) {
            rightStrip.setState(selectedChild.getDrawableState());
        }

        if (mStripMoved) {
            final Rect bounds = mBounds;
            bounds.left = selectedChild.getLeft();
            bounds.right = selectedChild.getRight();
            final int myHeight = getHeight();
            if (leftStrip != null) {
                leftStrip.setBounds(Math.min(0, bounds.left - leftStrip.getIntrinsicWidth()),
                        myHeight - leftStrip.getIntrinsicHeight(), bounds.left, myHeight);
            }
            if (rightStrip != null) {
                rightStrip.setBounds(bounds.right, myHeight - rightStrip.getIntrinsicHeight(),
                    Math.max(getWidth(), bounds.right + rightStrip.getIntrinsicWidth()), myHeight);
                        Math.max(getWidth(), bounds.right + rightStrip.getIntrinsicWidth()),
                        myHeight);
            }
            mStripMoved = false;
        }

        if (leftStrip != null) {
            leftStrip.draw(canvas);
        }
        if (rightStrip != null) {
            rightStrip.draw(canvas);
        }
    }

    /**
     * Sets the current tab.