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

Android Weather App: Hooking Up the Model to the View section, Using a ProgressBar Challenge

Challenge Link:

http://teamtreehouse.com/library/build-a-weather-app/hooking-up-the-model-to-the-view/using-a-progress-bar

Challenge Task 1 of 3

We've added a ProgressBar (spinner) to the Activity for when movie data is being loaded. Inject it using Butter Knife, just like the other member variables. Name it mProgressBar and use progressBar as the ID.

This is the line that's needed (which you could sort of figure out if you read threw the question a few dozen times):

@InjectView(R.id.progressBar) ProgressBar mProgressBar;

..which goes right after the other two @InjectView lines.

On to the next challenge..

Challenge Task 2 of 3

We want to display the progress bar while the network call is executing. Add the line of code to show it in the getMovieInfo() method.

Here's the getMovieInfo() code (with the needed line added):

    public void getMovieInfo() {
        if (isNetworkAvailable()) {
            // Some code omitted. Show the progress bar!
          mProgressBar.setVisibility(View.VISIBLE);
        }
    }

Proceeding onward to the final challenge..

Challenge Task 3 of 3

When the movie is retrieved we end up calling the updateDisplay() method. Hide the progress bar in there.

    public void updateDisplay(Movie movie) {
        // Some code omitted. Hide the progress bar.
        mProgressBar.setVisibility(View.INVISIBLE);
    }

By the way I found that line to set mProgressBar invisible code line in

Kevin's code (under 'public void handleBlogResponse()' ) from this forum thread:

https://teamtreehouse.com/forum/app-cant-connect-to-the-blog-after-doing-opening-a-webpage-in-browser-class

Thx for the help