question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drawer does not work with FragNav

See original GitHub issue

I’m using FragNav for fragments navigation (https://github.com/ncapdevi/FragNav) and when i set up MainActivity like this:

@AndroidEntryPoint
class MainActivity : AppCompatActivity(), FragNavController.TransactionListener {
    private val binding by viewBinding(ActivityMainBinding::inflate)

    val fragNavController = FragNavController(supportFragmentManager, R.id.fragmentContainer)

    override fun onCreate(savedInstanceState: Bundle?) {
        setTheme(R.style.AppTheme)
        super.onCreate(savedInstanceState)
        setContentView(binding.root)

        fragNavController.apply {
            transactionListener = this@MainActivity
            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)
        }
    }
}

the Beagle.show() returns false. When i inspect layout - no overlay is being added. If i disable FragNav like this:

@AndroidEntryPoint
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.fragmentContainer, HomeFragment())
        }
    }
}

It works perfectly. FragNav is pretty important to me. Is there a way to bypass this issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pandulapetercommented, Aug 17, 2020

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!

1reaction
pandulapetercommented, Aug 17, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Drawer navigation header button does not work after click
I can see the button but no respond when click on it. I tried to add button click event in MainActivity > OnCreate()...
Read more >
Fragment Navigation in Android Using FragNav Library
Implement clean, explicit and powerful Fragment navigation in your Android apps using FragNav library.
Read more >
FragNav: A Library for managing navigation between multiple stacks ...
It should absolutely work with the navigation drawer, as the library should be entirely independent of the UI that's controlling it. There are...
Read more >
FragNav vs Duo Navigation Drawer - compare differences and ...
Compare FragNav vs Duo Navigation Drawer and see what are their differences. ... My biggest issues now are with how the IDE editor...
Read more >
Android Fragments Common Queries & Common Mistakes
Fragment BottomBarNavigation and drawer. ... So when people say ViewPager is not refreshed it's nothing but old ... ncapdevi/FragNav ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found