Fragment Swipe Silent Exception
KitsuneFolk opened this issue · 0 comments
KitsuneFolk commented
Please consider making a Pull Request if you are capable of doing so.
Library Version:
2.8
Affected Device(s):
Redmi 9C
Describe the bug
Тихое исключение при свайпе фрагмента:
2023-06-13 11:53:36.549 10961-10961 RecyclerView com.fragula2.sample W Cannot call this method in a scroll callback. Scroll callbacks mightbe run during a measure & layout pass where you cannot change theRecyclerView data. Any method call that might change the structureof the RecyclerView or the adapter contents should be postponed tothe next frame.
java.lang.IllegalStateException: androidx.viewpager2.widget.ViewPager2$RecyclerViewImpl{16cf409 VFED..... ......ID 0,0-720,1433 #1}, adapter:com.fragula2.adapter.NavBackStackAdapter@625909f, layout:androidx.viewpager2.widget.ViewPager2$LinearLayoutManagerImpl@a0935ec, context:com.fragula2.sample.MainActivity@56ee45d
at androidx.recyclerview.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:3061)
at androidx.recyclerview.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeRemoved(RecyclerView.java:5563)
at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeRemoved(RecyclerView.java:12288)
at androidx.recyclerview.widget.RecyclerView$Adapter.notifyItemRemoved(RecyclerView.java:7515)
at com.fragula2.adapter.NavBackStackAdapter.pop(NavBackStackAdapter.kt:55)
at com.fragula2.navigation.SwipeBackFragment.popBackStack(SwipeBackFragment.kt:163)
at com.fragula2.navigation.SwipeBackNavigator.popBackStack(SwipeBackNavigator.kt:80)
at androidx.navigation.NavController.popBackStackInternal(NavController.kt:274)
at androidx.navigation.NavController.popBackStackInternal(NavController.kt:557)
at androidx.navigation.NavController.popBackStack(NavController.kt:472)
at androidx.navigation.NavController.popBackStack(NavController.kt:449)
at androidx.navigation.NavController.popBackStack(NavController.kt:434)
at com.fragula2.navigation.SwipeBackFragment$onPageChangeCallback$1.onPageScrollStateChanged(SwipeBackFragment.kt:56)
at androidx.viewpager2.widget.CompositeOnPageChangeCallback.onPageScrollStateChanged(CompositeOnPageChangeCallback.java:87)
at androidx.viewpager2.widget.CompositeOnPageChangeCallback.onPageScrollStateChanged(CompositeOnPageChangeCallback.java:87)
at androidx.viewpager2.widget.ScrollEventAdapter.dispatchStateChanged(ScrollEventAdapter.java:426)
at androidx.viewpager2.widget.ScrollEventAdapter.onScrolled(ScrollEventAdapter.java:214)
at androidx.recyclerview.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:5173)
at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5338)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1041)
at android.view.Choreographer.doCallbacks(Choreographer.java:860)
at android.view.Choreographer.doFrame(Choreographer.java:781)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1026)
at android.os.Handler.handleCallback(Handler.java:914)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:225)
at android.app.ActivityThread.main(ActivityThread.java:7563)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)
To Reproduce
Steps to reproduce the behavior:
- Открыть фрагмент
- Закрыть фрагмент свайпом
При добавлении
viewPager?.post {
navBackStackAdapter?.pop()
}
вместо
navBackStackAdapter?.pop()
исключения нету, сделаю pr как возможный фикс.
#22