mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-30 00:00:04 +08:00
refactored the Command stuff a bit more, added a spashscreen
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
PhoneGap.addPlugin = function(name, obj) {
|
||||
if ( !window.plugins ) {
|
||||
window.plugins = {};
|
||||
}
|
||||
|
||||
if ( !window.plugins[name] ) {
|
||||
window.plugins[name] = obj;
|
||||
}
|
||||
}
|
||||
|
||||
function Cache() {
|
||||
}
|
||||
|
||||
Cache.prototype.getCachedPathForURI = function(uri, success, fail) {
|
||||
PhoneGap.execAsync(success, fail, 'com.phonegap.api.impl.Cache', 'getCachedPathForURI', [uri]);
|
||||
};
|
||||
|
||||
PhoneGap.addPlugin('cache', new Cache());
|
||||
@@ -136,6 +136,19 @@ PhoneGap.addConstructor = function(func) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a plugin object to window.plugins
|
||||
*/
|
||||
PhoneGap.addPlugin = function(name, obj) {
|
||||
if ( !window.plugins ) {
|
||||
window.plugins = {};
|
||||
}
|
||||
|
||||
if ( !window.plugins[name] ) {
|
||||
window.plugins[name] = obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* onDOMContentLoaded channel is fired when the DOM content
|
||||
* of the page has been parsed.
|
||||
@@ -216,23 +229,22 @@ PhoneGap.callbacks = {};
|
||||
* @param {String[]} [args] Zero or more arguments to pass to the method
|
||||
*/
|
||||
PhoneGap.exec = function(clazz, action, args) {
|
||||
CommandManager.exec(clazz, action, callbackId, args.join('__PHONEGAP__'), false);
|
||||
CommandManager.exec(clazz, action, callbackId, JSON.stringify(args), false);
|
||||
};
|
||||
|
||||
PhoneGap.execAsync = function(success, fail, clazz, action, args) {
|
||||
var callbackId = clazz + PhoneGap.callbackId++;
|
||||
PhoneGap.callbacks[callbackId] = {success:success, fail:fail};
|
||||
CommandManager.exec(clazz, action, callbackId, args.join('__PHONEGAP__'), true);
|
||||
return callbackId;
|
||||
return CommandManager.exec(clazz, action, callbackId, JSON.stringify(args), true);
|
||||
};
|
||||
|
||||
PhoneGap.callbackSuccess = function(callbackId, args) {
|
||||
PhoneGap.callbacks[callbackId].success.apply(this, JSON.parse(args));
|
||||
PhoneGap.callbacks[callbackId].success(args);
|
||||
delete PhoneGap.callbacks[callbackId];
|
||||
};
|
||||
|
||||
PhoneGap.callbackFailure = function(callbackId, args) {
|
||||
PhoneGap.callbacks[callbackId].fail.apply(this, JSON.parse(args));
|
||||
PhoneGap.callbackError = function(callbackId, args) {
|
||||
PhoneGap.callbacks[callbackId].fail(args);
|
||||
delete PhoneGap.callbacks[callbackId];
|
||||
};
|
||||
|
||||
@@ -353,7 +365,7 @@ PhoneGap.UUIDcreatePart = function(length) {
|
||||
};
|
||||
|
||||
PhoneGap.close = function(context, func, params) {
|
||||
if (null == params) {
|
||||
if (typeof params === 'undefined') {
|
||||
return function() {
|
||||
return func.apply(context, arguments);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
PhoneGap.addConstructor(function() {
|
||||
if (typeof navigator.splashScreen == "undefined") {
|
||||
navigator.splashScreen = SplashScreen; // SplashScreen object come from native side through addJavaScriptInterface
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user