Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Animations and Transitions The Transitions Framework Transitioning Back and Forth

cdlvr
cdlvr
14,448 Points

Why is mCurrentScene set in both onTrackPanelClicked and in the setEnterAction Runnables?

In onTrackPanelClicked(), mCurrentScene is set to the scene that we are transitioning to. Again in the run() method of setEnterAction()'s Runnable, mCurrentScene is set to the scene we are transitioning to. To me it seems like this redundant: by the time run() is called, mCurrentScene is already set to the correct value due to the logic/assignment in onTrackPanelClicked(). Am I missing something? The transition still seems to work as expected with the run() methods' mCurrentScene assignment commented out.

Sachin Jayaram
Sachin Jayaram
5,461 Points

In the setEnterAction method you are trying to repopulating the values else it would get set to its default value. Basically in one of the previous videos when you click the onTrackPanel button the color used t change to default and to coreect that you added the setEnterAction method and hence you would have to update all the values that are coupled to make sure the behavior doesn't change.

1 Answer

Scott Junner
Scott Junner
9,010 Points

I've been sitting here scratching my head over this one too. And after commenting out the lines setting mCurrentScene in both calls to setEnterAction it seems you are right.

Setting mCurrentScene in setEnterAction() is redundant. There is no need for it. mCurrentScene is set in onTrackPanelClicked()