EverythingMe / overscroll-decor

Android: iOS-like over-scrolling effect applicable over almost all scrollable Android views.
BSD 2-Clause "Simplified" License
2.85k stars 400 forks source link

unexpected long press event #14

Open anagaf opened 8 years ago

anagaf commented 8 years ago

Hi

I'm trying to use the decorator with a RecyclerView. If I fling twice quickly an unexpected long press event is dispatched:

04-25 11:28:29.516 25881-25881/me.everything.overscrolldemo D/anagaf: drag start java.lang.Throwable
                                                                          at me.everything.overscrolldemo.view.RecyclerViewDemoFragment$1.onSelectedChanged(RecyclerViewDemoFragment.java:72)
                                                                          at me.everything.android.ui.overscroll.adapters.RecyclerViewOverScrollDecorAdapter$ItemTouchHelperCallbackWrapper.onSelectedChanged(RecyclerViewOverScrollDecorAdapter.java:213)
                                                                          at me.everything.android.ui.overscroll.adapters.RecyclerViewOverScrollDecorAdapter$1.onSelectedChanged(RecyclerViewOverScrollDecorAdapter.java:73)
                                                                          at android.support.v7.widget.helper.ItemTouchHelper.select(ItemTouchHelper.java:669)
                                                                          at android.support.v7.widget.helper.ItemTouchHelper.access$800(ItemTouchHelper.java:76)
                                                                          at android.support.v7.widget.helper.ItemTouchHelper$ItemTouchHelperGestureListener.onLongPress(ItemTouchHelper.java:2289)
                                                                          at android.view.GestureDetector.dispatchLongPress(GestureDetector.java:770)
                                                                          at android.view.GestureDetector.-wrap0(GestureDetector.java)
                                                                          at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:293)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I suppose it's because BounceBackState#handleUpOrCancelTouchEvent() and OverScrollingState#handleUpOrCancelTouchEvent() always return true. If touch up event happens during the animation it's missed so the next touch up event is treated as a long press.

It is possible to change these methods to return false?

Thanks, Andrey

d4vidi commented 8 years ago

Hi, which version are you using? Please make sure it's 1.0.1 and not 1.0.0. Thanks!

anagaf commented 8 years ago

I use the latest sources from git

d4vidi commented 8 years ago

Very well, I'll look into it -- thanks!

d4vidi commented 8 years ago

@anagaf - hi, I'm going over some of the git issue. I know this one is old but it has got me curious - Have you made any changes to the ItemTouchHelper callback used in the demo app? Have you by any chance enabled items dragging (i.e. position switching), on top of the already enabled item swiping?