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());
}
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;
}
Aggregations