Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fast scroll up blank screen issue #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@ -192,6 +192,16 @@ private int preFillGrid(Direction direction, int dy, int emptyTop,
detachView(cachedView);
}
}
//Check if it is scrolled too fast and if so find the row that should be displayed first
//If startTopOffset is greater than zero than that means we are trying to fill the screen
//somewhere below the top part.
if (direction == Direction.UP) {
while (startTopOffset >= -dy / 2 && mFirstVisibleRow != 0) {
mFirstVisibleRow--;
newFirstVisiblePosition = firstChildPositionForRow(mFirstVisibleRow);
startTopOffset -= sizeForChildAtPosition(newFirstVisiblePosition).getHeight();
}
}

mFirstVisiblePosition = newFirstVisiblePosition;

Expand Down Expand Up @@ -378,8 +388,9 @@ public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerVi
if (getChildCount() == 0 || dy == 0) {
return 0;
}

//Take top measurements from the top-left child
final View topLeftView = getChildAt(0);
//Take bottom measurements from the bottom-right child.
final View bottomRightView = getChildAt(getChildCount() - 1);
int pixelsFilled = getContentHeight();
// TODO: Split into methods, or a switch case?
Expand Down