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

java.lang.IllegalStateException: An instance of OnFlingListener already set. #23

Closed
Kolyall opened this issue Jun 27, 2017 · 4 comments
Closed

Comments

@Kolyall
Copy link

Kolyall commented Jun 27, 2017

Here is my code:

SnapHelper snapHelper = new GravitySnapHelper(Gravity.START);
snapHelper.attachToRecyclerView(mRecyclerView);

but sometimes the issue occurs:

FATAL EXCEPTION: main
                                                                        Process: by.gramoplayer.android, PID: 12195
                                                                        java.lang.IllegalStateException: An instance of OnFlingListener already set.
                                                                            at android.support.v7.widget.SnapHelper.setupCallbacks(SnapHelper.java:114)
                                                                            at android.support.v7.widget.SnapHelper.attachToRecyclerView(SnapHelper.java:102)
                                                                            at com.github.rubensousa.gravitysnaphelper.GravitySnapHelper.attachToRecyclerView(GravitySnapHelper.java:47)
@evanhalley
Copy link

Set the recycler view fling listener to null (this is what worked for me).

mRecyclerView.setOnFlingListener(null);

@Kolyall
Copy link
Author

Kolyall commented Jun 28, 2017

I added check for isSnapHelperAttached or not

@rubensousa
Copy link
Owner

Fixed on 1.3. Now the FlingListener is set to null before the SnapHelper attaches itself to the RecyclerView.

@ghost
Copy link

ghost commented Nov 20, 2017

getting same error with an example

 snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));
 snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));
snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));
snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));
snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));
snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));
snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));
snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));
snapAdapter.addSnap(new Snap(Gravity.CENTER_HORIZONTAL, "Snap center", apps));

scrolling to the bottom and then up produces this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants