androidkotlincontrollerbottomnavigationviewconductor

Conductor: Popping to controller without showing in view


I have an app that uses Conductor to handle it's Bottom Nav bar navigation. For sake of brevity, I will try to describe it as concisely as possible. The app has a good amount of logic in place which I want to touch as minimally as possible

The issue i'm having has to do with ControllerChangeHandler.onChangeCompleted()

The bottom nav is structured as so..

Dashboard | Login | Doctors | Locations | More

When the user logs in via the Login tab, Conductor pops to my Dashboard Controller very quickly then launches a new activity, so that when the user hit's back button they are return to BottomNav Activity and land on dashboard.

The issue i'm having is that the user is able to see the Dashboard view flash for half a second before the new activity launches.

  router.popToTag(newTag, null)

^^ Should passing in null for ChangeHandler prevent any swapping of views? Or will it simple swap the views without any fancy animations?? I believe this is where the source of my confusion is.

I was hoping that by having ChangeHandler set to null, there would be no visible animation, but views still swap before launching activity.

Unfortunetly, my login logic and flow is tightly dependent on OnChangeCompleted(). So I need Conductor to pop to the new controller, I just need it to happen completely invisible to the user...

Any advice?? I think if my question directly under the line of code is answered that will help me a lot.


Solution

  • Conductor ships with the class com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler which should fit your use case. Looking at the source, it does nothing other than call ControllerChangeCompletedListener.onChangeCompleted(). As I understand, that should mean that no views are added or removed.

    To answer your question about passing in a null change handler, the internal method in the library responsible for handling changes contains the following code:

    if (inHandler == null) {
        handler = new SimpleSwapChangeHandler();
    } else if (inHandler.hasBeenUsed && !inHandler.isReusable()) {
        handler = inHandler.copy();
    } else {
        handler = inHandler;
    }
    

    where inHandler refers to the change handler you passed in to the popToTag method. The SimpleSwapChangeHandler does swap the views with no animation exactly as you've discovered.