Comments (9)
maybe a DefaultStateChanger for Fragments is enough?
from simple-stack.
So far I didn't have any problems while using this:
Navigator.configure()
.setStateChanger(FragmentStateChanger(supportFragmentManager, R.id.fragmentContainer))
.setShouldPersistContainerChild(false)
.install(this, fragmentContainer, HistoryBuilder.single(Key()))
I'll give an update if something needs to be done more.
from simple-stack.
It might be impossible because I cannot guarantee the recreation order of fragments after process death, and internally Navigator hosts the BackstackManager in a retained fragment - this is why I'm able to do Navigator.get(context)
in any view
Although I also think that once Navigator creates a view, the fragment could be added to the view as the fragment will be bound to a containerId. I don't think I have tried this.
But basically the fragments in the fragment manager are recreated in an unordered manner, so it's tricky. I listen for onCreate()
of the retained fragment, and I cannot tell which fragment will be alive and who isn't.
Although, maybe you can use deferred initialization and make it reliable. Hmm...
from simple-stack.
I'll try it out with deferred init and see what happens.
But the tricky thing is that BackstackDelegate
can also be shared through the context with the getSystemService()
trick, which allows it to work similarly to navigator.
from simple-stack.
There is a bit more configuration required for Fragments than for View, because I'd have to provide a fragment you need to inherit from. Either to have the key in the arguments, or maybe even to bind it into the view hierarchy in view inflation in onCreateView`.
Either way, I'd have to modularize the project and have the core, the navigator support, and a fragment support component.
Not a bad idea though, if I get past the intimidation of setting up multi-project for jitpack release
from simple-stack.
Any updates on this? I might also try and work on this. I'll see what I can do
from simple-stack.
No I've been super-busy and this would bring 2.0 with it, so it's a bit more complicated.
You can try using Navigator with one of the fragment state changers that use add/attach/detach/remove and see if it's stable enough, in the meantime. Just use Navigator.configure().setStateChanger(new FragmentStateChanger()).shouldPersistContainerChild(false).install(...)
from simple-stack.
@gumil if there can be an issue with it, it's after process death.
You can verify process death behavior by putting your app in background with HOME, press "Terminate application" button in Android Studio (it's a Red X in the logcat tab), then restart your app in launcher.
If you get unpredictable behavior, like fragments being reloaded multiple times and stuff, then it doesn't work well.
But there is a chance that it does work.
from simple-stack.
1.) navigator CAN be used with Fragments, although it's not possible if you use ScopedServices + FragmentFactory.
Otherwise, it works fine.
In fact, now it is preferred for 2.x.
2.) this would introduce a lot of complexity for maintenance so it won't happen. 🤔
from simple-stack.
Related Issues (20)
- Allow removing a `Backstack.CompletionListener` from inside the listener itself HOT 5
- Clarification: can a service be registered/unregistered more than once? HOT 5
- Can I Use @styles/Theme.MyComposeTheme on AndroidManifests.xml? HOT 3
- Question: What is the purpose of RegistrationViewModel inside ServiceProvider in extension-compose-example? HOT 4
- What is the proper way to add a key to the top even if it already exists in the backstack? HOT 2
- Publish to MavenCentral instead of just Jitpack.io
- Unable to start activity ComponentInfo{com.xxxxxxxxxx.yyyyyy/com.xxxxxxxxxx.yyyyyy.activities.MainActivity}: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment q2.v1: could not find Fragment constructor HOT 7
- How to 'lookup<>()' scoped class from an Android Service HOT 2
- Lazy initialization of ScopedServices HOT 2
- KMM support? HOT 2
- Screen can get the service from wrong scope during back animation HOT 6
- Backstack is not available in a child Fragment's onCreate after process death
- DialogFragment and BottomDialogFragment as part of navigation stack, question HOT 2
- Verify that the new `setParentServices()`'s `lookupFromScope(..., EXPLICIT)` behavior is what is expected
- Updating the Compose example to Compose 1.5.0 requires AGP 8.1
- Should Simple Stack be used in new projects HOT 14
- Crash due to activity.onBackPressed() when removing fragment hosting a WebView in AndroidView {} + FADE HOT 15
- Backstack with espresso HOT 3
- The service does not exist in any accessible scopes HOT 11
- Up navigation examples are hard to find HOT 3
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 simple-stack.