AndroidDeveloperLB / LollipopContactsRecyclerViewFastScroller

A sample of how to mimic the way that the contacts app handles a Fast-Scroller for a RecyclerView
Apache License 2.0
540 stars 95 forks source link

Fix for handle is not smooth issue #6

Closed dimbslmh closed 9 years ago

dimbslmh commented 9 years ago

Fix for issue #3 Scrolling RecyclerView, handle is not smooth

AndroidDeveloperLB commented 9 years ago

Is this really fixed?

dimbslmh commented 9 years ago

@AndroidDeveloperLB Yes, please try it out first if you don't wan't to accept the PR right away.

  1. Download my repo
  2. File -> New -> Import Project in Android Studio
  3. Decrease the SIZE in the LargeAdapter to lets say 20

Note: You need to update your SDK/BuildTool versions to 23/23.0.1

davideas commented 9 years ago

Yes, for me it is fixed, good job @dimbslmh!! I didn't know about those 2 compute functions of the RecyclerView. Maybe the code could be improved a little bit in this point:

@Override
public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) {
    if (handle.isSelected()) return;
    float proportion = (float) recyclerView.computeVerticalScrollOffset()
                 / (float) (recyclerView.computeVerticalScrollRange() - height);
    setBubbleAndHandlePosition(height * proportion);
}

Also, all logs should be commented!

AndroidDeveloperLB commented 9 years ago

Thank you guys. However, there is still an issue with this fix (maybe it was before too):

  1. make the items count to 20.
  2. drag the fast-scroller to the middle (or anything else).
  3. scroll a really tiny bit (in the recyclerView itself)

The bug: it shows the scrollber very far from its previous position.

AndroidDeveloperLB commented 9 years ago

Also, about the removal of variables, this does not improve performance, as the runtime will use the temporary variables whether you declare them or not (they are stored in registers). It's better to separate variables in order to make them more readable.