Tweak PluginManager.setPluginEntries() to create startup plugins when called post init()

This commit is contained in:
Andrew Grieve 2015-03-12 16:33:55 -04:00
parent e1828696f7
commit f764448ccc

View File

@ -44,6 +44,7 @@ public class PluginManager {
private final CordovaInterface ctx; private final CordovaInterface ctx;
private final CordovaWebView app; private final CordovaWebView app;
private boolean isInitialized;
public PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, Collection<PluginEntry> pluginEntries) { public PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, Collection<PluginEntry> pluginEntries) {
this.ctx = cordova; this.ctx = cordova;
@ -56,13 +57,18 @@ public class PluginManager {
} }
public void setPluginEntries(Collection<PluginEntry> pluginEntries) { public void setPluginEntries(Collection<PluginEntry> pluginEntries) {
if (isInitialized) {
this.onPause(false); this.onPause(false);
this.onDestroy(); this.onDestroy();
pluginMap.clear(); pluginMap.clear();
entryMap.clear(); entryMap.clear();
}
for (PluginEntry entry : pluginEntries) { for (PluginEntry entry : pluginEntries) {
addService(entry); addService(entry);
} }
if (isInitialized) {
startupPlugins();
}
} }
/** /**
@ -70,6 +76,7 @@ public class PluginManager {
*/ */
public void init() { public void init() {
LOG.d(TAG, "init()"); LOG.d(TAG, "init()");
isInitialized = true;
this.onPause(false); this.onPause(false);
this.onDestroy(); this.onDestroy();
pluginMap.clear(); pluginMap.clear();