Commit 6872b219 by Sebastián Katzer

Make sendJavascript synchronized

parent 30ef6817
...@@ -177,14 +177,14 @@ public class LocalNotification extends CordovaPlugin { ...@@ -177,14 +177,14 @@ public class LocalNotification extends CordovaPlugin {
* Properties for each local notification * Properties for each local notification
*/ */
private void schedule (JSONArray notifications) { private void schedule (JSONArray notifications) {
for (int i = 0; i < notifications.length(); i++) { for (int i = 0; i < notifications.length(); i++) {
JSONObject options = notifications.optJSONObject(i); JSONObject options = notifications.optJSONObject(i);
Notification notification = Notification notification =
getNotificationMgr().schedule(options, TriggerReceiver.class); getNotificationMgr().schedule(options, TriggerReceiver.class);
fireEvent("schedule", notification); fireEvent("schedule", notification);
} }
} }
/** /**
...@@ -251,7 +251,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -251,7 +251,7 @@ public class LocalNotification extends CordovaPlugin {
* Clear all triggered notifications without canceling them. * Clear all triggered notifications without canceling them.
*/ */
private void clearAll() { private void clearAll() {
getNotificationMgr().clearAll(); getNotificationMgr().clearAll();
fireEvent("clearall"); fireEvent("clearall");
} }
...@@ -441,14 +441,14 @@ public class LocalNotification extends CordovaPlugin { ...@@ -441,14 +441,14 @@ public class LocalNotification extends CordovaPlugin {
* Optional local notification to pass the id and properties. * Optional local notification to pass the id and properties.
*/ */
static void fireEvent (String event, Notification notification) { static void fireEvent (String event, Notification notification) {
String state = getApplicationState(); String state = getApplicationState();
String params = "\"" + state + "\""; String params = "\"" + state + "\"";
if (notification != null) { if (notification != null) {
params = notification.toString() + "," + params; params = notification.toString() + "," + params;
} }
String js = "cordova.plugins.notification.local.fireEvent(" + String js = "cordova.plugins.notification.local.fireEvent(" +
"\"" + event + "\"," + params + ")"; "\"" + event + "\"," + params + ")";
sendJavascript(js); sendJavascript(js);
...@@ -460,7 +460,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -460,7 +460,7 @@ public class LocalNotification extends CordovaPlugin {
* @param js * @param js
* JS code snippet as string * JS code snippet as string
*/ */
private static void sendJavascript(final String js) { private static synchronized void sendJavascript(final String js) {
if (!deviceready) { if (!deviceready) {
eventQueue.add(js); eventQueue.add(js);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment