Search in sources :

Example 1 with SavedStateScrolling

use of com.marshalchen.ultimaterecyclerview.uiUtils.SavedStateScrolling in project UltimateRecyclerView by cymcsg.

the class UltimateRecyclerView method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedStateScrolling ss = (SavedStateScrolling) state;
    mPrevFirstVisiblePosition = ss.prevFirstVisiblePosition;
    mPrevFirstVisibleChildHeight = ss.prevFirstVisibleChildHeight;
    mPrevScrolledChildrenHeight = ss.prevScrolledChildrenHeight;
    mPrevScrollY = ss.prevScrollY;
    mScrollY = ss.scrollY;
    mChildrenHeights = ss.childrenHeights;
    RecyclerView.LayoutManager layoutManager = getLayoutManager();
    /**
         * enhanced and store the previous scroll position
         */
    if (layoutManager != null) {
        int count = layoutManager.getChildCount();
        if (mPrevScrollY != RecyclerView.NO_POSITION && mPrevScrollY < count) {
            layoutManager.scrollToPosition(mPrevScrollY);
        }
    }
    super.onRestoreInstanceState(ss.getSuperState());
}
Also used : SavedStateScrolling(com.marshalchen.ultimaterecyclerview.uiUtils.SavedStateScrolling) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with SavedStateScrolling

use of com.marshalchen.ultimaterecyclerview.uiUtils.SavedStateScrolling in project UltimateRecyclerView by cymcsg.

the class UltimateRecyclerView method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();
    SavedStateScrolling ss = new SavedStateScrolling(superState);
    ss.prevFirstVisiblePosition = mPrevFirstVisiblePosition;
    ss.prevFirstVisibleChildHeight = mPrevFirstVisibleChildHeight;
    ss.prevScrolledChildrenHeight = mPrevScrolledChildrenHeight;
    ss.prevScrollY = mPrevScrollY;
    ss.scrollY = mScrollY;
    ss.childrenHeights = mChildrenHeights;
    return ss;
}
Also used : SavedStateScrolling(com.marshalchen.ultimaterecyclerview.uiUtils.SavedStateScrolling) Parcelable(android.os.Parcelable)

Aggregations

SavedStateScrolling (com.marshalchen.ultimaterecyclerview.uiUtils.SavedStateScrolling)2 Parcelable (android.os.Parcelable)1 RecyclerView (android.support.v7.widget.RecyclerView)1