GithubHelp home page GithubHelp logo

Comments (5)

pandulapeter avatar pandulapeter commented on May 23, 2024 1

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.

pandulapeter avatar pandulapeter commented on May 23, 2024 1

Awesome 👍 And thanks for posting the code as well.

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.

pandulapeter avatar pandulapeter commented on May 23, 2024

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.

jakoss avatar jakoss commented on May 23, 2024

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.

jakoss avatar jakoss commented on May 23, 2024

Also, is it necessary to create Overlay while using dialog or bottom sheet menu?

from beagle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.