Comments (7)
I couldn't press Back quickly enough, but it is easily reproducible programmatically, by calling FragmentManager.popBackStack()
immediately after commit()
, or from second fragment's onCreate()
.
from viewbindingpropertydelegate.
Also reproduced this error when switching fragments programmatically, is there any way to destroy binding without using a handler?
from viewbindingpropertydelegate.
Also reproduced this error when switching fragments programmatically, is there any way to destroy binding without using a handler?
Yes, you can keep reference to the delegate instance and call clear()
from viewbindingpropertydelegate.
Need to check the bug with AndroidX Fragment 1.3.0. @midery , please do this and write about results
from viewbindingpropertydelegate.
Need to check the bug with AndroidX Fragment 1.3.0. @midery , please do this and write about results
Checked this issue in AndroidX Fragment 1.3.0. Surprisingly, it isn't reproducing anymore.
It happens because the Fragment.onDestroyView call is now "postponed" and cancellable in new FragmentManager implementation.
Fragment.destroyFragmentView now is bound to a FragmentTransition, which is used to show fragment's removal. If the transition is not yet completed - Fragment's view won't be destroyed.
Thus, if we will try to press back after the new fragment is added and current fragment is being replaced, it will happen before transition's completion, and the viewBindings would not be cleared.
So, the logs now are showing something like this:
- Fragment B: onCreateView
- Fragment B: BackPressed
- Fragment A: onDestroyView
- Fragment A: onCreateView <-- valid viewBinding here
- Fragment A: onStart
- Fragment A: onResume //on destroy is never called
TL;DR: Update the AndroidX Fragment artifact to version 1.3.0+ and this issue will be fixed.
from viewbindingpropertydelegate.
viewBindings would not be cleared
Sorry, but this is exactly the issue. I see no difference between Fragment 1.2.5 & 1.3.0 in this respect.
Here is a sample project to reproduce. After forward-back navigation the text on screen is wrong, because FirstFragment
's binding
still points to old view during onViewCreated
.
from viewbindingpropertydelegate.
viewBindings would not be cleared
Sorry, but this is exactly the issue. I see no difference between Fragment 1.2.5 & 1.3.0 in this respect.
Here is a sample project to reproduce. After forward-back navigation the text on screen is wrong, becauseFirstFragment
'sbinding
still points to old view duringonViewCreated
.
Please open separate issue with your bug
from viewbindingpropertydelegate.
Related Issues (20)
- java.lang.IllegalStateException Fragment's view can't be accessed. Fragment isn't added HOT 1
- IllegalStateException when using viewBinding for onCreateView HOT 14
- Can give a sample of how to use RecyclerView.ViewHolder? HOT 1
- IllegalStateException: Fragment's view can't be accessed. HOT 6
- IllegalStateException FragmentViewBindingProperty.getLifecycleOwner HOT 1
- UnresolvedReference HOT 2
- Crash on language change HOT 7
- Android Studio Dolphin | 2021.3.1 does not show layout preview HOT 2
- IllegalStateException: Fragment's view can't be accessed. Fragment isn't added. - when trying to restore fragment state HOT 1
- Kkk
- Custom views are crashing preview after updating Android Studio up to Dolphin HOT 1
- Hgf
- Version 1.5.8 onwards causes error in RecyclerView HOT 1
- NoClassDefFoundError HOT 1
- Clear happens after onViewCreated HOT 3
- Cresh issue HOT 2
- Crash HOT 1
- java.lang.IllegalStateException: Host view isn't ready to create a ViewBinding instance HOT 4
- Lint errors when updated to 1.5.6 HOT 1
- Access to viewBinding after Lifecycle is destroyed or hasn't created yet. The instance of viewBinding will be not cached. HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from viewbindingpropertydelegate.