alexvasilkov / GestureViews

ImageView and FrameLayout with gestures control and position animation
Apache License 2.0
2.38k stars 384 forks source link

IllegalStateException: "You should call enter(...) before calling exit(...)" #115

Closed Farasy closed 6 years ago

Farasy commented 6 years ago

For some reason some users report the above issue. This happens on all android version from 5.0 and also new devices like Galaxy S9.

Enter procedure is always same:

animator = GestureTransitions.from(mRecyclerView, fromTracker).into(mPager, intoTracker);
animator.addPositionUpdateListener(this);

...
animator.enter(mAdapter.getData().get(position).getId(), true);

Full stacktrace:

java.lang.IllegalStateException: 
  at com.alexvasilkov.gestures.animation.ViewPositionAnimator.exit (ViewPositionAnimator.java:275)
  at com.alexvasilkov.gestures.internal.ExitController.finishDetection (ExitController.java:278)
  at com.alexvasilkov.gestures.internal.ExitController.stopDetection (ExitController.java:71)
  at com.alexvasilkov.gestures.GestureController.notifyStateReset (GestureController.java:404)
  at com.alexvasilkov.gestures.GestureController.resetState (GestureController.java:258)
  at com.alexvasilkov.gestures.animation.ViewPositionAnimator.applyCurrentPosition (ViewPositionAnimator.java:566)
  at com.alexvasilkov.gestures.animation.ViewPositionAnimator.setState (ViewPositionAnimator.java:496)
  at com.alexvasilkov.gestures.animation.ViewPositionAnimator.exit (ViewPositionAnimator.java:284)
  at com.alexvasilkov.gestures.transition.ViewsTransitionAnimator.cleanupAnimator (ViewsTransitionAnimator.java:273)
  at com.alexvasilkov.gestures.transition.ViewsTransitionAnimator.cleanupRequest (ViewsTransitionAnimator.java:247)
  at com.alexvasilkov.gestures.transition.ViewsCoordinator.request (ViewsCoordinator.java:71)
  at com.alexvasilkov.gestures.transition.ViewsTransitionAnimator.enter (ViewsTransitionAnimator.java:70)
  at com.alexvasilkov.gestures.transition.internal.IntoViewPagerListener.switchToCurrentPage (IntoViewPagerListener.java:124)
  at com.alexvasilkov.gestures.transition.internal.IntoViewPagerListener.access$500 (IntoViewPagerListener.java:20)
  at com.alexvasilkov.gestures.transition.internal.IntoViewPagerListener$PagerListener.onPageScrollStateChanged (IntoViewPagerListener.java:159)
  at android.support.v4.view.ViewPager.dispatchOnScrollStateChanged (ViewPager.java:1956)
  at android.support.v4.view.ViewPager.setScrollState (ViewPager.java:491)
  at android.support.v4.view.ViewPager.smoothScrollTo (ViewPager.java:968)
  at android.support.v4.view.ViewPager.scrollToItem (ViewPager.java:677)
  at android.support.v4.view.ViewPager.setCurrentItemInternal (ViewPager.java:663)
  at android.support.v4.view.ViewPager.onTouchEvent (ViewPager.java:2255)
  at com.alexvasilkov.gestures.GestureControllerForPager.passEventToViewPager (GestureControllerForPager.java:362)
  at com.alexvasilkov.gestures.GestureControllerForPager.onUpOrCancel (GestureControllerForPager.java:166)
  at com.alexvasilkov.gestures.GestureController.onTouchInternal (GestureController.java:490)
  at com.alexvasilkov.gestures.GestureControllerForPager.onTouchInternal (GestureControllerForPager.java:121)
  at com.alexvasilkov.gestures.GestureController.onTouch (GestureController.java:441)
  at com.alexvasilkov.gestures.GestureControllerForPager.onTouch (GestureControllerForPager.java:106)
  at com.alexvasilkov.gestures.views.GestureImageView.onTouchEvent (GestureImageView.java:160)
  at android.view.View.dispatchTouchEvent (View.java:9377)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2554)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2255)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2554)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2255)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2554)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2255)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2554)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2255)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2554)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2255)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2554)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2255)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2554)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2255)
  at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent (PhoneWindow.java:2410)
  at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1744)
  at android.app.Activity.dispatchTouchEvent (Activity.java:2805)
  at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68)
  at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68)
  at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent (PhoneWindow.java:2371)
  at android.view.View.dispatchPointerEvent (View.java:9597)
  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4234)
  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4100)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3646)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:3699)
  at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:3665)
  at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:3791)
  at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:3673)
  at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:3848)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3646)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:3699)
  at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:3665)
  at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:3673)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3646)
  at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:5926)
  at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:5900)
  at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:5861)
  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:6029)
  at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:185)
  at android.os.MessageQueue.nativePollOnce (MessageQueue.java)
  at android.os.MessageQueue.next (MessageQueue.java:331)
  at android.os.Looper.loop (Looper.java:218)
  at android.app.ActivityThread.main (ActivityThread.java:5526)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)
alexvasilkov commented 6 years ago

That's a very strange crash, cannot find out how to reproduce it. How many of them do you have reported?

Anyway, I followed the stacktrace and fixed it in v2.5.2 hopefully, let me know if you will still see this issue.

Farasy commented 6 years ago

Thank you, i'll add the updated lib to the most recent beta of my app.

Crashlytics says more than 40 unique users face this bug.