Add delay so splash screen can be shown for a specific amount of time.

This commit is contained in:
Bryce Curtis 2010-11-11 21:56:56 -06:00
parent 28ff6e1150
commit 4f1bc1401f

View File

@ -29,7 +29,6 @@ import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.webkit.GeolocationPermissions.Callback; import android.webkit.GeolocationPermissions.Callback;
import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebSettings.LayoutAlgorithm;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.phonegap.api.Plugin; import com.phonegap.api.Plugin;
import com.phonegap.api.PluginManager; import com.phonegap.api.PluginManager;
@ -199,7 +198,6 @@ public class DroidGap extends PhonegapActivity {
appView.addJavascriptInterface(this.mKey, "BackButton"); appView.addJavascriptInterface(this.mKey, "BackButton");
appView.addJavascriptInterface(this.callbackServer, "CallbackServer"); appView.addJavascriptInterface(this.callbackServer, "CallbackServer");
appView.addJavascriptInterface(new SplashScreen(this), "SplashScreen");
this.addService("Geolocation", "com.phonegap.GeoBroker"); this.addService("Geolocation", "com.phonegap.GeoBroker");
this.addService("Device", "com.phonegap.Device"); this.addService("Device", "com.phonegap.Device");
@ -225,13 +223,8 @@ public class DroidGap extends PhonegapActivity {
// If spashscreen // If spashscreen
this.splashscreen = this.getProperty("splashscreen", 0); this.splashscreen = this.getProperty("splashscreen", 0);
if (this.splashscreen != 0) { if (this.splashscreen != 0) {
appView.setBackgroundColor(0); appView.setBackgroundColor(0);
appView.setBackgroundResource(splashscreen); appView.setBackgroundResource(splashscreen);
}
// If loadingDialog, then show the App loading dialog
if (this.getProperty("loadingDialog", true)) {
this.pluginManager.exec("Notification", "activityStart", null, "[\"Wait\",\"Loading Application...\"]", false);
} }
// If hideLoadingDialogOnPageLoad // If hideLoadingDialogOnPageLoad
@ -273,14 +266,46 @@ public class DroidGap extends PhonegapActivity {
// Initialize callback server // Initialize callback server
this.callbackServer.init(url); this.callbackServer.init(url);
// If loadingDialog, then show the App loading dialog
if (this.getProperty("loadingDialog", true)) {
this.pluginManager.exec("Notification", "activityStart", null, "[\"Wait\",\"Loading Application...\"]", false);
}
// Load URL on UI thread // Load URL on UI thread
final DroidGap me = this;
this.runOnUiThread(new Runnable() { this.runOnUiThread(new Runnable() {
public void run() { public void run() {
DroidGap.this.appView.loadUrl(url); me.appView.loadUrl(url);
} }
}); });
} }
/**
* Load the url into the webview after waiting for period of time.
* This is used to display the splashscreen for certain amount of time.
*
* @param url
* @param time The number of ms to wait before loading webview
*/
public void loadUrl(final String url, final int time) {
System.out.println("loadUrl("+url+","+time+")");
final DroidGap me = this;
Runnable runnable = new Runnable() {
public void run() {
try {
synchronized(this) {
this.wait(time);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
me.loadUrl(url);
}
};
Thread thread = new Thread(runnable);
thread.start();
}
@Override @Override
/** /**
* Called by the system when the device configuration changes while your activity is running. * Called by the system when the device configuration changes while your activity is running.