示例#1
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();
            });
        }
示例#2
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();
                    });
                }
            });
        }
示例#3
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;
 }
示例#4
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);
                }
            });
        }