Skip to content

Commit

Permalink
Fix fast scroll up blank screen issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Undeger committed Nov 23, 2017
1 parent 56d99ce commit 818b056
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit 818b056

Please sign in to comment.