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

Commit 3b52ca3b authored by Adam Cohen's avatar Adam Cohen Committed by Android (Google) Code Review
Browse files

Merge "Fixing some ugly StackView relayouts on rotation" into honeycomb

parents e193c468 53838d26
Loading
Loading
Loading
Loading
+7 −15
Original line number Diff line number Diff line
@@ -280,6 +280,10 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * @param whichChild the index of the child view to display
     */
    public void setDisplayedChild(int whichChild) {
        setDisplayedChild(whichChild, true);
    }

    private void setDisplayedChild(int whichChild, boolean animate) {
        if (mAdapter != null) {
            mWhichChild = whichChild;
            if (whichChild >= getWindowSize()) {
@@ -290,7 +294,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>

            boolean hasFocus = getFocusedChild() != null;
            // This will clear old focus if we had it
            showOnly(mWhichChild);
            showOnly(mWhichChild, animate);
            if (hasFocus) {
                // Try to retake focus if we had it
                requestFocus(FOCUS_FORWARD);
@@ -793,22 +797,10 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
        if (mRemoteViewsAdapter != null && mAdapter == null) {
            mRestoreWhichChild = mWhichChild;
        } else {
            setDisplayedChild(mWhichChild);
            setDisplayedChild(mWhichChild, false);
        }
    }

    /**
     * Shows only the specified child. The other displays Views exit the screen
     * with the {@link #getOutAnimation() out animation} and the specified child
     * enters the screen with the {@link #getInAnimation() in animation}.
     *
     * @param childIndex The index of the child to be shown.
     */
    void showOnly(int childIndex) {
        final boolean animate = (!mFirstTime || mAnimateFirstTime);
        showOnly(childIndex, animate);
    }

    /**
     * Returns the View corresponding to the currently displayed child.
     *
@@ -977,7 +969,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>

            // Restore the previous position (see onRestoreInstanceState)
            if (mRestoreWhichChild > -1) {
                setDisplayedChild(mRestoreWhichChild);
                setDisplayedChild(mRestoreWhichChild, false);
                mRestoreWhichChild = -1;
            }
            return false;
+4 −11
Original line number Diff line number Diff line
@@ -549,25 +549,16 @@ public class StackView extends AdapterViewAnimator {
            mSlideAmount = Math.round(SLIDE_UP_RATIO * getMeasuredHeight());
            mSwipeThreshold = Math.round(SWIPE_THRESHOLD_RATIO * mSlideAmount);
            mFirstLayoutHappened = true;
            post(new Runnable() {
                public void run() {
            updateChildTransforms();
        }
            });
        }

        if (Float.compare(mPerspectiveShiftY, mNewPerspectiveShiftY) != 0 ||
                Float.compare(mPerspectiveShiftX, mNewPerspectiveShiftX) != 0) {

            mPerspectiveShiftY = mNewPerspectiveShiftY;
            mPerspectiveShiftX = mNewPerspectiveShiftX;

            post(new Runnable() {
                public void run() {
            updateChildTransforms();
        }
            });
        }
    }

    /**
@@ -1120,6 +1111,8 @@ public class StackView extends AdapterViewAnimator {

        mNewPerspectiveShiftX = PERSPECTIVE_SHIFT_FACTOR_X * measuredWidth;
        mNewPerspectiveShiftY = PERSPECTIVE_SHIFT_FACTOR_Y * measuredHeight;

        // If we have extra space, we try and spread the items out
        if (maxWidth > 0 && count > 0 && maxWidth < childWidth) {
            mNewPerspectiveShiftX = measuredWidth - maxWidth;
        }