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.
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.
Scott Junner9,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()