forked from github/Toast-PhoneGap-Plugin
Changes to send same parameters to success callback when the toast hides automatically - no tap
This commit is contained in:
parent
4fb9932c9b
commit
9b9365d9da
@ -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)) {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user