Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,24 @@ protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (mCallbacks != null) {
if (getChildCount() > 0) {
int firstVisiblePosition = getChildPosition(getChildAt(0));
int lastVisiblePosition = getChildPosition(getChildAt(getChildCount() - 1));
int firstVisiblePosition;
int lastVisiblePosition;

if (getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager manager = (LinearLayoutManager) getLayoutManager();
firstVisiblePosition = manager.findFirstVisibleItemPosition();
lastVisiblePosition = manager.findLastVisibleItemPosition();
} else {
throw new IllegalArgumentException("need to be an LinearLayoutManager child");
}

for (int i = firstVisiblePosition, j = 0; i <= lastVisiblePosition; i++, j++) {
if (mChildrenHeights.indexOfKey(i) < 0 || getChildAt(j).getHeight() != mChildrenHeights.get(i)) {
mChildrenHeights.put(i, getChildAt(j).getHeight());
}
}

View firstVisibleChild = getChildAt(0);
View firstVisibleChild = getChildAt(firstVisiblePosition);
if (firstVisibleChild != null) {
if (mPrevFirstVisiblePosition < firstVisiblePosition) {
// scroll down
Expand Down