bluelinelabs / Conductor

A small, yet full-featured framework that allows building View-based Android applications
Apache License 2.0
3.9k stars 343 forks source link

How to know if a controller view is in the front screen? #660

Open johnjeremih opened 2 years ago

johnjeremih commented 2 years ago

I'm using EventBus. A child controller depends on the main controller, the child controller is calling the methods from the main controller. Now, I need to know how I can check whether the user is on main controller or not. I tried using onViewBound and onViewView, but the onViewBound and onViewView get called only when the user opens the controller for the first time, if the user goes back to the previous controller the onViewBound and onViewView never get called.

Any thoughts?

ursusursus commented 2 years ago

router.backstack

johnjeremih commented 2 years ago

@ursusursus can you please tell me how do you use it? Using backstack.size doesn't work for me.

ursusursus commented 2 years ago

its a iterable you can look into to see if your controller is there

router.backstack.firstOrNull { it.controller is MainController }