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

Commit dda51080 authored by Alan Viverette's avatar Alan Viverette Committed by android-build-merger
Browse files

Merge "Handle null left and right tab strip drawables" into oc-mr1-dev am: 286c7db3

am: 7dbf5b03

Change-Id: I5c3f616276f1f68a134c48f886cc43d282400415
parents e98252d2 7dbf5b03
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.