public void Hide()
 {
     _app.SafeInvokeOnMainThread(() =>
     {
         _hub.Hide(true);
     });
 }
 void insertPeople(int numberOfPeople)
 {
     hud = new MBProgressHUD();
     hud.Show(true);
     NameGenerator.GetPeopleAsync(numberOfPeople).ContinueWith(t => {
         if (t.Exception == null)
         {
             Database.Main.InsertPeople(t.Result).ContinueWith(t2 => {
                 Database.Main.UpdateInstant <Person>();
                 this.BeginInvokeOnMainThread(delegate {
                     if (t2.Exception != null)
                     {
                         Console.WriteLine(t2.Exception);
                         (new UIAlertView("Error", "There was an error inserting people.", null, "Ok")).Show();
                     }
                     hud.Hide(true);
                 });
             });
         }
         else
         {
             Console.WriteLine(t.Exception);
             this.BeginInvokeOnMainThread(delegate {
                 (new UIAlertView("Error", "There was an error generating names.", null, "Ok")).Show();
                 hud.Hide(true);
             });
         }
     });
 }
        public static IProgressDialog Progress(UIApplication app, UIView view, ProgressConfig config)
        {
            app.SafeInvokeOnMainThread(() =>
            {
                _progressHub = MBProgressHUD.ShowHUD(view, true);
                //_progressHub.Mode = MBProgressHUDMode.DeterminateHorizontalBar;
                _progressHub.Mode                = MBProgressHUDMode.Determinate;
                _progressHub.Label.Text          = config.Text;
                _progressHub.Label.LineBreakMode = UILineBreakMode.WordWrap;
                _progressHub.Label.Lines         = int.MaxValue;
                _progressHub.MinShowTime         = 1; // The minimum time (in seconds) that the HUD is shown.

                if (config.MarkType == MarkType.Black)
                {
                    _progressHub.BackgroundView.Style = MBProgressHUDBackgroundStyle.SolidColor;
                    _progressHub.BackgroundView.Color = UIColor.Black.ColorWithAlpha(0.5f);
                }

                if (config.Cancellable)
                {
                    _progressHub.Button.SetTitle(config.CancelText, UIControlState.Normal);
                    _progressHub.Button.AddTarget((_1, _2) =>
                    {
                        config.CancelAction?.Invoke();
                        _progressHub.Hide(true);
                    }, UIControlEvent.TouchUpInside);
                }

                _progressHub.Show(true);
            });

            return(new DefaultProgressDialog(app, config, _progressHub));
        }
Beispiel #4
0
        public void stophud()
        {
            /*
             * if (_hud == null)
             *  return;
             * _hud.StopAnimating ();
             * _hud.RemoveFromSuperview ();
             * _hud.Dispose ();
             * _hud = null;
             */
            if (hud == null)
            {
                return;
            }
            hud.Hide(true);
            hud.RemoveFromSuperview();
            // hud.Dispose ();
            hud = null;

            this.NavigationItem.LeftBarButtonItem = null;

            this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Search, delegate {
                showSearchBox();
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            MBProgressHUD hud = MBProgressHUD.ShowHUD(View, true);

            hud.Label.Text = "Loading...";

            hud.Show(true);
            hud.Hide(true, 3.0f);
        }
Beispiel #6
0
        public static IDisposable Loading(UIApplication app, UIView view, LoadingConfig config)
        {
            app.SafeInvokeOnMainThread(() =>
            {
                _loadingHub                     = MBProgressHUD.ShowHUD(view, true);
                _loadingHub.Mode                = MBProgressHUDMode.Indeterminate;
                _loadingHub.Label.Text          = config.Text;
                _loadingHub.Label.LineBreakMode = UILineBreakMode.WordWrap;
                _loadingHub.Label.Lines         = int.MaxValue;
                _loadingHub.MinShowTime         = 1;         // The minimum time (in seconds) that the HUD is shown.

                if (config.MarkType == MarkType.Black)
                {
                    _loadingHub.BackgroundView.Style = MBProgressHUDBackgroundStyle.SolidColor;
                    _loadingHub.BackgroundView.Color = UIColor.Black.ColorWithAlpha(0.5f);
                }

                if (config.Cancellable)
                {
                    _loadingHub.Button.SetTitle(config.CancelText, UIControlState.Normal);
                    _loadingHub.Button.AddTarget((_1, _2) =>
                    {
                        config.CancelAction?.Invoke();
                        _loadingHub.Hide(true);
                    }, UIControlEvent.TouchUpInside);
                }

                _loadingHub.Show(true);

                if (config.Duration.HasValue)
                {
                    _loadingHub.Hide(true, config.Duration.Value.TotalSeconds);
                }

                //_loadingHub.Hide(true, 3);  // seconds
            });

            return(new DisposableAction(() => _loadingHub.Hide(true)));
        }
Beispiel #7
0
        public static void DoWork(this UIViewController controller, Action work, Action <Exception> error = null, Action final = null)
        {
            MBProgressHUD hud = null;

            hud = new MBProgressHUD(controller.View.Superview)
            {
                Mode = MBProgressHUDMode.Indeterminate, TitleText = "Loading..."
            };
            controller.View.Superview.AddSubview(hud);
            hud.Show(true);

            ThreadPool.QueueUserWorkItem(delegate {
                try
                {
                    Utilities.PushNetworkActive();
                    work();
                }
                catch (Exception e)
                {
                    if (error != null)
                    {
                        error(e);
                    }
                    controller.InvokeOnMainThread(delegate {
                        Utilities.ShowAlert("Error", e.Message);
                    });
                }
                finally
                {
                    Utilities.PopNetworkActive();
                    if (final != null)
                    {
                        controller.InvokeOnMainThread(() => final());
                    }
                }

                if (hud != null)
                {
                    controller.InvokeOnMainThread(delegate {
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                    });
                }
            });
        }
Beispiel #8
0
 public void stophud()
 {
     /*
      * if (_hud == null)
      *  return;
      * _hud.StopAnimating ();
      * _hud.RemoveFromSuperview ();
      * _hud.Dispose ();
      * _hud = null;
      */
     if (hud == null)
     {
         return;
     }
     hud.Hide(true);
     hud.RemoveFromSuperview();
     // hud.Dispose ();
     hud = null;
 }
Beispiel #9
0
        public static void Build(UIApplication app, UIView view, ToastConfig config)
        {
            app.SafeInvokeOnMainThread(() =>
            {
                _hub                     = MBProgressHUD.ShowHUD(view, true);
                _hub.Mode                = MBProgressHUDMode.Text;
                _hub.Label.Text          = config.Message;
                _hub.Label.LineBreakMode = UILineBreakMode.WordWrap;
                _hub.Label.Lines         = int.MaxValue;
                _hub.MinShowTime         = 1; // The minimum time (in seconds) that the HUD is shown.

                _hub.UserInteractionEnabled = false;

                if (config.TextColor.HasValue)
                {
                    _hub.Label.TextColor = config.TextColor.Value.ToNative();
                }

                if (config.BackgroundColor.HasValue)
                {
                    _hub.BezelView.BackgroundColor = config.BackgroundColor.Value.ToNative();
                }

                if (config.Position == ToastPosition.Top)
                {
                    _hub.Offset = new CoreGraphics.CGPoint(0, 0);
                }
                else if (config.Position == ToastPosition.Bottom || config.Position == ToastPosition.Default)
                {
                    _hub.Offset = new CoreGraphics.CGPoint(0, 10000);
                }

                _hub.Show(true);

                _hub.Hide(true, config.Duration.TotalSeconds);
            });
        }
 public void DisposeHUD()
 {
     hud.Hide(true, 3.0f);
     hud = null;
 }
Beispiel #11
0
 public static void Hide()
 {
     _loadingHub?.Hide(true);
 }
 public void Finaliza()
 {
     _progressDialog.Hide(true);
 }
Beispiel #13
0
        /// <summary>
        /// Begins the login process.
        /// </summary>
        private void BeginLogin()
        {
            MBProgressHUD hud = null;
            string        username = null, password = null;
            Account       loggedInAccount = null;

            //The nice hud
            InvokeOnMainThread(delegate {
                username = User.Text;
                password = Password.Text;
                hud      = new MBProgressHUD(View)
                {
                    Mode = MBProgressHUDMode.Indeterminate, TitleText = "Logging In..."
                };
                View.AddSubview(hud);
                hud.Show(true);
            });

            try
            {
                loggedInAccount = Login(username, password);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error = " + e.Message);
            }

            InvokeOnMainThread(delegate
            {
                //Dismiss the hud
                hud.Hide(true);
                hud.RemoveFromSuperview();

                if (loggedInAccount == null)
                {
                    Utilities.ShowAlert("Unable to Authenticate", "Unable to login as user " + username + ". Please check your credentials and try again.");
                    return;
                }

                var account = Application.Accounts.Find(loggedInAccount.Username);

                //Account does not exist! Add it!
                if (account == null)
                {
                    account = loggedInAccount;
                    Application.Accounts.Insert(account);
                }
                //Account already exists. Update the password just incase it changed...
                else
                {
                    account.Password = Password.Text;
                    account.Update();
                    Application.SetUser(account);
                }

                if (LoginComplete != null)
                {
                    LoginComplete(account);
                }
            });
        }