/// <summary> /// Displays information to the user. The dialog box will have only /// one button. /// </summary> /// <param name="message">The message to be shown to the user.</param> /// <param name="title">The title of the dialog box. This may be null.</param> /// <param name="buttonConfirmText">The text shown in the "confirm" button /// in the dialog box. If left null, the text "OK" will be used.</param> /// <param name="buttonCancelText">The text shown in the "cancel" button /// in the dialog box. If left null, the text "Cancel" will be used.</param> /// <param name="afterHideCallback">A callback that should be executed after /// the dialog box is closed by the user. The callback method will get a boolean /// parameter indicating if the "confirm" button (true) or the "cancel" button /// (false) was pressed by the user.</param> /// <returns>A Task allowing this async method to be awaited. The task will return /// true or false depending on the dialog result.</returns> /// <remarks>Displaying dialogs in Android is synchronous. As such, /// this method will be executed synchronously even though it can be awaited /// for cross-platform compatibility purposes.</remarks> public Task <bool> ShowMessage( string message, string title, string buttonConfirmText, string buttonCancelText, Action <bool> afterHideCallback) { Action <bool> callback = r => { if (afterHideCallback != null) { afterHideCallback(r); afterHideCallback = null; } }; AlertDialogInfo info = CreateDialog( message, title, buttonConfirmText, buttonCancelText ?? "Cancel", callback); info.Dialog.Show(); return(info.Tcs.Task); }
/// <summary> /// Displays information to the user. The dialog box will have only /// one button with the text "OK". /// </summary> /// <param name="message">The message to be shown to the user.</param> /// <param name="title">The title of the dialog box. This may be null.</param> /// <returns>A Task allowing this async method to be awaited.</returns> /// <remarks>Displaying dialogs in Android is synchronous. As such, /// this method will be executed synchronously even though it can be awaited /// for cross-platform compatibility purposes.</remarks> public Task ShowMessage(string message, string title) { AlertDialogInfo info = CreateDialog( message, title); info.Dialog.Show(); return(info.Tcs.Task); }
/// <summary> /// Displays information about an error. /// </summary> /// <param name="error">The exception of which the message must be shown to the user.</param> /// <param name="title">The title of the dialog box. This may be null.</param> /// <param name="buttonText">The text shown in the only button /// in the dialog box. If left null, the text "OK" will be used.</param> /// <param name="afterHideCallback">A callback that should be executed after /// the dialog box is closed by the user.</param> /// <returns>A Task allowing this async method to be awaited.</returns> /// <remarks>Displaying dialogs in Android is synchronous. As such, /// this method will be executed synchronously even though it can be awaited /// for cross-platform compatibility purposes.</remarks> public Task ShowError(Exception error, string title, string buttonText, Action afterHideCallback) { Action <bool> callback = r => { if (afterHideCallback != null) { afterHideCallback(); afterHideCallback = null; } }; AlertDialogInfo info = CreateDialog( error.Message, title, buttonText, null, callback); info.Dialog.Show(); return(info.Tcs.Task); }