Changes to send same parameters to success callback when the toast hides automatically - no tap

This commit is contained in:
ElNinjaGaiden 2016-03-04 09:24:55 -06:00
parent 4fb9932c9b
commit 9b9365d9da
2 changed files with 21 additions and 1 deletions

View File

@ -52,7 +52,18 @@ public class Toast extends CordovaPlugin {
mostRecentToast.cancel();
getViewGroup().setOnTouchListener(null);
}
callbackContext.success();
final JSONObject hideOptions = args.getJSONObject(0);
final String hidemessage = hideOptions.getString("message");
final JSONObject hideData = hideOptions.has("data") ? hideOptions.getJSONObject("data") : null;
final JSONObject json = new JSONObject();
try {
json.put("event", "hide");
json.put("message", hidemessage);
json.put("data", hideData);
} catch (JSONException e) {
e.printStackTrace();
}
callbackContext.success(json);
return true;
} else if (ACTION_SHOW_EVENT.equals(action)) {

View File

@ -185,6 +185,15 @@ static id styling;
- (void)toastTimerDidFinish:(NSTimer *)timer {
[self hideToast:(UIView *)timer.userInfo];
// also send an event back to JS
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:msg, @"message", @"hide", @"event", nil];
if (data != nil) {
[dict setObject:data forKey:@"data"];
}
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
[commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
}
- (void)handleToastTapped:(UITapGestureRecognizer *)recognizer {