mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
Change API to postMessage() to call a plugin's onMessage() method.
This commit is contained in:
parent
63ae953432
commit
798cb3e347
@ -136,15 +136,15 @@ public class Device extends Plugin {
|
||||
String extraData = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
|
||||
if (extraData.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
|
||||
LOG.i(TAG, "Telephone RINGING");
|
||||
myctx.onMessage("telephone", "ringing");
|
||||
myctx.postMessage("telephone", "ringing");
|
||||
}
|
||||
else if (extraData.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
|
||||
LOG.i(TAG, "Telephone OFFHOOK");
|
||||
myctx.onMessage("telephone", "offhook");
|
||||
myctx.postMessage("telephone", "offhook");
|
||||
}
|
||||
else if (extraData.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
|
||||
LOG.i(TAG, "Telephone IDLE");
|
||||
myctx.onMessage("telephone", "idle");
|
||||
myctx.postMessage("telephone", "idle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -840,10 +840,10 @@ public class DroidGap extends PhonegapActivity {
|
||||
* @param id The message id
|
||||
* @param data The message data
|
||||
*/
|
||||
public void onMessage(String id, Object data) {
|
||||
public void postMessage(String id, Object data) {
|
||||
|
||||
// Forward to plugins
|
||||
this.pluginManager.onMessage(id, data);
|
||||
this.pluginManager.postMessage(id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1835,21 +1835,21 @@ public class DroidGap extends PhonegapActivity {
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
{
|
||||
this.onMessage("onCreateOptionsMenu", menu);
|
||||
this.postMessage("onCreateOptionsMenu", menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu)
|
||||
{
|
||||
this.onMessage("onPrepareOptionsMenu", menu);
|
||||
this.postMessage("onPrepareOptionsMenu", menu);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
this.onMessage("onOptionsItemSelected", item);
|
||||
this.postMessage("onOptionsItemSelected", item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ public class NetworkManager extends Plugin {
|
||||
this.success(result, this.connectionCallbackId);
|
||||
|
||||
// Send to all plugins
|
||||
this.ctx.onMessage("networkconnection", type);
|
||||
this.ctx.postMessage("networkconnection", type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,5 +76,5 @@ public abstract class PhonegapActivity extends Activity {
|
||||
* @param id The message id
|
||||
* @param data The message data
|
||||
*/
|
||||
abstract public void onMessage(String id, Object data);
|
||||
abstract public void postMessage(String id, Object data);
|
||||
}
|
||||
|
@ -287,13 +287,9 @@ public final class PluginManager {
|
||||
* @param multitasking Flag indicating if multitasking is turned on for app
|
||||
*/
|
||||
public void onPause(boolean multitasking) {
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
plugin.onPause(multitasking);
|
||||
}
|
||||
for (IPlugin plugin : this.plugins.values()) {
|
||||
plugin.onPause(multitasking);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,26 +298,18 @@ public final class PluginManager {
|
||||
* @param multitasking Flag indicating if multitasking is turned on for app
|
||||
*/
|
||||
public void onResume(boolean multitasking) {
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
plugin.onResume(multitasking);
|
||||
}
|
||||
for (IPlugin plugin : this.plugins.values()) {
|
||||
plugin.onResume(multitasking);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The final call you receive before your activity is destroyed.
|
||||
*/
|
||||
public void onDestroy() {
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
plugin.onDestroy();
|
||||
}
|
||||
for (IPlugin plugin : this.plugins.values()) {
|
||||
plugin.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,12 +318,8 @@ public final class PluginManager {
|
||||
* @param id The message id
|
||||
* @param data The message data
|
||||
*/
|
||||
public void onMessage(String id, Object data) {
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
public void postMessage(String id, Object data) {
|
||||
for (IPlugin plugin : this.plugins.values()) {
|
||||
plugin.onMessage(id, data);
|
||||
}
|
||||
}
|
||||
@ -344,13 +328,9 @@ public final class PluginManager {
|
||||
* Called when the activity receives a new intent.
|
||||
*/
|
||||
public void onNewIntent(Intent intent) {
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
plugin.onNewIntent(intent);
|
||||
}
|
||||
for (IPlugin plugin : this.plugins.values()) {
|
||||
plugin.onNewIntent(intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user