/// <summary> /// Initializes a new instance of the <see cref="ErrorEventArgs"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="buttonText">The button text.</param> /// <param name="action">The action.</param> /// <param name="length">The length.</param> public ErrorEventArgs(string message, string buttonText, Action <View> action, ErrorLength length = ErrorLength.Finite) { this.Message = message; this.ClickAction = action; this.ButtonText = buttonText; this.Length = length; }
/// <summary> /// Reports the error. /// </summary> /// <param name="error">The error.</param> /// <param name="length">The length.</param> public void ReportError(string error, ErrorLength length = ErrorLength.Finite) { if (this.ErrorReported == null) { return; } this.InvokeOnMainThread(() => { this.ErrorReported?.Invoke(this, new ErrorEventArgs(error, length)); }); }
/// <summary> /// Reports the error. /// </summary> /// <param name="error">The error.</param> /// <param name="buttonText">The button text.</param> /// <param name="action">The action.</param> /// <param name="length">The length.</param> public void ReportError(string error, string buttonText, Action <View> action, ErrorLength length = ErrorLength.Finite) { if (this.ErrorReported == null) { return; } this.InvokeOnMainThread(() => { this.ErrorReported?.Invoke(this, new ErrorEventArgs(error, buttonText, action, length)); }); }
/// <summary> /// Initializes a new instance of the <see cref="ErrorEventArgs"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="length">The length.</param> public ErrorEventArgs(string message, ErrorLength length = ErrorLength.Finite) { this.Message = message; this.Length = length; }
/// <summary> /// Shows the error. /// </summary> /// <param name="message">The message.</param> /// <param name="buttonText">The button text.</param> /// <param name="action">The action.</param> /// <param name="length">The length.</param> private void ShowError(string message, string buttonText, Action <View> action, ErrorLength length) { //Depending on API Level show different error notification int apiLevel; Int32.TryParse(Build.VERSION.Sdk, out apiLevel); if (apiLevel >= 23) { this.ShowSnackbar(message, buttonText, action, length); } else { this.ShowDialog(message, buttonText, action); } }
/// <summary> /// Shows the error. /// </summary> /// <param name="message">The message.</param> /// <param name="buttonText">The button text.</param> /// <param name="action">The action.</param> private void ShowSnackbar(string message, string buttonText, Action <View> action, ErrorLength length) { var activity = Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity; var parentLayout = activity.FindViewById(Android.Resource.Id.Content); var snackbarLength = length == ErrorLength.Infinite ? Snackbar.LengthIndefinite : Snackbar.LengthLong; var snackbar = Snackbar.Make(parentLayout, message, snackbarLength); if (snackbarLength == Snackbar.LengthIndefinite && action == null) { snackbar.SetActionTextColor(this._applicationContext.GetColor(Resource.Color.primary_text)); snackbar.SetAction("Dismiss", (v) => { this._currentSnackbar.Dismiss(); }); } if (buttonText != null && action != null) { snackbar.SetActionTextColor(this._applicationContext.GetColor(Resource.Color.secondary_light)); snackbar.SetAction(buttonText, action); } this._currentSnackbar = snackbar; snackbar.Show(); }
/// <summary> /// Reports the error. /// </summary> /// <param name="error">The error.</param> /// <param name="length">The length.</param> public static void ReportError(string error, ErrorLength length = ErrorLength.Finite) { Mvx.Resolve <IErrorReporter>().ReportError(error, length); }
/// <summary> /// Reports the error. /// </summary> /// <param name="error">The error.</param> /// <param name="buttonText">The button text.</param> /// <param name="action">The action.</param> /// <param name="length">The length.</param> public static void ReportError(string error, string buttonText, Action <View> action, ErrorLength length = ErrorLength.Finite) { Mvx.Resolve <IErrorReporter>().ReportError(error, buttonText, action, length); }