mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
CB-8592 Fix NPE if lifecycle events reach CordovaWebView before init()
has been called
This commit is contained in:
parent
023ad9ddf8
commit
62c081dc85
@ -423,14 +423,12 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
||||
}
|
||||
@Override
|
||||
public void handlePause(boolean keepRunning) {
|
||||
LOG.d(TAG, "Handle the pause");
|
||||
// Send pause event to JavaScript
|
||||
sendJavascriptEvent("pause");
|
||||
|
||||
// Forward to plugins
|
||||
if (pluginManager != null) {
|
||||
pluginManager.onPause(keepRunning);
|
||||
if (!isInitialized()) {
|
||||
return;
|
||||
}
|
||||
LOG.d(TAG, "Handle the pause");
|
||||
sendJavascriptEvent("pause");
|
||||
pluginManager.onPause(keepRunning);
|
||||
|
||||
// If app doesn't want to run in background
|
||||
if (!keepRunning) {
|
||||
@ -439,29 +437,27 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void handleResume(boolean keepRunning)
|
||||
{
|
||||
public void handleResume(boolean keepRunning) {
|
||||
if (!isInitialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Resume JavaScript timers. This affects all webviews within the app!
|
||||
engine.setPaused(false);
|
||||
|
||||
sendJavascriptEvent("resume");
|
||||
|
||||
// Forward to plugins
|
||||
if (this.pluginManager != null) {
|
||||
this.pluginManager.onResume(keepRunning);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDestroy()
|
||||
{
|
||||
public void handleDestroy() {
|
||||
if (!isInitialized()) {
|
||||
return;
|
||||
}
|
||||
// Cancel pending timeout timer.
|
||||
loadUrlTimeout++;
|
||||
|
||||
// Forward to plugins
|
||||
if (this.pluginManager != null) {
|
||||
this.pluginManager.onDestroy();
|
||||
}
|
||||
|
||||
// Load blank page so that JavaScript onunload is called
|
||||
this.loadUrl("about:blank");
|
||||
|
Loading…
Reference in New Issue
Block a user