Conductor: Can interact with exiting controller

Created on 12 Dec 2016  路  4Comments  路  Source: bluelinelabs/Conductor

There appears to be an issue where the user can still interact with an exiting Controller.

The following code is in an onClick method in ControllerA. It creates a ControllerB and pushes it. The change handler uses an AnimatorSet of scales and rotations to switch between the controllers.

final RouterTransaction transaction = RouterTransaction.with(ControllerB.createInstance())
            .pushChangeHandler(new CrossRotateChangeHandler())
            .popChangeHandler(new CrossRotateChangeHandler()); 
getRouter().pushController(transaction);

The problem is that as ControllerA is transitioning away, I can still interact with it. In this case, it will create a second ControllerB and push it on top, such that the stack is now A->B->B`, and the animation will suddenly jank to be animating between B and B`.

This is easy to reproduce when setting the Animator duration scale in dev options.

The net effect of this is that all Controllers need to have ugly defensive code like this:

final String tag = ControllerB.class.getName();
if (getRouter().getControllerWithTag(tag) == null) {
    final RouterTransaction transaction = RouterTransaction.with(ControllerB.createInstance())
            .pushChangeHandler(new CrossRotateChangeHandler())
            .popChangeHandler(new CrossRotateChangeHandler())
            .tag(tag);
    getRouter().pushController(transaction);
}

Shouldn't Conductor prevent interaction with the exiting Controller?

Most helpful comment

If you use a ChangeHandlerFrameLayout as your router container this will be taken care of for you.

All 4 comments

If you use a ChangeHandlerFrameLayout as your router container this will be taken care of for you.

馃槺

Is that a reason why I sometimes get null when calling getActivity in an OnClickListener?

No, that was that wrong question.

Can this be the reason my onClick gets called after the hosting activity's onDestroy?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZakTaccardi picture ZakTaccardi  路  8Comments

JakeWharton picture JakeWharton  路  7Comments

DJafari picture DJafari  路  4Comments

lenguyenthanh picture lenguyenthanh  路  7Comments

PaulWoitaschek picture PaulWoitaschek  路  5Comments