Add progress bars
- indeterminate progress bar for authentication stuff - determinate progress bar for page loading (The second one was added so you can see that there is something happening after selecting your account)
This commit is contained in:
parent
69ee110182
commit
8cf0f3fff0
6
mobile/res/layout/dialog_progressbar.xml
Normal file
6
mobile/res/layout/dialog_progressbar.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/progressBarLoading"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
@ -72,6 +72,11 @@ public class DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
||||
mWebView = webView;
|
||||
mAccountManager = AccountManager.get(activity);
|
||||
mAccountAdapter = new AccountAdapter();
|
||||
|
||||
mProgressbar = new AlertDialog.Builder(mActivity)
|
||||
.setCancelable(false)
|
||||
.setView(mActivity.getLayoutInflater().inflate(R.layout.dialog_progressbar, null))
|
||||
.create();
|
||||
}
|
||||
|
||||
private void displayAccountList() {
|
||||
@ -89,10 +94,6 @@ public class DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
||||
}
|
||||
|
||||
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);
|
||||
@ -107,8 +108,7 @@ public class DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
||||
|
||||
@Override
|
||||
public void run(AccountManagerFuture<Bundle> value) {
|
||||
if (mProgressbar != null)
|
||||
mProgressbar.hide();
|
||||
mProgressbar.hide();
|
||||
|
||||
try {
|
||||
Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT);
|
||||
|
@ -2,7 +2,13 @@ package com.cradle.iitc_mobile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.cradle.iitc_mobile.R;
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.res.Configuration;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
@ -13,17 +19,12 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.StrictMode;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -47,12 +48,25 @@ public class IITC_Mobile extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||
|
||||
// TODO build an async task for url.openStream() in IITC_WebViewClient
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
|
||||
.permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
setContentView(R.layout.activity_main);
|
||||
iitc_view = (IITC_WebView) findViewById(R.id.iitc_webview);
|
||||
iitc_view.setWebChromeClient(new WebChromeClient()
|
||||
{
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
super.onProgressChanged(view, newProgress);
|
||||
|
||||
// maximum for newProgress is 100
|
||||
// maximum for setProgress is 10,000
|
||||
setProgress(newProgress * 100);
|
||||
}
|
||||
});
|
||||
|
||||
// fetch actionbar, set display flags, title and enable home button
|
||||
actionBar = this.getActionBar();
|
||||
|
Loading…
x
Reference in New Issue
Block a user