Skip to content

Commit

Permalink
#16 hide function for iOS and Android
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Mar 4, 2015
1 parent a7e8218 commit f956c49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ or copy-paste some of the code below to replicate the ActionSheets of the screen
};
```

### hide (iOS and WP8)
### hide

If for some reason you want to hide the actionsheet programmatically, do this:
```js
Expand Down
11 changes: 10 additions & 1 deletion src/android/ActionSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
public class ActionSheet extends CordovaPlugin {

private AlertDialog dialog;

public ActionSheet() {
super();
}
Expand All @@ -46,6 +48,12 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
callbackContext);
// need to return as this call is async.
return true;
} else if ("hide".equals(action)) {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, -1));
}
return true;
}
return false;
}
Expand Down Expand Up @@ -139,7 +147,8 @@ public void onCancel(DialogInterface dialog) {
}
});

builder.create().show();
dialog = builder.create();
dialog.show();
}
};
this.cordova.getActivity().runOnUiThread(runnable);
Expand Down

0 comments on commit f956c49

Please sign in to comment.