mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
A quick stab at CB-510
This commit is contained in:
parent
a705b72740
commit
f3e70c79eb
@ -336,6 +336,41 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the spinner
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void loadSpinner()
|
||||||
|
{
|
||||||
|
// If loadingDialog property, then show the App loading dialog for first page of app
|
||||||
|
// (This doesn't seem to actually do anything here)
|
||||||
|
String loading = null;
|
||||||
|
if (this.urls.size() == 1) {
|
||||||
|
loading = this.getStringProperty("loadingDialog", null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
loading = this.getStringProperty("loadingPageDialog", null);
|
||||||
|
}
|
||||||
|
if (loading != null) {
|
||||||
|
|
||||||
|
String title = "";
|
||||||
|
String message = "Loading Application...";
|
||||||
|
|
||||||
|
if (loading.length() > 0) {
|
||||||
|
int comma = loading.indexOf(',');
|
||||||
|
if (comma > 0) {
|
||||||
|
title = loading.substring(0, comma);
|
||||||
|
message = loading.substring(comma+1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
title = "";
|
||||||
|
message = loading;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.spinnerStart(title, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the url into the webview.
|
* Load the url into the webview.
|
||||||
*
|
*
|
||||||
@ -352,6 +387,15 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
// Load URL on UI thread
|
// Load URL on UI thread
|
||||||
final DroidGap me = this;
|
final DroidGap me = this;
|
||||||
|
|
||||||
|
final Runnable loadError = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
me.appView.stopLoading();
|
||||||
|
LOG.e(TAG, "DroidGap: TIMEOUT ERROR! - calling webViewClient");
|
||||||
|
appView.viewClient.onReceivedError(me.appView, -6, "The connection to the server was unsuccessful.", url);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this.runOnUiThread(new Runnable() {
|
this.runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
@ -362,34 +406,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
// Handle activity parameters (TODO: Somehow abstract this)
|
// Handle activity parameters (TODO: Somehow abstract this)
|
||||||
me.handleActivityParameters();
|
me.handleActivityParameters();
|
||||||
|
|
||||||
// If loadingDialog property, then show the App loading dialog for first page of app
|
// Then load the spinner
|
||||||
// (This doesn't seem to actually do anything here)
|
me.loadSpinner();
|
||||||
String loading = null;
|
|
||||||
if (me.urls.size() == 1) {
|
|
||||||
loading = me.getStringProperty("loadingDialog", null);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
loading = me.getStringProperty("loadingPageDialog", null);
|
|
||||||
}
|
|
||||||
if (loading != null) {
|
|
||||||
|
|
||||||
String title = "";
|
|
||||||
String message = "Loading Application...";
|
|
||||||
|
|
||||||
if (loading.length() > 0) {
|
|
||||||
int comma = loading.indexOf(',');
|
|
||||||
if (comma > 0) {
|
|
||||||
title = loading.substring(0, comma);
|
|
||||||
message = loading.substring(comma+1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
title = "";
|
|
||||||
message = loading;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
me.spinnerStart(title, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a timeout timer for loadUrl
|
// Create a timeout timer for loadUrl
|
||||||
final int currentLoadUrlTimeout = me.loadUrlTimeout;
|
final int currentLoadUrlTimeout = me.loadUrlTimeout;
|
||||||
@ -405,15 +424,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
// If timeout, then stop loading and handle error
|
// If timeout, then stop loading and handle error
|
||||||
if (me.loadUrlTimeout == currentLoadUrlTimeout) {
|
if (me.loadUrlTimeout == currentLoadUrlTimeout) {
|
||||||
|
me.runOnUiThread(loadError);
|
||||||
//TURTLES, TURTLES ALL THE WAY DOWN!!!!!
|
|
||||||
me.runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
me.appView.stopLoading();
|
|
||||||
LOG.e(TAG, "DroidGap: TIMEOUT ERROR! - calling webViewClient");
|
|
||||||
appView.viewClient.onReceivedError(me.appView, -6, "The connection to the server was unsuccessful.", url);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user