/// <summary> /// We have entered the stopped state. Run actions and update flags. /// </summary> private void Stopped() { StopSpinning(); StopActions.ForEach(a => a()); StopActions.Clear(); ImageView.Hidden = true; IsRunning = false; }
/// <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(); } } }