thellmund / Android-Week-View

Display highly customizable calendar views in your Android app
Apache License 2.0
188 stars 98 forks source link

swipe left or right in WithFragment lead to crash #252

Closed rezazarchi closed 3 years ago

rezazarchi commented 3 years ago

Describe the bug app crash when i want to go next 3 days or previous days (or weeks) in WithFragment

To Reproduce Steps to reproduce the behavior:

  1. Go to 'With Fragment'
  2. swipe left or right
  3. crash

Additional context

Logcat

2021-06-08 15:25:12.451 6769-6769/com.alamkanak.weekview E/InputEventReceiver: Exception dispatching input event.
2021-06-08 15:25:12.451 6769-6769/com.alamkanak.weekview D/AndroidRuntime: Shutting down VM
2021-06-08 15:25:12.459 6769-6769/com.alamkanak.weekview E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.alamkanak.weekview, PID: 6769
    java.lang.IllegalArgumentException: Cannot coerce value to an empty range: maximum -2076.6665 is less than minimum 5933.333.
        at kotlin.ranges.RangesKt___RangesKt.coerceIn(_Ranges.kt:1131)
        at com.alamkanak.weekview.Navigator.scrollHorizontallyBy(Navigator.kt:23)
        at com.alamkanak.weekview.WeekViewGestureHandler.onScroll(WeekViewGestureHandler.kt:68)
        at android.view.GestureDetector.onTouchEvent(GestureDetector.java:714)
        at com.alamkanak.weekview.WeekViewGestureHandler.onTouchEvent(WeekViewGestureHandler.kt:172)
        at com.alamkanak.weekview.WeekView.onTouchEvent(WeekView.kt:1193)
        at android.view.View.dispatchTouchEvent(View.java:14309)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
        at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:488)
        at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1871)
        at android.app.Activity.dispatchTouchEvent(Activity.java:4125)
        at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
        at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:446)
        at android.view.View.dispatchPointerEvent(View.java:14568)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6016)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5819)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5310)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5367)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5333)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5485)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5341)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5542)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5314)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5367)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5333)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5341)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5314)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8080)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8031)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7992)
        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:8203)
        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:220)
        at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
        at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:200)
        at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:8160)
        at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:8242)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
2021-06-08 15:25:12.464 6769-6769/com.alamkanak.weekview E/AndroidRuntime:     at android.view.Choreographer.doCallbacks(Choreographer.java:796)
        at android.view.Choreographer.doFrame(Choreographer.java:724)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
thellmund commented 3 years ago

I can’t reproduce the crash on my emulator. Can you send a screen recording?

rezazarchi commented 3 years ago

oh sorry. this issue not happens when system language is English. I changed system language to Persian (or Arabic) and all layouts directions got RTL then repeat the scenario and crash happened.

https://user-images.githubusercontent.com/8654398/121335000-71832c80-c92f-11eb-9020-51a9a7d6658c.mp4

thellmund commented 3 years ago

Thanks for the screen recording! I'll fix the issues in RTL mode before the next release.

thellmund commented 3 years ago

Hey @rezazarchi, I pushed a quick fix. I did a bit of testing and things seem fine now, but let me know if anything else is still not working as expected.

rezazarchi commented 3 years ago

thanks but it seems that it hasn't fixed yet. I tested latest commits on master on Emulator with Android 11 and app crashed again on all pages.

    --------- beginning of crash
2021-06-20 09:37:52.655 7317-7317/com.alamkanak.weekview E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.alamkanak.weekview, PID: 7317
    java.lang.IllegalArgumentException: Cannot coerce value to an empty range: maximum -5636.6665 is less than minimum 2373.3333.
        at kotlin.ranges.RangesKt___RangesKt.coerceIn(_Ranges.kt:1131)
        at com.alamkanak.weekview.ViewState.scrollToFirstDayOfWeek(ViewState.kt:341)
        at com.alamkanak.weekview.ViewState.updateViewState(ViewState.kt:541)
        at com.alamkanak.weekview.ViewState.update(ViewState.kt:524)
        at com.alamkanak.weekview.WeekView.updateViewState(WeekView.kt:134)
        at com.alamkanak.weekview.WeekView.onDraw(WeekView.kt:120)
        at android.view.View.draw(View.java:22350)
        at android.view.View.updateDisplayListIfDirty(View.java:21226)
        at android.view.View.draw(View.java:22081)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
        at android.view.View.updateDisplayListIfDirty(View.java:21217)
        at android.view.View.draw(View.java:22081)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
        at android.view.View.updateDisplayListIfDirty(View.java:21217)
        at android.view.View.draw(View.java:22081)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
        at android.view.View.updateDisplayListIfDirty(View.java:21217)
        at android.view.View.draw(View.java:22081)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
        at android.view.View.updateDisplayListIfDirty(View.java:21217)
        at android.view.View.draw(View.java:22081)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
        at android.view.View.updateDisplayListIfDirty(View.java:21217)
        at android.view.View.draw(View.java:22081)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
        at android.view.View.updateDisplayListIfDirty(View.java:21217)
        at android.view.View.draw(View.java:22081)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
        at android.view.View.draw(View.java:22353)
        at com.android.internal.policy.DecorView.draw(DecorView.java:806)
        at android.view.View.updateDisplayListIfDirty(View.java:21226)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:559)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:565)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:642)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:4101)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3828)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3099)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
        at android.view.Choreographer.doCallbacks(Choreographer.java:796)
        at android.view.Choreographer.doFrame(Choreographer.java:731)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

https://user-images.githubusercontent.com/8654398/122662798-1234e000-d1ab-11eb-8b3e-d06eb1c84787.mp4

thellmund commented 3 years ago

Are you certain this is using the latest version on master? I tested it with the Force RTL mode developer option and with an RTL language, and both are working fine.

https://user-images.githubusercontent.com/11819826/122673432-6d140a80-d19e-11eb-91e8-99e961c6bd89.mp4

rezazarchi commented 3 years ago

I tested again on Android 11 both Force-RTL and Persian language have this problem. branch: master HEAD commit: 48b4d4b639243c0a22e2f0fb6b65b396c376ddcf