Comments (5)
Hi,
Thanks for the bug report, this sounds interesting! I've never used FragNav so I'm investigating this right now (I've managed to reproduce the issue). Should be something simple, as apparently this addOverlayFragment() function fails to do its job, my first guess was that FragNav is replacing the Fragment in the android.R.id.content FrameLayout with something else but looks like that's not the case. Anyway, I'll let you know when I find something.
from beagle.
Awesome
Yeah, the OverlayFragment does a couple of things: while you're right that its View hierarchy is only used for the Drawer, it also handles some Activity Results (screenshot, screen recording) and the keyline overlay module which must work for all types, so it must be added.
I'll close this one for now, I think this is a reasonable workaround and a more elegant solution would be the ability to whitelist some Fragment tags in FragNav which doesn't depend on us. Thanks for bringing it up, let me know if you find anything else!
from beagle.
I think I found it.
During its initialize() function, in line 201 FragNav removes all Fragments from the FragmentManager (which at that moment already contains the OverlayFragment needed for Beagle). Now, maybe I could introduce a small delay to circumvent this but this comment is pretty clear, and we might introduce further issues down the road. Exposing the OverlayFragment for you to manually add is cumbersome + can introduce issues with the release build.
I think I have a solution but I'd kindly ask you to give it a try with your setup. Could you let Beagle use the Activity's supportFragmentManager (as it does now) but initialize FragNav within a Fragment, using that Fragment's childFragmentManager? From what I saw, that could work and would be a relatively quick fix (besides introducing a Fragment into the hierarchy...). Will this fix your issue? If it does, is it too much overhead when using FragNav?
I'll think about it a bit more but for now I don't see a fix that won't affect other users negatively (people using manual Fragment management / Jetpack Navigation).
from beagle.
Ok, so i changed my activity to this:
class MainActivity : AppCompatActivity() {
private val binding by viewBinding(ActivityMainBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
setContentView(binding.root)
supportFragmentManager.commit {
replace(R.id.activityFragmentContainer, MainNavigationFragment())
}
}
}
and MainNavigationFragment looks like this:
class MainNavigationFragment : Fragment(R.layout.fragment_main_navigation) {
val fragNavController by lazy {
FragNavController(
childFragmentManager,
R.id.fragmentContainer
)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
fragNavController.apply {
rootFragments = listOf(HomeFragment())
fragNavLogger = object : FragNavLogger {
override fun error(message: String, throwable: Throwable) {
Timber.e(throwable, message)
}
}
defaultTransactionOptions = FragNavTransactionOptions.newBuilder().customAnimations(
R.anim.slide_left_from_right,
R.anim.slide_left_from_middle,
R.anim.slide_right_from_left,
R.anim.slide_right_from_middle
).build()
initialize(savedInstanceState = savedInstanceState)
}
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, backCallback)
}
}
And it works fine so far. I don't think that one more fragment in hierarchy will drastically impact the performance, so this is ok for me 👍🏻
from beagle.
Also, is it necessary to create Overlay while using dialog or bottom sheet menu?
from beagle.
Related Issues (20)
- NoSuchMethodError somewhere in Beagle.initialize() after moving to Hilt HOT 4
- Coil update HOT 3
- TextInputModule Crash HOT 2
- On SDK 31 and above the screen recording crashes when started HOT 1
- Beagle crash logging doesn't work HOT 2
- Crash with DrawerLayout when getting permissions HOT 3
- Drawer doesn't appear when using content.viewTreeObserver.addOnPreDrawListener on the Acitivty HOT 5
- Beagle should not cause a crash if a value is set to the Slider module that is outside the specified range HOT 1
- The drawer opening gesture does not respect the value of `shouldShowDebugMenu` HOT 1
- Can't open Activity when try to forceCrash from debug panel HOT 7
- ListModules should support the isEnabled flag.
- TextInputModule. Suggestion for improving the validator
- Buggy inset handling in edge-to-edge apps
- SwitchModule. Ui data not re-initialize. Reset selected state HOT 5
- Double debug-panel HOT 3
- When activity theme is not a material theme, Beagle view crashes. HOT 3
- Implement dynamic notification permission support HOT 1
- Android 14 and gesture to preview back HOT 2
- Possibility to change the width of the drawer HOT 2
- The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant). HOT 2
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 beagle.