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

The dreaded "Adding a Progress Incdicator" challenge (3 parts)

Here's the link to the challenge: http://teamtreehouse.com/library/adding-a-progress-indicator

It starts out innocently enough with:

Challenge Task 1 of 3

In the onCreate() method, add the line of code that requests the progress indicator window feature. Here's some helpful text that you can copy and paste: Window.FEATURE_INDETERMINATE_PROGRESS

However that hint doesn't include:

requestWindowFeature

So the you have to know to add that, as well as the parenthesis, and put it the line of code in the right place:

public class SignUpActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // rest of code omitted
    }

    protected void signUp(String username, String password) {
        ParseUser newUser = new ParseUser();
        newUser.setUsername(username);
        newUser.setPassword(password);
        newUser.signUpInBackground(new SignUpCallback() {
            @Override
            public void done(ParseException e) {
                // some code omitted
            }
        });
    }
}

Then you proceed on to:

Challenge Task 2 of 3

Now show the progress indicator right before the signUpInBackground() method is executed. Here is some more helpful copy/paste text: setProgressBarIndeterminateVisibility

Seems like a simple copy/paste?

Right?

No --Wrong!

you have to add

(true);

to the end of the line to get:

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import com.parse.ParseUser;
import com.parse.ParseException;
import com.parse.SignUpCallback;

public class SignUpActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // rest of code omitted
    }

    protected void signUp(String username, String password) {
        ParseUser newUser = new ParseUser();
        newUser.setUsername(username);
        newUser.setPassword(password);
        setProgressBarIndeterminateVisibility(true);
        newUser.signUpInBackground(new SignUpCallback() {
            @Override
            public void done(ParseException e) {
                // some code omitted
            }
        });
    }
}

So by now (hopefully) you are getting wise to the fact that when the challenge says:

"copy/paste"

it really means:

"copy/edit/paste"

With that thought in mind (forewarned is fore-armed)..

Challenge Task 3 of 3

Finally, hide the progress indicator when signUpInBackground() completes.

So i jump out of my chair thinking:

"at last they gave us both parts of the copy/edit/paste"

Namely:

'hide' and 'signUpInBackground()'

Thus the line of code needing to be added is

(or should naturally be):

signUpInBackground(hide);

Alas..you were supposed to realize

(without the challenge ever bothering to tell you),

that if you were using 'true' (and the code passed)

to make it visible than using boolean logic

the correct line would be

setProgressBarIndeterminateVisibility(false);

Still confused about Boolean logic in java

(so was I..)

Here's a link: http://en.wikibooks.org/wiki/Java_Programming/Boolean_expressions

............

Then the question becomes where (on which line)

does the 'complete' event happen.

In the middle of the first set of curly braces (before the override)

for signUpInBackground() ,

..or maybe after the final set of curly braces for void done?

After much experimentation you maybe are able to come

up with something that passes like:

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import com.parse.ParseUser;
import com.parse.ParseException;
import com.parse.SignUpCallback;

public class SignUpActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // rest of code omitted
    }

    protected void signUp(String username, String password) {
        ParseUser newUser = new ParseUser();
        newUser.setUsername(username);
        newUser.setPassword(password);
        setProgressBarIndeterminateVisibility(true);
        newUser.signUpInBackground(new SignUpCallback() {
            @Override
            public void done(ParseException e) {
                // some code omitted
              setProgressBarIndeterminateVisibility(false);
            }
        });
    }
}

But be careful about using setProgressBarIndeterminateVisibility in other projects because you may end up with a NullPointerException like this guy did: https://teamtreehouse.com/forum/delete-the-calling-of-the-original-set-progress-bar-methods

Here's another guy that tried to use some of code from this challenge and had issues also: https://teamtreehouse.com/forum/progress-bar-doesnt-appear-in-android-project-with-setprogressbarindeterminatevisibility

..and still more issue for someone else using 'requestwindowfeature": https://teamtreehouse.com/forum/after-adding-requestwindowfeature-i-cant-open-ribbit

No one said trying to use the Ribbit / Build a Self-Destructing Message Android App code was going to be easy, did they?

Thanks for this!

No one said trying to use the Ribbit / Build a Self-Destructing Message Android App code was going to be easy, did they?

It's not even easy in the app... especially since the actionBarTabs were deprecated. The tabbed template isn't creating itself, unless you have updates within two weeks or so from today. (I know because my desktop was updated about 2 or so weeks ago, while my portable development device was updated within a week or so-- and action bar tabs makes lines through everything on the desktop, but with the updates it makes 'toolbar' and tabs-- along with a floating 'snackbar' you have to remove... and the dummy fragment isn't a dummy anymore....)

I have downloaded 4 Ribbit apps from the play store, and I can't log in to any of them.