Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Animations and Transitions The Transitions Framework Transitioning Back and Forth

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()