Fix formatting and rearrange method order.

This commit is contained in:
Bryce Curtis 2010-11-11 14:00:56 -06:00
parent 4b2398b487
commit e8b85f6cf7

View File

@ -191,6 +191,41 @@ public class DroidGap extends PhonegapActivity {
this.handleActivityParameters();
}
/**
* Bind PhoneGap objects to JavaScript.
*
* @param appView
*/
private void bindBrowser(WebView appView) {
this.callbackServer = new CallbackServer();
this.pluginManager = new PluginManager(appView, this);
this.mKey = new BrowserKey(appView, this);
// This creates the new javascript interfaces for PhoneGap
appView.addJavascriptInterface(this.pluginManager, "PluginManager");
appView.addJavascriptInterface(this.mKey, "BackButton");
appView.addJavascriptInterface(this.callbackServer, "CallbackServer");
appView.addJavascriptInterface(new SplashScreen(this), "SplashScreen");
this.addService("Geolocation", "com.phonegap.GeoBroker");
this.addService("Device", "com.phonegap.Device");
this.addService("Accelerometer", "com.phonegap.AccelListener");
this.addService("Compass", "com.phonegap.CompassListener");
this.addService("Media", "com.phonegap.AudioHandler");
this.addService("Camera", "com.phonegap.CameraLauncher");
this.addService("Contacts", "com.phonegap.ContactManager");
this.addService("Crypto", "com.phonegap.CryptoHandler");
this.addService("File", "com.phonegap.FileUtils");
this.addService("Location", "com.phonegap.GeoBroker"); // Always add Location, even though it is built-in on 2.x devices. Let JavaScript decide which one to use.
this.addService("Network Status", "com.phonegap.NetworkManager");
this.addService("Notification", "com.phonegap.Notification");
this.addService("Storage", "com.phonegap.Storage");
this.addService("Temperature", "com.phonegap.TempListener");
}
/**
* Look at activity parameters and process them.
*/
@ -221,6 +256,39 @@ public class DroidGap extends PhonegapActivity {
}
}
/**
* Load the url into the webview.
*
* @param url
*/
public void loadUrl(final String url) {
System.out.println("loadUrl("+url+")");
this.url = url;
int i = url.lastIndexOf('/');
if (i > 0) {
this.baseUrl = url.substring(0, i);
}
else {
this.baseUrl = this.url;
}
System.out.println("url="+url+" baseUrl="+baseUrl);
// Init web view if not already done
if (this.appView == null) {
this.init();
}
// Initialize callback server
this.callbackServer.init(url);
// Load URL on UI thread
this.runOnUiThread(new Runnable() {
public void run() {
DroidGap.this.appView.loadUrl(url);
}
});
}
@Override
/**
* Called by the system when the device configuration changes while your activity is running.
@ -429,73 +497,6 @@ public class DroidGap extends PhonegapActivity {
this.pluginManager.addService(serviceType, className);
}
/**
* Bind PhoneGap objects to JavaScript.
*
* @param appView
*/
private void bindBrowser(WebView appView) {
this.callbackServer = new CallbackServer();
this.pluginManager = new PluginManager(appView, this);
this.mKey = new BrowserKey(appView, this);
// This creates the new javascript interfaces for PhoneGap
appView.addJavascriptInterface(this.pluginManager, "PluginManager");
appView.addJavascriptInterface(this.mKey, "BackButton");
appView.addJavascriptInterface(this.callbackServer, "CallbackServer");
appView.addJavascriptInterface(new SplashScreen(this), "SplashScreen");
this.addService("Geolocation", "com.phonegap.GeoBroker");
this.addService("Device", "com.phonegap.Device");
this.addService("Accelerometer", "com.phonegap.AccelListener");
this.addService("Compass", "com.phonegap.CompassListener");
this.addService("Media", "com.phonegap.AudioHandler");
this.addService("Camera", "com.phonegap.CameraLauncher");
this.addService("Contacts", "com.phonegap.ContactManager");
this.addService("Crypto", "com.phonegap.CryptoHandler");
this.addService("File", "com.phonegap.FileUtils");
this.addService("Location", "com.phonegap.GeoBroker"); // Always add Location, even though it is built-in on 2.x devices. Let JavaScript decide which one to use.
this.addService("Network Status", "com.phonegap.NetworkManager");
this.addService("Notification", "com.phonegap.Notification");
this.addService("Storage", "com.phonegap.Storage");
this.addService("Temperature", "com.phonegap.TempListener");
}
/**
* Load the url into the webview.
*
* @param url
*/
public void loadUrl(final String url) {
this.url = url;
int i = url.lastIndexOf('/');
if (i > 0) {
this.baseUrl = url.substring(0, i);
}
else {
this.baseUrl = this.url;
}
// Init web view if not already done
if (this.appView == null) {
this.init();
}
// Initialize callback server
this.callbackServer.init(url);
// Load URL on UI thread
this.runOnUiThread(new Runnable() {
public void run() {
DroidGap.this.appView.loadUrl(url);
}
});
}
/**
* Send JavaScript statement back to JavaScript.
* (This is a convenience method)