Add progress bar

This commit is contained in:
Felix Kloft 2013-05-15 12:29:30 +02:00
parent db42329234
commit 69ee110182

View File

@ -53,6 +53,7 @@ public class DeviceAccountLogin implements AccountManagerCallback<Bundle> {
private Account[] mAccounts; private Account[] mAccounts;
private IITC_Mobile mActivity; private IITC_Mobile mActivity;
private String mAuthToken; private String mAuthToken;
private AlertDialog mProgressbar;
private WebView mWebView; private WebView mWebView;
private DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() { private DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
@ -74,8 +75,7 @@ public class DeviceAccountLogin implements AccountManagerCallback<Bundle> {
} }
private void displayAccountList() { private void displayAccountList() {
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
builder
.setTitle(R.string.choose_account_to_login) .setTitle(R.string.choose_account_to_login)
.setSingleChoiceItems(mAccountAdapter, 0, onClickListener) .setSingleChoiceItems(mAccountAdapter, 0, onClickListener)
.setNegativeButton(android.R.string.cancel, onClickListener); .setNegativeButton(android.R.string.cancel, onClickListener);
@ -89,6 +89,12 @@ public class DeviceAccountLogin implements AccountManagerCallback<Bundle> {
} }
private void startAuthentication() { private void startAuthentication() {
mProgressbar = new AlertDialog.Builder(mActivity)
.setCancelable(false)
.setView(mActivity.getLayoutInflater().inflate(R.layout.dialog_progressbar, null))
.create();
mProgressbar.show();
mAccountManager.getAuthToken(mAccount, mAuthToken, null, mActivity, this, null); mAccountManager.getAuthToken(mAccount, mAuthToken, null, mActivity, this, null);
} }
@ -101,6 +107,9 @@ public class DeviceAccountLogin implements AccountManagerCallback<Bundle> {
@Override @Override
public void run(AccountManagerFuture<Bundle> value) { public void run(AccountManagerFuture<Bundle> value) {
if (mProgressbar != null)
mProgressbar.hide();
try { try {
Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT); Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT);
if (launch != null) { if (launch != null) {