瀏覽代碼

Make sendJavascript synchronized

Sebastián Katzer 10 年之前
父節點
當前提交
6872b2198d
共有 1 個文件被更改,包括 8 次插入8 次删除
  1. 8 8
      src/android/LocalNotification.java

+ 8 - 8
src/android/LocalNotification.java

@@ -177,14 +177,14 @@ public class LocalNotification extends CordovaPlugin {
      *      Properties for each local notification
      */
     private void schedule (JSONArray notifications) {
-    	for (int i = 0; i < notifications.length(); i++) {
-    		JSONObject options = notifications.optJSONObject(i);
+        for (int i = 0; i < notifications.length(); i++) {
+            JSONObject options = notifications.optJSONObject(i);
 
             Notification notification =
                     getNotificationMgr().schedule(options, TriggerReceiver.class);
-            
+
             fireEvent("schedule", notification);
-    	}
+        }
     }
 
     /**
@@ -251,7 +251,7 @@ public class LocalNotification extends CordovaPlugin {
      * Clear all triggered notifications without canceling them.
      */
     private void clearAll() {
-    	getNotificationMgr().clearAll();
+        getNotificationMgr().clearAll();
         fireEvent("clearall");
     }
 
@@ -441,14 +441,14 @@ public class LocalNotification extends CordovaPlugin {
      *      Optional local notification to pass the id and properties.
      */
     static void fireEvent (String event, Notification notification) {
-    	String state = getApplicationState();
+        String state = getApplicationState();
         String params = "\"" + state + "\"";
 
         if (notification != null) {
             params = notification.toString() + "," + params;
         }
 
-    	String js = "cordova.plugins.notification.local.fireEvent(" +
+        String js = "cordova.plugins.notification.local.fireEvent(" +
                 "\"" + event + "\"," + params + ")";
 
         sendJavascript(js);
@@ -460,7 +460,7 @@ public class LocalNotification extends CordovaPlugin {
      * @param js
      *       JS code snippet as string
      */
-    private static void sendJavascript(final String js) {
+    private static synchronized void sendJavascript(final String js) {
 
         if (!deviceready) {
             eventQueue.add(js);