mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
CB-8210 Remove unused onDestroy channel (close #146)
- Channel was defined as internal event and fired by javascript eval() - Rather than change firing of event, simpler to remove as was not used
This commit is contained in:
parent
15e19489e3
commit
5415440829
32
framework/assets/www/cordova.js
vendored
32
framework/assets/www/cordova.js
vendored
@ -1,5 +1,5 @@
|
|||||||
// Platform: android
|
// Platform: android
|
||||||
// 07125ef9d481fab81c2c29eafec253846f05a8ca
|
// ee7b91f28e3780afb44222a2d950ccc1bebd0b87
|
||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
@ -284,10 +284,16 @@ var cordova = {
|
|||||||
if (callback) {
|
if (callback) {
|
||||||
if (isSuccess && status == cordova.callbackStatus.OK) {
|
if (isSuccess && status == cordova.callbackStatus.OK) {
|
||||||
callback.success && callback.success.apply(null, args);
|
callback.success && callback.success.apply(null, args);
|
||||||
} else {
|
} else if (!isSuccess) {
|
||||||
callback.fail && callback.fail.apply(null, args);
|
callback.fail && callback.fail.apply(null, args);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
else
|
||||||
|
Note, this case is intentionally not caught.
|
||||||
|
this can happen if isSuccess is true, but callbackStatus is NO_RESULT
|
||||||
|
which is used to remove a callback from the list without calling the callbacks
|
||||||
|
typically keepCallback is false in this case
|
||||||
|
*/
|
||||||
// Clear callback if not expecting any more results
|
// Clear callback if not expecting any more results
|
||||||
if (!keepCallback) {
|
if (!keepCallback) {
|
||||||
delete cordova.callbacks[callbackId];
|
delete cordova.callbacks[callbackId];
|
||||||
@ -631,7 +637,6 @@ var utils = require('cordova/utils'),
|
|||||||
* onDeviceReady* User event fired to indicate that Cordova is ready
|
* onDeviceReady* User event fired to indicate that Cordova is ready
|
||||||
* onResume User event fired to indicate a start/resume lifecycle event
|
* onResume User event fired to indicate a start/resume lifecycle event
|
||||||
* onPause User event fired to indicate a pause lifecycle event
|
* onPause User event fired to indicate a pause lifecycle event
|
||||||
* onDestroy* Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
|
|
||||||
*
|
*
|
||||||
* The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
|
* The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
|
||||||
* All listeners that subscribe after the event is fired will be executed right away.
|
* All listeners that subscribe after the event is fired will be executed right away.
|
||||||
@ -843,9 +848,6 @@ channel.create('onResume');
|
|||||||
// Event to indicate a pause lifecycle event
|
// Event to indicate a pause lifecycle event
|
||||||
channel.create('onPause');
|
channel.create('onPause');
|
||||||
|
|
||||||
// Event to indicate a destroy lifecycle event
|
|
||||||
channel.createSticky('onDestroy');
|
|
||||||
|
|
||||||
// Channels that must fire before "deviceready" is fired.
|
// Channels that must fire before "deviceready" is fired.
|
||||||
channel.waitForInitialization('onCordovaReady');
|
channel.waitForInitialization('onCordovaReady');
|
||||||
channel.waitForInitialization('onDOMContentLoaded');
|
channel.waitForInitialization('onDOMContentLoaded');
|
||||||
@ -1517,12 +1519,14 @@ module.exports = {
|
|||||||
// TODO: Extract this as a proper plugin.
|
// TODO: Extract this as a proper plugin.
|
||||||
modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
|
modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
|
||||||
|
|
||||||
|
var APP_PLUGIN_NAME = Number(cordova.platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App';
|
||||||
|
|
||||||
// Inject a listener for the backbutton on the document.
|
// Inject a listener for the backbutton on the document.
|
||||||
var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
|
var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
|
||||||
backButtonChannel.onHasSubscribersChange = function() {
|
backButtonChannel.onHasSubscribersChange = function() {
|
||||||
// If we just attached the first handler or detached the last handler,
|
// If we just attached the first handler or detached the last handler,
|
||||||
// let native know we need to override the back button.
|
// let native know we need to override the back button.
|
||||||
exec(null, null, "App", "overrideBackbutton", [this.numHandlers == 1]);
|
exec(null, null, APP_PLUGIN_NAME, "overrideBackbutton", [this.numHandlers == 1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add hardware MENU and SEARCH button handlers
|
// Add hardware MENU and SEARCH button handlers
|
||||||
@ -1533,7 +1537,7 @@ module.exports = {
|
|||||||
// generic button bind used for volumeup/volumedown buttons
|
// generic button bind used for volumeup/volumedown buttons
|
||||||
var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
|
var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
|
||||||
volumeButtonChannel.onHasSubscribersChange = function() {
|
volumeButtonChannel.onHasSubscribersChange = function() {
|
||||||
exec(null, null, "App", "overrideButton", [buttonName, this.numHandlers == 1]);
|
exec(null, null, APP_PLUGIN_NAME, "overrideButton", [buttonName, this.numHandlers == 1]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Inject a listener for the volume buttons on the document.
|
// Inject a listener for the volume buttons on the document.
|
||||||
@ -1543,8 +1547,8 @@ module.exports = {
|
|||||||
// Let native code know we are all done on the JS side.
|
// Let native code know we are all done on the JS side.
|
||||||
// Native code will then un-hide the WebView.
|
// Native code will then un-hide the WebView.
|
||||||
channel.onCordovaReady.subscribe(function() {
|
channel.onCordovaReady.subscribe(function() {
|
||||||
exec(onMessageFromNative, null, 'App', 'messageChannel', []);
|
exec(onMessageFromNative, null, APP_PLUGIN_NAME, 'messageChannel', []);
|
||||||
exec(null, null, "App", "show", []);
|
exec(null, null, APP_PLUGIN_NAME, "show", []);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1568,11 +1572,7 @@ function onMessageFromNative(msg) {
|
|||||||
// Volume events
|
// Volume events
|
||||||
case 'volumedownbutton':
|
case 'volumedownbutton':
|
||||||
case 'volumeupbutton':
|
case 'volumeupbutton':
|
||||||
try {
|
cordova.fireDocumentEvent(action);
|
||||||
cordova.fireDocumentEvent(action);
|
|
||||||
} catch(e) {
|
|
||||||
console.log('exception firing ' + action + ' event from native:' + e);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('Unknown event action ' + action);
|
throw new Error('Unknown event action ' + action);
|
||||||
|
@ -813,9 +813,6 @@ public class CordovaWebView extends WebView {
|
|||||||
// Cancel pending timeout timer.
|
// Cancel pending timeout timer.
|
||||||
loadUrlTimeout++;
|
loadUrlTimeout++;
|
||||||
|
|
||||||
// Send destroy event to JavaScript
|
|
||||||
this.loadUrl("javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");
|
|
||||||
|
|
||||||
// Load blank page so that JavaScript onunload is called
|
// Load blank page so that JavaScript onunload is called
|
||||||
this.loadUrl("about:blank");
|
this.loadUrl("about:blank");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user