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(); }); }
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 )); }
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() ); }
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 ); }); }
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() ); }
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() ); }
public virtual void Hide() { this.IsShowing = false; Droid.RequestMainThread(() => AndHUD.Shared.Dismiss(Forms.Context)); }