Example #1
0
        public override void Prompt(string message, Action <PromptResult> promptResult, string title, string okText, string cancelText, string hint, int lines)
        {
            Droid.RequestMainThread(() => {
                var txt = new EditText(Forms.Context)
                {
                    Hint = hint
                };
                if (lines > 1)
                {
                    txt.SetLines(lines);
                    txt.SetSingleLine(false);
                    txt.ImeOptions = ImeAction.Next;
                }

                new AlertDialog
                .Builder(Forms.Context)
                .SetMessage(message)
                .SetTitle(title)
                .SetView(txt)
                .SetPositiveButton(okText, (o, e) =>
                                   promptResult(new PromptResult {
                    Ok   = true,
                    Text = txt.Text
                })
                                   )
                .SetNegativeButton(cancelText, (o, e) =>
                                   promptResult(new PromptResult {
                    Ok   = false,
                    Text = txt.Text
                })
                                   )
                .Show();
            });
        }
Example #2
0
        protected virtual void Refresh()
        {
            if (!this.IsShowing)
            {
                return;
            }

            var p   = -1;
            var txt = this.Title;

            if (this.IsDeterministic)
            {
                p = this.PercentComplete;
                if (!String.IsNullOrWhiteSpace(txt))
                {
                    txt += "\n";
                }

                txt += p + "%\n";
            }

            if (this.cancelAction != null)
            {
                txt += "\n" + this.cancelText;
            }

            Droid.RequestMainThread(() => AndHUD.Shared.Show(
                                        Forms.Context,
                                        txt,
                                        p,
                                        MaskType.Black,
                                        null,
                                        this.OnCancelClick
                                        ));
        }
Example #3
0
 public override void Confirm(string message, Action <bool> onConfirm, string title, string okText, string cancelText)
 {
     Droid.RequestMainThread(() =>
                             new AlertDialog
                             .Builder(Forms.Context)
                             .SetMessage(message)
                             .SetTitle(title)
                             .SetPositiveButton(okText, (o, e) => onConfirm(true))
                             .SetNegativeButton(cancelText, (o, e) => onConfirm(false))
                             .Show()
                             );
 }
Example #4
0
        public override void Toast(string message, int timeoutSeconds, Action onClick)
        {
            Droid.RequestMainThread(() => {
                onClick = onClick ?? (() => {});

                AndHUD.Shared.ShowToast(
                    Forms.Context,
                    message,
                    MaskType.Clear,
                    TimeSpan.FromSeconds(timeoutSeconds),
                    false,
                    onClick
                    );
            });
        }
Example #5
0
        public override void ActionSheet(ActionSheetOptions options)
        {
            var array = options
                        .Options
                        .Select(x => x.Text)
                        .ToArray();

            Droid.RequestMainThread(() =>
                                    new AlertDialog
                                    .Builder(Forms.Context)
                                    .SetTitle(options.Title)
                                    .SetItems(array, (sender, args) => options.Options[args.Which].Action())
                                    .Show()
                                    );
        }
Example #6
0
 public override void Alert(string message, string title, string okText, Action onOk)
 {
     Droid.RequestMainThread(() =>
                             new AlertDialog
                             .Builder(Forms.Context)
                             .SetMessage(message)
                             .SetTitle(title)
                             .SetPositiveButton(okText, (o, e) => {
         if (onOk != null)
         {
             onOk();
         }
     })
                             .Show()
                             );
 }
Example #7
0
 public virtual void Hide()
 {
     this.IsShowing = false;
     Droid.RequestMainThread(() => AndHUD.Shared.Dismiss(Forms.Context));
 }