Example #1
0
        void ShowImageWorker(UIImage image, string status, TimeSpan duration)
        {
            _progress = -1;
            CancelRingLayerAnimation();

            //this should happen when Dismiss is called, but it happens AFTER the animation ends
            // so sometimes, the cancel button is left on :(
            if (_cancelHud != null)
            {
                _cancelHud.RemoveFromSuperview();
                _cancelHud = null;
            }

            if (!IsVisible)
            {
                Show();
            }

            ImageView.TintColor = HudForegroundColor;
            ImageView.Image     = image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
            ImageView.Hidden    = false;
            StringLabel.Text    = status;
            UpdatePosition();
            SpinnerView.StopAnimating();

            StartDismissTimer(duration);
        }
Example #2
0
        void ShowImageWorker(UIImage image, string status, TimeSpan duration)
        {
            _progress = -1;
            CancelRingLayerAnimation();

            //this should happen when Dismiss is called, but it happens AFTER the animation ends
            // so sometimes, the cancel button is left on :(
            if (CancelHudButton != null)
            {
                CancelHudButton.RemoveFromSuperview();
                CancelHudButton = null;
            }

            if (!IsVisible)
            {
                Show();
            }

            ImageView.Image  = image;
            ImageView.Hidden = false;
            StringLabel.Text = status;
            UpdatePosition();
            SpinnerView.StopAnimating();

            StartDismissTimer(duration);
        }
Example #3
0
        void ShowImageWorker(UIImage image, string status, TimeSpan duration)
        {
            _progress = -1;
            CancelRingLayerAnimation();

            if (!BTProgressHUD.IsVisible)
            {
                BTProgressHUD.Show();
            }

            ImageView.Image  = image;
            ImageView.Hidden = false;
            StringLabel.Text = status;
            UpdatePosition();
            SpinnerView.StopAnimating();

            StartDismissTimer(duration);
        }
Example #4
0
        void UpdateProgress()
        {
            obj.InvokeOnMainThread(delegate
            {
                ImageView.Image  = null;
                ImageView.Hidden = false;
                SpinnerView.StopAnimating();

                if (RingLayer.StrokeEnd > 1)
                {
                    RingLayer.StrokeEnd = 0.0f;
                }
                else
                {
                    RingLayer.StrokeEnd += 0.1f;
                }
            });
        }
Example #5
0
        void ShowProgressWorker(float progress = -1, string status = null, MaskType maskType = MaskType.None, bool textOnly = false,
                                ToastPosition toastPosition = ToastPosition.Center, string cancelCaption = null, Action cancelCallback  = null,
                                double timeoutMs            = 1000, bool showContinuousProgress = false, UIImage displayContinuousImage = null)
        {
            Ring.ResetStyle(IsiOS7ForLookAndFeel, (IsiOS7ForLookAndFeel ? TintColor : UIColor.White));


            if (OverlayView.Superview == null)
            {
                var windows = UIApplication.SharedApplication.Windows;
                Array.Reverse(windows);
                foreach (UIWindow window in windows)
                {
                    if (!window.Hidden && window.IsKeyWindow)
                    {
                        window.AddSubview(OverlayView);
                        break;
                    }
                }
            }


            if (Superview == null)
            {
                OverlayView.AddSubview(this);
            }

            _fadeoutTimer    = null;
            ImageView.Hidden = true;
            _maskType        = maskType;
            _progress        = progress;

            StringLabel.Text = status;

            if (!string.IsNullOrEmpty(cancelCaption))
            {
                CancelHudButton.SetTitle(cancelCaption, UIControlState.Normal);
                CancelHudButton.TouchUpInside += delegate
                {
                    Dismiss();
                    if (cancelCallback != null)
                    {
                        obj.InvokeOnMainThread(() => cancelCallback.DynamicInvoke(null));
                        //cancelCallback.DynamicInvoke(null);
                    }
                };
            }

            UpdatePosition(textOnly);

            if (showContinuousProgress)
            {
                if (displayContinuousImage != null)
                {
                    _displayContinuousImage = true;
                    ImageView.Image         = displayContinuousImage;
                    ImageView.Hidden        = false;
                }

                RingLayer.StrokeEnd = 0.0f;
                StartProgressTimer(TimeSpan.FromMilliseconds(Ring.ProgressUpdateInterval));
            }
            else
            {
                if (progress >= 0)
                {
                    ImageView.Image  = null;
                    ImageView.Hidden = false;

                    SpinnerView.StopAnimating();
                    RingLayer.StrokeEnd = progress;
                }
                else if (textOnly)
                {
                    CancelRingLayerAnimation();
                    SpinnerView.StopAnimating();
                }
                else
                {
                    CancelRingLayerAnimation();
                    SpinnerView.StartAnimating();
                }
            }

            bool cancelButtonVisible = _cancelHud != null && _cancelHud.IsDescendantOfView(_hudView);

            // intercept user interaction with the underlying view
            if (maskType != MaskType.None || cancelButtonVisible)
            {
                OverlayView.UserInteractionEnabled = true;
                //AccessibilityLabel = status;
                //IsAccessibilityElement = true;
            }
            else
            {
                OverlayView.UserInteractionEnabled = false;
                //hudView.IsAccessibilityElement = true;
            }

            OverlayView.Hidden = false;
            this.toastPosition = toastPosition;
            PositionHUD(null);


            if (Alpha != 1)
            {
                RegisterNotifications();
                HudView.Transform.Scale(1.3f, 1.3f);

                if (isClear)
                {
                    Alpha         = 1f;
                    HudView.Alpha = 0f;
                }

                UIView.Animate(0.15f, 0,
                               UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.BeginFromCurrentState,
                               delegate
                {
                    HudView.Transform.Scale((float)1 / 1.3f, (float)1f / 1.3f);
                    if (isClear)
                    {
                        HudView.Alpha = 1f;
                    }
                    else
                    {
                        Alpha = 1f;
                    }
                }, delegate
                {
                    //UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, string);

                    if (textOnly)
                    {
                        StartDismissTimer(TimeSpan.FromMilliseconds(timeoutMs));
                    }
                });

                SetNeedsDisplay();
            }
        }
Example #6
0
        /*
         * void ShowProgressWorker(string cancelCaption, Delegate cancelCallback, float progress = -1, string status = null, MaskType maskType = MaskType.None){
         *      CancelHudButton.SetTitle(cancelCaption, UIControlState.Normal);
         *      CancelHudButton.TouchUpInside += delegate {
         *              BTProgressHUD.Dismiss();
         *              if(cancelCallback != null){
         *                      cancelCallback.DynamicInvoke(null);
         *              }
         *      };
         *      UpdatePosition();
         *      ShowProgressWorker(progress, status, maskType);
         * }
         */
        void ShowProgressWorker(float progress         = -1, string status = null, MaskType maskType = MaskType.None, bool textOnly = false,
                                bool showToastCentered = true, string cancelCaption = null, Action cancelCallback = null, double timeoutMs = 1000)
        {
            if (OverlayView.Superview == null)
            {
                UIApplication.SharedApplication.KeyWindow.AddSubview(OverlayView);
            }

            if (Superview == null)
            {
                OverlayView.AddSubview(this);
            }

            _fadeoutTimer    = null;
            ImageView.Hidden = true;
            _maskType        = maskType;
            _progress        = progress;

            StringLabel.Text = status;

            if (!string.IsNullOrEmpty(cancelCaption))
            {
                CancelHudButton.SetTitle(cancelCaption, UIControlState.Normal);
                CancelHudButton.TouchUpInside += delegate {
                    BTProgressHUD.Dismiss();
                    if (cancelCallback != null)
                    {
                        obj.InvokeOnMainThread(() => cancelCallback.DynamicInvoke(null));
                        //cancelCallback.DynamicInvoke(null);
                    }
                };
            }

            UpdatePosition(textOnly);

            if (progress >= 0)
            {
                ImageView.Image  = null;
                ImageView.Hidden = false;
                SpinnerView.StopAnimating();
                RingLayer.StrokeEnd = progress;
            }
            else if (textOnly)
            {
                CancelRingLayerAnimation();
                SpinnerView.StopAnimating();
            }
            else
            {
                CancelRingLayerAnimation();
                SpinnerView.StartAnimating();
            }

            if (maskType != MaskType.None)
            {
                OverlayView.UserInteractionEnabled = true;
                //AccessibilityLabel = status;
                //IsAccessibilityElement = true;
            }
            else
            {
                OverlayView.UserInteractionEnabled = true;
                //hudView.IsAccessibilityElement = true;
            }

            OverlayView.Hidden     = false;
            this.showToastCentered = showToastCentered;
            PositionHUD(null);


            if (Alpha != 1)
            {
                RegisterNotifications();
                HudView.Transform.Scale(1.3f, 1.3f);

                UIView.Animate(0.15f, 0,
                               UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.BeginFromCurrentState,
                               delegate {
                    HudView.Transform.Scale((float)1 / 1.3f, (float)1f / 1.3f);
                    Alpha = 1;
                }, delegate {
                    //UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, string);

                    if (textOnly)
                    {
                        StartDismissTimer(TimeSpan.FromMilliseconds(timeoutMs));
                    }
                });

                SetNeedsDisplay();
            }
        }