コード例 #1
0
        /// <summary>
        /// Show dialog with title, message and positive button.
        /// </summary>
        /// <param name="title">dialog title</param>
        /// <param name="message">dialog message</param>
        /// <param name="buttonText">text for positive button</param>
        public static async Task ShowAsyncAlertWithTitleMessageAndOk(string title, string message,
                                                                     string buttonText)
        {
            UniroidDialog.ShowOk(title, message, buttonText);

            bool isDialogClosed = false;

            OnClickEvent += WaitForClickEvent;

            while (!isDialogClosed)
            {
                await Task.Delay(TimeSpan.FromMilliseconds(50));
            }


            void WaitForClickEvent(int clickResult)
            {
                OnClickEvent  -= WaitForClickEvent;
                isDialogClosed = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Show dialog with title and list of buttons.
        /// </summary>
        /// <param name="title">dialog title</param>
        /// <param name="buttonsText">texts for buttons</param>
        /// <returns>the text of touched button</returns>
        public static async Task <string> ShowAsyncAlertWithTitleAndListButtons(string title, string[] buttonsText)
        {
            UniroidDialog.ShowListButtons(title, buttonsText);

            int?result = null;

            OnClickEvent += WaitForClickEvent;

            while (!result.HasValue)
            {
                await Task.Delay(TimeSpan.FromMilliseconds(50));
            }

            return(buttonsText[result.Value]);


            void WaitForClickEvent(int clickResult)
            {
                OnClickEvent -= WaitForClickEvent;
                result        = clickResult;
            }
        }
コード例 #3
0
        /// <summary>
        /// Show dialog with title, message, positive button and negative button.
        /// </summary>
        /// <param name="title">dialog title</param>
        /// <param name="message">dialog message</param>
        /// <param name="positiveButtonsText">text for positive button</param>
        /// <param name="negativeButtonText">text for negative button</param>
        /// <returns>true:touched positive / false:touched negative</returns>
        public static async Task <bool> ShowAsyncAlertWithTitleMessageAndOkCancel(string title, string message,
                                                                                  string positiveButtonsText, string negativeButtonText)
        {
            UniroidDialog.ShowOkCancel(title, message, positiveButtonsText, negativeButtonText);

            int?result = null;

            OnClickEvent += WaitForClickEvent;

            while (!result.HasValue)
            {
                await Task.Delay(TimeSpan.FromMilliseconds(50));
            }

            return(result.Value == TOUCHED_POSITIVE);


            void WaitForClickEvent(int clickResult)
            {
                OnClickEvent -= WaitForClickEvent;
                result        = clickResult;
            }
        }
コード例 #4
0
 /// <summary>
 /// This method will be invoked when a button in the dialog is clicked.
 /// </summary>
 /// <remarks>https://developer.android.com/reference/android/content/DialogInterface.OnClickListener</remarks>
 /// <param name="dialog"></param>
 /// <param name="value">DialogInterface.BUTTON_NEGATIVE https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE </param>
 public void onClick(AndroidJavaObject dialog, int value)
 {
     //ボタンが押された時に呼び出される
     Debug.Log($"ButtonClickListener onClick. value={value}");
     UniroidDialog.OnClickEvent(TOUCHED_NEGATIVE);
 }
コード例 #5
0
 /// <summary>
 /// show android native dialog with title, message, positive button and negative button.
 /// </summary>
 /// <param name="title">dialog title</param>
 /// <param name="message">dialog message</param>
 /// <param name="buttonsText">[0]: text for positive button / [1]: text for negative button</param>
 /// <returns>true:touched positive / false:touched negative</returns>
 public static async Task <bool> ShowAsyncAlertWithTitleMessageAndOkCancel(string title, string message,
                                                                           string[] buttonsText)
 {
     return(await UniroidDialog.ShowAsyncAlertWithTitleMessageAndOkCancel(title, message, buttonsText[0],
                                                                          buttonsText[1]));
 }