mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
Enable onMessage() to return a value.
This commit is contained in:
parent
9f5f4973ae
commit
d683bd3744
@ -140,8 +140,9 @@ public class AudioHandler extends Plugin {
|
|||||||
*
|
*
|
||||||
* @param id The message id
|
* @param id The message id
|
||||||
* @param data The message data
|
* @param data The message data
|
||||||
|
* @return Object to stop propagation or null
|
||||||
*/
|
*/
|
||||||
public void onMessage(String id, Object data) {
|
public Object onMessage(String id, Object data) {
|
||||||
|
|
||||||
// If phone message
|
// If phone message
|
||||||
if (id.equals("telephone")) {
|
if (id.equals("telephone")) {
|
||||||
@ -167,6 +168,7 @@ public class AudioHandler extends Plugin {
|
|||||||
this.pausedForPhone.clear();
|
this.pausedForPhone.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
@ -1050,8 +1050,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
*
|
*
|
||||||
* @param id The message id
|
* @param id The message id
|
||||||
* @param data The message data
|
* @param data The message data
|
||||||
|
* @return Object or null
|
||||||
*/
|
*/
|
||||||
public void onMessage(String id, Object data) {
|
public Object onMessage(String id, Object data) {
|
||||||
LOG.d(TAG, "onMessage(" + id + "," + data + ")");
|
LOG.d(TAG, "onMessage(" + id + "," + data + ")");
|
||||||
if ("splashscreen".equals(id)) {
|
if ("splashscreen".equals(id)) {
|
||||||
if ("hide".equals(data.toString())) {
|
if ("hide".equals(data.toString())) {
|
||||||
@ -1079,6 +1080,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
else if ("exit".equals(id)) {
|
else if ("exit".equals(id)) {
|
||||||
this.endActivity();
|
this.endActivity();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,8 @@ public interface CordovaInterface {
|
|||||||
*
|
*
|
||||||
* @param id The message id
|
* @param id The message id
|
||||||
* @param data The message data
|
* @param data The message data
|
||||||
|
* @return Object or null
|
||||||
*/
|
*/
|
||||||
public void onMessage(String id, Object data);
|
public Object onMessage(String id, Object data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,9 @@ public interface IPlugin {
|
|||||||
*
|
*
|
||||||
* @param id The message id
|
* @param id The message id
|
||||||
* @param data The message data
|
* @param data The message data
|
||||||
|
* @return Object to stop propagation or null
|
||||||
*/
|
*/
|
||||||
public void onMessage(String id, Object data);
|
public Object onMessage(String id, Object data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an activity you launched exits, giving you the requestCode you started it with,
|
* Called when an activity you launched exits, giving you the requestCode you started it with,
|
||||||
|
@ -107,8 +107,10 @@ public abstract class Plugin implements IPlugin {
|
|||||||
*
|
*
|
||||||
* @param id The message id
|
* @param id The message id
|
||||||
* @param data The message data
|
* @param data The message data
|
||||||
|
* @return Object to stop propagation or null
|
||||||
*/
|
*/
|
||||||
public void onMessage(String id, Object data) {
|
public Object onMessage(String id, Object data) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,14 +314,22 @@ public class PluginManager {
|
|||||||
*
|
*
|
||||||
* @param id The message id
|
* @param id The message id
|
||||||
* @param data The message data
|
* @param data The message data
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public void postMessage(String id, Object data) {
|
public Object postMessage(String id, Object data) {
|
||||||
this.ctx.onMessage(id, data);
|
Object obj = this.ctx.onMessage(id, data);
|
||||||
|
if (obj != null) {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
for (PluginEntry entry : this.entries.values()) {
|
for (PluginEntry entry : this.entries.values()) {
|
||||||
if (entry.plugin != null) {
|
if (entry.plugin != null) {
|
||||||
entry.plugin.onMessage(id, data);
|
obj = entry.plugin.onMessage(id, data);
|
||||||
|
if (obj != null) {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user