A quick stab at CB-510

This commit is contained in:
Joe Bowser 2012-05-10 16:42:37 -07:00
parent a705b72740
commit f3e70c79eb

View File

@ -336,41 +336,20 @@ public class DroidGap extends Activity implements CordovaInterface {
}
}
/**
* Load the url into the webview.
/*
* Load the spinner
*
* @param url
*/
private void loadUrlIntoView(final String url) {
if (!url.startsWith("javascript:")) {
LOG.d(TAG, "DroidGap.loadUrl(%s)", url);
}
if (!url.startsWith("javascript:")) {
LOG.d(TAG, "DroidGap: url=%s baseUrl=%s", url, baseUrl);
}
// Load URL on UI thread
final DroidGap me = this;
this.runOnUiThread(new Runnable() {
public void run() {
// Init web view if not already done
if (me.appView == null) {
me.init();
}
// Handle activity parameters (TODO: Somehow abstract this)
me.handleActivityParameters();
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 (me.urls.size() == 1) {
loading = me.getStringProperty("loadingDialog", null);
if (this.urls.size() == 1) {
loading = this.getStringProperty("loadingDialog", null);
}
else {
loading = me.getStringProperty("loadingPageDialog", null);
loading = this.getStringProperty("loadingPageDialog", null);
}
if (loading != null) {
@ -388,8 +367,48 @@ public class DroidGap extends Activity implements CordovaInterface {
message = loading;
}
}
me.spinnerStart(title, message);
this.spinnerStart(title, message);
}
}
/**
* Load the url into the webview.
*
* @param url
*/
private void loadUrlIntoView(final String url) {
if (!url.startsWith("javascript:")) {
LOG.d(TAG, "DroidGap.loadUrl(%s)", url);
}
if (!url.startsWith("javascript:")) {
LOG.d(TAG, "DroidGap: url=%s baseUrl=%s", url, baseUrl);
}
// Load URL on UI thread
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() {
public void run() {
// Init web view if not already done
if (me.appView == null) {
me.init();
}
// Handle activity parameters (TODO: Somehow abstract this)
me.handleActivityParameters();
// Then load the spinner
me.loadSpinner();
// Create a timeout timer for loadUrl
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 (me.loadUrlTimeout == currentLoadUrlTimeout) {
//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);
};
});
me.runOnUiThread(loadError);
}
}