mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 12:03:28 +08:00
CB-8389 Allow plugins to handle exit and onReceivedError messages before CordovaInterface
Also switches to LinkedHashMap for plugins so that activity can insert a plugin and have it be the first one to receive messages
This commit is contained in:
parent
bf327f3916
commit
26ee1c4547
@ -19,14 +19,8 @@
|
|||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import org.apache.cordova.CordovaWebView;
|
|
||||||
import org.apache.cordova.CallbackContext;
|
|
||||||
import org.apache.cordova.CordovaInterface;
|
|
||||||
import org.apache.cordova.CordovaPlugin;
|
|
||||||
import org.apache.cordova.PluginEntry;
|
|
||||||
import org.apache.cordova.PluginResult;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -45,8 +39,8 @@ public class PluginManager {
|
|||||||
private static final int SLOW_EXEC_WARNING_THRESHOLD = Debug.isDebuggerConnected() ? 60 : 16;
|
private static final int SLOW_EXEC_WARNING_THRESHOLD = Debug.isDebuggerConnected() ? 60 : 16;
|
||||||
|
|
||||||
// List of service entries
|
// List of service entries
|
||||||
private final HashMap<String, CordovaPlugin> pluginMap = new HashMap<String, CordovaPlugin>();
|
private final LinkedHashMap<String, CordovaPlugin> pluginMap = new LinkedHashMap<String, CordovaPlugin>();
|
||||||
private final HashMap<String, PluginEntry> entryMap = new HashMap<String, PluginEntry>();
|
private final LinkedHashMap<String, PluginEntry> entryMap = new LinkedHashMap<String, PluginEntry>();
|
||||||
|
|
||||||
private final CordovaInterface ctx;
|
private final CordovaInterface ctx;
|
||||||
private final CordovaWebView app;
|
private final CordovaWebView app;
|
||||||
@ -281,19 +275,15 @@ public class PluginManager {
|
|||||||
* @return Object to stop propagation or null
|
* @return Object to stop propagation or null
|
||||||
*/
|
*/
|
||||||
public Object postMessage(String id, Object data) {
|
public Object postMessage(String id, Object data) {
|
||||||
Object obj = this.ctx.onMessage(id, data);
|
|
||||||
if (obj != null) {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
for (CordovaPlugin plugin : this.pluginMap.values()) {
|
for (CordovaPlugin plugin : this.pluginMap.values()) {
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
obj = plugin.onMessage(id, data);
|
Object obj = plugin.onMessage(id, data);
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return ctx.onMessage(id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user