Skip to content

Commit

Permalink
show progress dialog while creating webview dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
PierfrancescoSoffritti committed Jul 28, 2016
1 parent 30df5d0 commit dbab5fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ allprojects {
Add this to your module-level `build.gradle`:
```
dependencies {
compile 'com.github.PierfrancescoSoffritti:WebBasedOAuth:0.5'
compile 'com.github.PierfrancescoSoffritti:WebBasedOAuth:0.6'
}
```
## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.net.Uri;
Expand Down Expand Up @@ -51,6 +52,8 @@ public class Authenticator {

private final Semaphore available = new Semaphore(0, true);

private final ProgressDialog progressDialog;

/**
* @param context base activity.
* @param persister responsible for storing the auth credentials.
Expand Down Expand Up @@ -79,6 +82,11 @@ public Authenticator(@NonNull Activity context, @NonNull CredentialPersister per
this.clientSecret = clientSecret;

this.credentialStore = new CredentialStore(persister);

progressDialog = new ProgressDialog(context);
progressDialog.setMessage(context.getString(R.string.loading));
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(true);
}

private String buildScopesString(String[] scopes) {
Expand Down Expand Up @@ -196,6 +204,8 @@ private void refreshToken() {
*/
@SuppressLint("SetJavaScriptEnabled")
private void showDialog(final CredentialStore credentialStore) {
progressDialog.show();

final Dialog authDialog = new Dialog(context);
authDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

Expand Down Expand Up @@ -234,6 +244,7 @@ public void onDismiss(DialogInterface dialog) {

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon){
progressDialog.dismiss();
}

@Override
Expand Down

0 comments on commit dbab5fd

Please sign in to comment.