1

Background

In the past, I've asked how to create a fast-scroller for the RecyclerView (here), and found a way to add it and I've even published it, including a Github project (here).

The problem

Starting with specific support library version, things got buggy. The library I've made works fine with this :

compile 'com.android.support:recyclerview-v7:21.0.3' compile 'com.android.support:appcompat-v7:21.0.3' 

But not with this one:

compile 'com.android.support:recyclerview-v7:22.2.0' compile 'com.android.support:appcompat-v7:22.2.0' 

Here's a sample of how it used to work:

enter image description here

The bug that occurs is that when dragging the fast-scroller, it (what you drag) jumps from time to time to other places (reported about here).

What I've tried

I tried finding the cause for this, as well as finding what has changed in RecyclerView that could cause this issue.

I've also tried to report about it (here), but Google told me to ask about it here.

Sadly, I couldn't find the reason for this.

The question

How can I fix this issue, and make the code work fine again?

4
  • ` it jumps from time to time to other places` What jumps, the track or the list? How do you track these positions? You should just debug and see why your handle moves, which callback & stack trace you receive etc. Commented Jul 7, 2015 at 21:17
  • @yigit Please check the links I've provided and what I wrote. They have more information in them to put in here. The jumpy behavior is of the fast scroller itself (what you drag). Commented Jul 7, 2015 at 21:35
  • The only useful thing I see there is setBubbleAndHandlePosition is called with a very high value. Briefly checking your source code shows you are getting it from the event but you are ignoring event pointer etc. Probably sth is wrong in your event tracking. I would suggest checking ItemTouchHelper's event handling. Commented Jul 7, 2015 at 22:22
  • @yigit Seems logical. But why would it work on previous versions of the support library, yet now it doesn't? Commented Jul 7, 2015 at 22:34

1 Answer 1

1

What a coincidence, I just used your FastScroller and had the same issue, I also use 22.2.0.

My list to test has roughly 150 items and I saw small jumps in the handle and bubble when I scroll slowly.

Some debugging and I found out that when I drag the handle, the method setBubbleAndHandlePosition() is called from onTouch and from onScrolled.

The problem with that is that onScrolled calculates the "perfect" place for the handle based on the top row. That results in a different position than the handle hold by touch.

My solution was pretty simple, I check in onScrolled() if the handle is in "drag" mode by checking for isSelected() and prevent further calculations on onScrolled().

@Override public void onScrolled(RecyclerView rv, int dx, int dy) { // only react on scroll events when not done by moving the handle by touch // prevents nervous jumping of the handle if (handle.isSelected()) { return; } // rest code of onScrolled is unchanged } 

I guess the reason is/was that onScrolled wasn't called below 22.x but is now...

Sign up to request clarification or add additional context in comments.

2 Comments

So this occurs because 2 methods call to change the position of the handle? The scrolling and the touching? and you made it ignore the scrolling in case the handle is being dragged?
It seems to fix this issue, but now it caused a new issue: Try to drag the fast-scroller . Now stop and scroll in the same direction you've dragged. There is a small jump of the scrolling . Sometimes even in the other direction. I wonder why this time it has issues.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.