Commit 40461306 by Sebastián Katzer

`onadd` was called each time after a repeating message was triggered

parent 7c642208
...@@ -46,11 +46,14 @@ or to use this exact version: ...@@ -46,11 +46,14 @@ or to use this exact version:
More informations can be found [here](https://build.phonegap.com/plugins/413). More informations can be found [here](https://build.phonegap.com/plugins/413).
## Release Notes ## Release Notes
#### Version 0.7.2 (not yet released)
- [enhancement:] Avoid blocking the main thread (on Android) **(dpogue)**.
- [bugfix:] `onadd` was called each time after a repeating message was triggered (Android)
#### Version 0.7.1 (31.01.2014) #### Version 0.7.1 (31.01.2014)
- [bugfix:] `ongoing` attribute was ignored. - [bugfix:] `ongoing` attribute was ignored.
- [bugfix:] `oncancel` wasnt fired if `autoCancel` was set to true. - [bugfix:] `oncancel` wasnt fired if `autoCancel` was set to true.
- [bugfix:] App throwed an error at restart if a callback was registered. - [bugfix:] App throwed an error at restart if a callback was registered.
- [enhancement:] Avoid blocking the main thread (on Android) **(dpogue)**.
#### Version 0.7.0 (22.01.2014) #### Version 0.7.0 (22.01.2014)
**Note:** The new way of callback registration will be not compatible with previous versions! See #62 **Note:** The new way of callback registration will be not compatible with previous versions! See #62
......
...@@ -72,11 +72,11 @@ public class LocalNotification extends CordovaPlugin { ...@@ -72,11 +72,11 @@ public class LocalNotification extends CordovaPlugin {
if (action.equalsIgnoreCase("add")) { if (action.equalsIgnoreCase("add")) {
cordova.getThreadPool().execute( new Runnable() { cordova.getThreadPool().execute( new Runnable() {
public void run() { public void run() {
JSONObject arguments = args.optJSONObject(0); JSONObject arguments = args.optJSONObject(0);
Options options = new Options(context).parse(arguments); Options options = new Options(context).parse(arguments);
persist(options.getId(), args); persist(options.getId(), args);
add(options); add(options, true);
} }
}); });
...@@ -116,8 +116,10 @@ public class LocalNotification extends CordovaPlugin { ...@@ -116,8 +116,10 @@ public class LocalNotification extends CordovaPlugin {
* *
* @param options * @param options
* The options that can be specified per alarm. * The options that can be specified per alarm.
* @param doFireEvent
* If the onadd callback shall be called.
*/ */
public static void add (Options options) { public static void add (Options options, boolean doFireEvent) {
long triggerTime = options.getDate(); long triggerTime = options.getDate();
Intent intent = new Intent(context, Receiver.class) Intent intent = new Intent(context, Receiver.class)
...@@ -127,7 +129,9 @@ public class LocalNotification extends CordovaPlugin { ...@@ -127,7 +129,9 @@ public class LocalNotification extends CordovaPlugin {
AlarmManager am = getAlarmManager(); AlarmManager am = getAlarmManager();
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
fireEvent("add", options.getId(), options.getJSON()); if (doFireEvent) {
fireEvent("add", options.getId(), options.getJSON());
}
am.set(AlarmManager.RTC_WAKEUP, triggerTime, pi); am.set(AlarmManager.RTC_WAKEUP, triggerTime, pi);
} }
...@@ -299,4 +303,4 @@ public class LocalNotification extends CordovaPlugin { ...@@ -299,4 +303,4 @@ public class LocalNotification extends CordovaPlugin {
callbackQueue.clear(); callbackQueue.clear();
} }
} }
\ No newline at end of file
...@@ -79,7 +79,7 @@ public class Receiver extends BroadcastReceiver { ...@@ -79,7 +79,7 @@ public class Receiver extends BroadcastReceiver {
} else if (isFirstAlarmInFuture()) { } else if (isFirstAlarmInFuture()) {
return; return;
} else { } else {
LocalNotification.add(options.moveDate()); LocalNotification.add(options.moveDate(), false);
} }
Builder notification = buildNotification(); Builder notification = buildNotification();
......
...@@ -59,7 +59,7 @@ public class Restore extends BroadcastReceiver { ...@@ -59,7 +59,7 @@ public class Restore extends BroadcastReceiver {
/* /*
* If the trigger date was in the past, the notification will be displayed immediately. * If the trigger date was in the past, the notification will be displayed immediately.
*/ */
LocalNotification.add(options); LocalNotification.add(options, false);
} catch (JSONException e) {} } catch (JSONException e) {}
} }
......
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