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 Build a Blog Reader Android App Adapting Data for Display in a List Cleaning Up Our Presentation

Harry Kendall
Harry Kendall
2,463 Points

is dialog disappearance a feature or a bug?

while working through this video, i noticed that the dialogue box did indeed work as expected, however once i added in the progressbar code, if i turn off the network, my app would just sit there with the spinning progressbar for... ever? also the text we set into the empty textView never shows.

i assumed this was an error i made, so i re-watched the video to see what i had missed, then just to be sure i downloaded the sample code and installed the pre-built apk on my phone, with showed the same behaviour... leading me to wonder if this is the intended behaviour(seems strange!), or just a bug... its been a long day and my head is full of little robots, so i apologize if this is self-evident, i shall re-watch the video again in the morning... :-) thanks!!

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Sounds like you found a bug! I just recreated it based on your description.

It looks like I forgot to hide the ProgressBar by default. We can do that in the layout file by adding a visibility parameter:

    <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:visibility="invisible" />

Then, to have the empty text view display, we would need to use the same lines from updateDisplayForError() in the else condition in onCreate(), like this:

        if (isNetworkAvailable()) {
            mProgressBar.setVisibility(View.VISIBLE);
            GetBlogPostsTask getBlogPostsTask = new GetBlogPostsTask();
            getBlogPostsTask.execute();
        }
        else {
            Toast.makeText(this, "Network is unavailable!", Toast.LENGTH_LONG).show();
                TextView emptyTextView = (TextView) getListView().getEmptyView();
        emptyTextView.setText(getString(R.string.no_items));
        }

But now we have the same code in two places, so we should refactor those two lines into a little helper method.

Sorry for the confusion! I'll address this when I refresh the course. I added a Known Issue in the Teacher's Notes as well.

Harry Kendall
Harry Kendall
2,463 Points

No worries, thanks for the explanation! does this mean i get that exterminator badge the treehouse FAQ alludes to? :-)

and ill take this opportunity to thank you Ben, for your great work, this android course has been a pleasure to work through so far!

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Oh yeah! I just need to tag Elizabeth Fawkes, Rob Allessi, and chelseyv. One of them can award you the badge. :) And thanks for the kind words!

Ben Jakuben done! :) Thanks for tagging us.

Harry Kendall, you should see the exterminator badge on your profile. Thanks for helping us with our bug-squashing mission!