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

Exception when clicking on the back arrow button while swiping a swipeable fragment #13

Closed
KitsuneFolk opened this issue May 14, 2023 · 7 comments
Assignees
Labels
bug Something that needs to be fixed

Comments

@KitsuneFolk
Copy link
Contributor

Library Version:
2.7

Affected Device(s):
Redmi 9C with Android 10, API 29
Describe the bug
If we open a swipeable fragment and then try to unswipe on 5dp or something, then slowly swipe back and press the back arrow button in the toolbar, the fragment becomes black. If we swipe from right to left, then it back to normal, but swipeable fragments in the recyclerview are not opening and if we try to open a swipeable fragment from the navigation view again, it throws the exception below:

java.lang.IllegalStateException: Fragment SwipeBackFragment{21e6e36} (56b51e72-7a1b-490c-82f0-2ad41f0a08f2) not attached to a context.
                                                                                                    	at androidx.fragment.app.Fragment.requireContext(Fragment.java:967)
                                                                                                    	at com.fragula2.adapter.NavBackStackAdapter.createFragment(NavBackStackAdapter.kt:14)
                                                                                                    	at androidx.viewpager2.adapter.FragmentStateAdapter.ensureFragment(FragmentStateAdapter.java:268)
                                                                                                    	at androidx.viewpager2.adapter.FragmentStateAdapter.onBindViewHolder(FragmentStateAdapter.java:175)
                                                                                                    	at androidx.viewpager2.adapter.FragmentStateAdapter.onBindViewHolder(FragmentStateAdapter.java:67)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
                                                                                                    	at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
                                                                                                    	at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
                                                                                                    	at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
                                                                                                    	at androidx.recyclerview.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1391)
                                                                                                    	at androidx.recyclerview.widget.LinearLayoutManager.scrollHorizontallyBy(LinearLayoutManager.java:1116)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView.scrollStep(RecyclerView.java:1838)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView.scrollByInternal(RecyclerView.java:1940)
                                                                                                    	at androidx.recyclerview.widget.RecyclerView.scrollBy(RecyclerView.java:1812)
                                                                                                    	at androidx.viewpager2.widget.FakeDrag.fakeDragBy(FakeDrag.java:95)
                                                                                                    	at androidx.viewpager2.widget.ViewPager2.fakeDragBy(ViewPager2.java:735)
                                                                                                    	at com.fragula2.utils.ExtensionsKt.fakeDragTo$lambda$1$lambda$0(Extensions.kt:88)
                                                                                                    	at com.fragula2.utils.ExtensionsKt.$r8$lambda$C6bpgJwUl--4hf-kWEmxak-d7uU(Unknown Source:0)
                                                                                                    	at com.fragula2.utils.ExtensionsKt$$ExternalSyntheticLambda0.onAnimationUpdate(Unknown Source:8)
                                                                                                    	at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1558)
                                                                                                    	at android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1349)
                                                                                                    	at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1481)
                                                                                                    	at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
                                                                                                    	at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
                                                                                                    	at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
                                                                                                    	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1039)
                                                                                                    	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:

  1. Open the native kotlin fragula app
  2. Open the Settings fragment in the navigation view
  3. Swipe from left to right a few millimeters, swipe back from right to left while pressing the toolbar's back button
  4. See the black screen, then swipe from right to left to get the fragment to normal
  5. Open the Settings fragment again and see the exception

I attached a video file, so you can see how exactly to reproduce the bug:
https://github.com/massivemadness/Fragula/assets/104719315/cb79f3b7-0c0c-4fbf-b8ae-0f47145c91d9

@KitsuneFolk KitsuneFolk added the bug Something that needs to be fixed label May 14, 2023
@massivemadness
Copy link
Owner

@MrRuslanYT привет, спасибо видео, постараюсь воспроизвести

massivemadness added a commit that referenced this issue May 16, 2023
When the user started scrolling, but then changed his mind and returned the fragment to its original position
@massivemadness
Copy link
Owner

@MrRuslanYT попробуй этот билд - 4995414771. Максимально костыльный фикс, но вроде работает

@KitsuneFolk
Copy link
Contributor Author

@massivemadness не, все равно баг сохраняется, уже удалил старое приложение и установил новый апк, не помогло

@KitsuneFolk
Copy link
Contributor Author

KitsuneFolk commented May 17, 2023

@massivemadness Сделал фикс в MainActivity, как я могу сделать pull request? Я попробовал через таб Pull Requestes, не получилось: Can't create a new pull request: Push failed: remote: Permission to massivemadness/Fragula.git denied to MrRuslanYT. unable to access 'https://github.com/massivemadness/Fragula.git/': The requested URL returned error: 403

@massivemadness
Copy link
Owner

massivemadness commented May 17, 2023

@MrRuslanYT тебе нужно форкнуть репозиторий и запушить в него изменения. Дальше твой форк с изменениями можно будет использовать для создания PR

@KitsuneFolk KitsuneFolk changed the title Exception when click on the back arrow button while swiping a swipeable fragment Exception when clicking on the back arrow button while swiping a swipeable fragment May 21, 2023
massivemadness pushed a commit that referenced this issue May 25, 2023
* Bug fix for issue #13

* Downgraded minSdk from 23 to 21

* Remove the raw fix of #13 MainActivity.kt

* Removed the last newline in MainActivity
@massivemadness
Copy link
Owner

massivemadness commented May 27, 2023

Сделал билд с исправлением, у меня проблема ушла (5098610511). Добавил проверку, чтобы в момент программного или пользовательского скроллинга нельзя было удалить страницу из viewpager-а. Подтверди как освободишься

@KitsuneFolk
Copy link
Contributor Author

Подтверждаю, баг исправлен, всё работает хорошо.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that needs to be fixed
Projects
None yet
Development

No branches or pull requests

2 participants