Commit f2a24d7f by Sebastián Katzer

Merge pull request #80 from dpogue/threaded

Android: Avoid blocking the main thread.
parents 9044fb23 4885cdf8
...@@ -68,15 +68,14 @@ public class LocalNotification extends CordovaPlugin { ...@@ -68,15 +68,14 @@ public class LocalNotification extends CordovaPlugin {
} }
@Override @Override
public boolean execute (String action, JSONArray args, CallbackContext callbackContext) throws JSONException { public boolean execute (String action, final JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equalsIgnoreCase("add")) { if (action.equalsIgnoreCase("add")) {
cordova.getThreadPool().execute( new Runnable() {
public void run() {
JSONObject arguments = args.optJSONObject(0); JSONObject arguments = args.optJSONObject(0);
final Options options = new Options(context).parse(arguments); Options options = new Options(context).parse(arguments);
persist(options.getId(), args); persist(options.getId(), args);
cordova.getThreadPool().execute( new Runnable() {
public void run() {
add(options); add(options);
} }
}); });
...@@ -85,17 +84,25 @@ public class LocalNotification extends CordovaPlugin { ...@@ -85,17 +84,25 @@ public class LocalNotification extends CordovaPlugin {
} }
if (action.equalsIgnoreCase("cancel")) { if (action.equalsIgnoreCase("cancel")) {
cordova.getThreadPool().execute( new Runnable() {
public void run() {
String id = args.optString(0); String id = args.optString(0);
cancel(id); cancel(id);
unpersist(id); unpersist(id);
}
});
return true; return true;
} }
if (action.equalsIgnoreCase("cancelAll")) { if (action.equalsIgnoreCase("cancelAll")) {
cordova.getThreadPool().execute( new Runnable() {
public void run() {
cancelAll(); cancelAll();
unpersistAll(); unpersistAll();
}
});
return true; return true;
} }
......
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