Exemple #1
0
        /// <summary>
        /// Starts teh animation on this spinner.
        /// </summary>
        public void Start()
        {
            lock (this)
            {
                if (IsRunning)
                {
                    return;
                }

                ImageView.Hidden = true;
                ImageView.Alpha  = 1;
                IsRunning        = true;

                if (AutoShowTimer != null)
                {
                    AutoShowTimer.Enabled = false;
                    AutoShowTimer.Dispose();
                }

                AutoShowTimer           = new Timer(Crex.Application.Current.Config.LoadingSpinnerDelay.Value);
                AutoShowTimer.Elapsed  += AutoShowTimer_Elapsed;
                AutoShowTimer.AutoReset = false;
                AutoShowTimer.Enabled   = true;
            }
        }
Exemple #2
0
        /// <summary>
        /// Stops the animation on this spinner.
        /// </summary>
        /// <param name="finished">An action to be performed when the spinner has hidden.</param>
        public void Stop(Action finished = null)
        {
            lock (this)
            {
                if (finished != null)
                {
                    StopActions.Add(finished);
                }

                //
                // If we stopped before showing the spinner then just cancel the timer.
                //
                if (AutoShowTimer != null)
                {
                    AutoShowTimer.Enabled = false;
                    AutoShowTimer.Dispose();
                    AutoShowTimer = null;

                    Stopped();
                }
                else if (ImageView.Layer.AnimationForKey("rotation") != null)
                {
                    //
                    // Otherwise do a nice fadeout animation.
                    //
                    UIView.Animate(Crex.Application.Current.Config.AnimationTime.Value / 1000.0f, () =>
                    {
                        ImageView.Alpha = 0.0f;
                    }, () =>
                    {
                        InvokeOnMainThread(() =>
                        {
                            lock (this)
                            {
                                if (IsRunning)
                                {
                                    Stopped();
                                }
                            }
                        });
                    });
                }
                else
                {
                    Stopped();
                }
            }
        }