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

Commit c52e0d90 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Properly restore RTL state in HorizontalScrollView" into mnc-dev

parents 0771d929 a3aa6d82
Loading
Loading
Loading
Loading
+9 −15
Original line number Diff line number Diff line
@@ -1505,11 +1505,9 @@ public class HorizontalScrollView extends FrameLayout {
            final int scrollRange = Math.max(0,
                    childWidth - (r - l - mPaddingLeft - mPaddingRight));
            if (mSavedState != null) {
                if (isLayoutRtl() == mSavedState.isLayoutRtl) {
                    mScrollX = mSavedState.scrollPosition;
                } else {
                    mScrollX = scrollRange - mSavedState.scrollPosition;
                }
                mScrollX = isLayoutRtl()
                        ? scrollRange - mSavedState.scrollOffsetFromStart
                        : mSavedState.scrollOffsetFromStart;
                mSavedState = null;
            } else {
                if (isLayoutRtl()) {
@@ -1692,8 +1690,7 @@ public class HorizontalScrollView extends FrameLayout {
        }
        Parcelable superState = super.onSaveInstanceState();
        SavedState ss = new SavedState(superState);
        ss.scrollPosition = mScrollX;
        ss.isLayoutRtl = isLayoutRtl();
        ss.scrollOffsetFromStart = isLayoutRtl() ? -mScrollX : mScrollX;
        return ss;
    }

@@ -1705,8 +1702,7 @@ public class HorizontalScrollView extends FrameLayout {
    }

    static class SavedState extends BaseSavedState {
        public int scrollPosition;
        public boolean isLayoutRtl;
        public int scrollOffsetFromStart;

        SavedState(Parcelable superState) {
            super(superState);
@@ -1714,23 +1710,21 @@ public class HorizontalScrollView extends FrameLayout {

        public SavedState(Parcel source) {
            super(source);
            scrollPosition = source.readInt();
            isLayoutRtl = (source.readInt() == 0) ? true : false;
            scrollOffsetFromStart = source.readInt();
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            super.writeToParcel(dest, flags);
            dest.writeInt(scrollPosition);
            dest.writeInt(isLayoutRtl ? 1 : 0);
            dest.writeInt(scrollOffsetFromStart);
        }

        @Override
        public String toString() {
            return "HorizontalScrollView.SavedState{"
                    + Integer.toHexString(System.identityHashCode(this))
                    + " scrollPosition=" + scrollPosition
                    + " isLayoutRtl=" + isLayoutRtl + "}";
                    + " scrollPosition=" + scrollOffsetFromStart
                    + "}";
        }

        public static final Parcelable.Creator<SavedState> CREATOR