Exemplo n.º 1
0
        public static AnimatorSet CreateMovementAnimation(View view, float canvasX, float canvasY, float offsetStartX, float offsetStartY, float offsetEndX, float offsetEndY, EventHandler animationEndHandler)
        {
            view.Alpha = INVISIBLE;

            var alphaIn = ObjectAnimator.OfFloat(view, ALPHA, INVISIBLE, VISIBLE).SetDuration(500);

            var setUpX = ObjectAnimator.OfFloat(view, COORD_X, canvasX + offsetStartX).SetDuration(INSTANT);
            var setUpY = ObjectAnimator.OfFloat(view, COORD_Y, canvasY + offsetStartY).SetDuration(INSTANT);

            var moveX = ObjectAnimator.OfFloat(view, COORD_X, canvasX + offsetEndX).SetDuration(1000);
            var moveY = ObjectAnimator.OfFloat(view, COORD_Y, canvasY + offsetEndY).SetDuration(1000);
            moveX.StartDelay = 1000;
            moveY.StartDelay = 1000;

            var alphaOut = ObjectAnimator.OfFloat(view, ALPHA, INVISIBLE).SetDuration(500);
            alphaOut.StartDelay = 2500;

            var aset = new AnimatorSet();
            aset.Play(setUpX).With(setUpY).Before(alphaIn).Before(moveX).With(moveY).Before(alphaOut);

            var handler = new Handler();
            handler.PostDelayed(() =>
            {
                animationEndHandler(view, EventArgs.Empty);
            }, 3000);

            return aset;
        }
Exemplo n.º 2
0
		void DoAnimation2 (bool really, Action changePic)
		{
			if (!really)
				changePic ();
			else {
				var fdIn = ObjectAnimator.OfFloat (this, "alpha", new float[] { 0, 1 });
				var fdOut = ObjectAnimator.OfFloat (this, "alpha", new float[] { 1, 0 });
				fdOut.AnimationEnd += (sender, e) => changePic ();

				var animator = new AnimatorSet ();
				animator.SetInterpolator (new LinearInterpolator ());
				//animator.PlaySequentially (fdOut, fdIn);
				animator.Play (fdOut);
				animator.Play (fdIn).After (fdOut).After (2000);
				animator.Start ();
			}
		}
Exemplo n.º 3
0
        private void SetActiveSlice (int value, bool animate = false, bool updateStats = true)
        {
            if (slices.Count == 1 || value >= slices.Count) {
                value = -1;
            }

            if (value == activeSlice) {
                return;
            }

            activeSlice = value;
            Clickable = activeSlice >= 0;

            if (updateStats) {
                UpdateStats ();
            }

            if (animate) {
                // Finish currently running animations
                if (currentSelectAnimation != null) {
                    currentSelectAnimation.Cancel ();
                }

                // Animate changes
                var scene = new AnimatorSet ();
                for (var i = 0; i < slices.Count; i++) {
                    var slice = slices [i];

                    if (i == activeSlice) {
                        // Slice activating animations
                        if (slice.Alpha < 1) {
                            var fadeIn = ObjectAnimator.OfFloat (slice, "alpha", slice.Alpha, 1).SetDuration (500);
                            scene.Play (fadeIn);
                        }
                        if (slice.ScaleX != ActiveSliceScale) {
                            var scaleXUp = ObjectAnimator.OfFloat (slice, "scaleX", slice.ScaleX, ActiveSliceScale).SetDuration (500);
                            scene.Play (scaleXUp);
                        }
                        if (slice.ScaleY != ActiveSliceScale) {
                            var scaleYUp = ObjectAnimator.OfFloat (slice, "scaleY", slice.ScaleY, ActiveSliceScale).SetDuration (500);
                            scene.Play (scaleYUp);
                        }
                    } else if (activeSlice >= 0) {
                        // Slice deactivating animations
                        if (slice.Alpha > 0.5f) {
                            var fadeOut = ObjectAnimator.OfFloat (slice, "alpha", slice.Alpha, 0.5f).SetDuration (300);
                            scene.Play (fadeOut);
                        }
                        if (slice.ScaleX != NonActiveSliceScale) {
                            var scaleXDown = ObjectAnimator.OfFloat (slice, "scaleX", slice.ScaleX, NonActiveSliceScale).SetDuration (300);
                            scene.Play (scaleXDown);
                        }
                        if (slice.ScaleY != NonActiveSliceScale) {
                            var scaleYDown = ObjectAnimator.OfFloat (slice, "scaleY", slice.ScaleY, NonActiveSliceScale).SetDuration (300);
                            scene.Play (scaleYDown);
                        }
                    } else {
                        // No slice selected animations
                        if (slice.Alpha < 1) {
                            var fadeIn = ObjectAnimator.OfFloat (slice, "alpha", slice.Alpha, 1).SetDuration (300);
                            scene.Play (fadeIn);
                        }
                        if (slice.ScaleX != 1) {
                            var scaleXDown = ObjectAnimator.OfFloat (slice, "scaleX", slice.ScaleX, 1f).SetDuration (300);
                            scene.Play (scaleXDown);
                        }
                        if (slice.ScaleY != 1) {
                            var scaleYDown = ObjectAnimator.OfFloat (slice, "scaleY", slice.ScaleY, 1f).SetDuration (300);
                            scene.Play (scaleYDown);
                        }
                    }
                }

                currentSelectAnimation = scene;
                scene.Start ();
            }

            // Notify listeners
            if (ActiveSliceChanged != null) {
                ActiveSliceChanged (this, EventArgs.Empty);
            }
        }
Exemplo n.º 4
0
        public void Reset (SummaryReportView data)
        {
            this.data = data;

            // Cancel old animation
            if (currentRevealAnimation != null) {
                currentRevealAnimation.Cancel ();
                currentRevealAnimation = null;
            }
            if (currentSelectAnimation != null) {
                currentSelectAnimation.Cancel ();
                currentSelectAnimation = null;
            }

            var totalSlices = data == null || data.CollapsedProjects == null ? 0 : data.CollapsedProjects.Count;

            SetActiveSlice (-1, updateStats: false);
            backgroundView.Visibility = ViewStates.Visible;
            backgroundView.Radius = defaultRadius;

            ResetSlices (totalSlices);
            if (totalSlices > 0) {
                var totalTime = data.CollapsedProjects.Sum (x => x.TotalTime);
                var startAngle = 0f;

                for (var i = 0; i < totalSlices; i++) {
                    var slice = slices [i];
                    var project = data.CollapsedProjects [i];
                    var percentOfAll = (float)project.TotalTime / totalTime;

                    slice.Visibility = ViewStates.Gone;
                    slice.Radius = defaultRadius;
                    if (project.Color == ProjectModel.GroupedProjectColorIndex) {
                        slice.Color = Color.ParseColor (ProjectModel.GroupedProjectColor);
                    } else {
                        slice.Color = Color.ParseColor (ProjectModel.HexColors [project.Color % ProjectModel.HexColors.Length]);
                    }
                    slice.StartAngle = startAngle;
                    startAngle += percentOfAll * 360;
                }
            }

            // Detect state
            var isLoading = data == null || data.IsLoading;
            var isEmpty = !isLoading && totalSlices == 0;

            if (isLoading) {
                // Loading state
                loadingOverlayView.Visibility = ViewStates.Visible;
                loadingOverlayView.Alpha = 1f;

                emptyOverlayView.Visibility = ViewStates.Gone;
                statsOverlayView.Visibility = ViewStates.Gone;
            } else if (isEmpty) {
                // Error state
                loadingOverlayView.Visibility = ViewStates.Visible;
                loadingOverlayView.Alpha = 1f;

                emptyOverlayView.Visibility = ViewStates.Visible;
                emptyOverlayView.Alpha = 0f;

                statsOverlayView.Visibility = ViewStates.Gone;

                // Animate overlay in
                var scene = new AnimatorSet ();

                var fadeIn = ObjectAnimator.OfFloat (emptyOverlayView, "alpha", 0f, 1f).SetDuration (500);
                var fadeOut = ObjectAnimator.OfFloat (loadingOverlayView, "alpha", 1f, 0f).SetDuration (500);
                fadeOut.AnimationEnd += delegate {
                    loadingOverlayView.Visibility = ViewStates.Gone;
                };

                scene.Play (fadeOut);
                scene.Play (fadeIn).After (3 * fadeOut.Duration / 4);

                currentRevealAnimation = scene;
                scene.Start();
            } else {
                // Normal state
                var scene = new AnimatorSet ();

                // Fade loading message out
                statsOverlayView.Visibility = ViewStates.Visible;
                statsOverlayView.Alpha = 0f;

                var fadeOverlayOut = ObjectAnimator.OfFloat (loadingOverlayView, "alpha", 1f, 0f).SetDuration (500);
                fadeOverlayOut.AnimationEnd += delegate {
                    loadingOverlayView.Visibility = ViewStates.Gone;
                };
                scene.Play (fadeOverlayOut);

                var fadeOverlayIn = ObjectAnimator.OfFloat (statsOverlayView, "alpha", 0f, 1f).SetDuration (500);
                scene.Play (fadeOverlayIn).After (3 * fadeOverlayOut.Duration / 4);

                var donutReveal = ValueAnimator.OfFloat (0, 360);
                donutReveal.SetDuration (750);
                donutReveal.Update += (sender, e) => ShowSlices ((float)e.Animation.AnimatedValue);
                scene.Play (donutReveal).After (fadeOverlayOut.Duration / 2);

                currentRevealAnimation = scene;
                scene.Start();
            }

            UpdateStats ();
            RequestLayout ();
        }
Exemplo n.º 5
0
        public static AnimatorSet CreateMovementAnimation(View view, float x, float y)
        {
            var alphaIn = ObjectAnimator.OfFloat(view, ALPHA, INVISIBLE, VISIBLE).SetDuration(500);

            var setUpX = ObjectAnimator.OfFloat(view, COORD_X, x).SetDuration(INSTANT);
            var setUpY = ObjectAnimator.OfFloat(view, COORD_Y, y).SetDuration(INSTANT);

            var aset = new AnimatorSet();
            aset.Play(setUpX).With(setUpY).Before(alphaIn);
            return aset;
        }
Exemplo n.º 6
0
		private void PlayAnimation()
		{
			var animator = ObjectAnimator.OfFloat (this, "animationSeek", 0.0f, 1.0f);
			var animatorSet = new AnimatorSet ();
			animatorSet.SetDuration (AnimationDuration);
			animatorSet.SetInterpolator (new DecelerateInterpolator ());
			animatorSet.SetTarget (this);
            animatorSet.Play(animator);
			animatorSet.Start();
		}
Exemplo n.º 7
0
        public void Reset (SummaryReportView data)
        {
            // Cancel old animation
            if (currentAnimation != null) {
                currentAnimation.Cancel ();
                currentAnimation = null;
            }

            // Not zooming
            isZooming = false;

            var totalRows = 0;
            var hasTime = false;

            if (data == null) {
                backgroundView.XAxisLabels = null;
                ResetRows (totalRows);
            } else {
                var showEveryYLabel = 1;
                var showValueLabels = true;

                backgroundView.XAxisLabels = data.ChartTimeLabels.ToArray ();

                totalRows = Math.Min (data.Activity.Count, data.ChartRowLabels.Count);
                ResetRows (totalRows);

                if (totalRows > 25) {
                    showEveryYLabel = 3;
                    showValueLabels = false;
                }

                for (var i = 0; i < totalRows; i++) {
                    var activity = data.Activity [i];
                    var yLabel = data.ChartRowLabels [i];

                    if (activity.TotalTime > 0) {
                        hasTime = true;
                    }

                    var barWidth = (float)activity.TotalTime / (float) (data.MaxTotal * 3600);
                    var showYAxis = i % showEveryYLabel == 0;

                    // Bind the data to row
                    var row = rows [i];
                    row.RelativeWidth = barWidth;
                    row.BarView.BillableTime = activity.BillableTime;
                    row.BarView.TotalTime = activity.TotalTime;
                    row.ValueTextView.Text = activity.FormattedTotalTime;
                    row.ValueTextView.Visibility = showValueLabels ? ViewStates.Visible : ViewStates.Gone;
                    row.YAxisTextView.Text = yLabel;
                    row.YAxisTextView.Visibility = showYAxis ? ViewStates.Visible : ViewStates.Gone;
                }
            }

            // Detect state
            var isLoading = totalRows == 0 || (data != null && data.IsLoading);
            var isEmpty = !isLoading && !hasTime;

            if (isLoading) {
                // Loading state
                loadingOverlayView.Visibility = ViewStates.Visible;
                loadingOverlayView.Alpha = 1f;

                emptyOverlayView.Visibility = ViewStates.Gone;
            } else if (isEmpty) {
                // Error state
                loadingOverlayView.Visibility = ViewStates.Visible;
                loadingOverlayView.Alpha = 1f;

                emptyOverlayView.Visibility = ViewStates.Visible;
                emptyOverlayView.Alpha = 0f;

                // Animate overlay in
                var scene = new AnimatorSet ();

                var fadeIn = ObjectAnimator.OfFloat (emptyOverlayView, "alpha", 0f, 1f).SetDuration (500);
                var fadeOut = ObjectAnimator.OfFloat (loadingOverlayView, "alpha", 1f, 0f).SetDuration (500);
                fadeOut.AnimationEnd += delegate {
                    loadingOverlayView.Visibility = ViewStates.Gone;
                };

                scene.Play (fadeOut);
                scene.Play (fadeIn).After (3 * fadeOut.Duration / 4);

                currentAnimation = scene;
                scene.Start();
            } else {
                // Normal state
                var scene = new AnimatorSet ();

                // Fade loading message out
                var fadeOverlayOut = ObjectAnimator.OfFloat (loadingOverlayView, "alpha", 1f, 0f).SetDuration (500);
                fadeOverlayOut.AnimationEnd += delegate {
                    loadingOverlayView.Visibility = ViewStates.Gone;
                };

                scene.Play (fadeOverlayOut);

                foreach (var row in rows) {
                    var axisFadeIn = ObjectAnimator.OfFloat (row.YAxisTextView, "alpha", 0f, 1f).SetDuration (500);
                    var barScaleUp = ObjectAnimator.OfFloat (row.BarView, "scaleX", 0f, 1f).SetDuration (750);
                    var valueFadeIn = ObjectAnimator.OfFloat (row.ValueTextView, "alpha", 0f, 1f).SetDuration (400);

                    scene.Play (axisFadeIn);
                    scene.Play (barScaleUp).After (axisFadeIn.Duration / 2);
                    scene.Play (valueFadeIn).After (barScaleUp);
                }

                currentAnimation = scene;
                scene.Start();
            }

            RequestLayout ();
        }
Exemplo n.º 8
0
		public ExpandHelper(Context context, Callback callback, int small, int large) {
			this.smallSize = small;
			this.maximumStretch = Math.Max (smallSize, 1) * StretchInterval;
			this.largeSize = large;
			this.context = context;
			this.callback = callback;
			this.scaler = new ViewScaler();
			this.gravity = GravityFlags.Top;

			//this.scaleAnimation = ObjectAnimator.OfFloat (scaler, "Height", 0f);
			this.scaleAnimation = ValueAnimator.OfFloat (0f);
			this.scaleAnimation.Update += (sender, e) => scaler.Height = (float)e.Animation.AnimatedValue;
			this.scaleAnimation.SetDuration (ExpandDuration);

			AnimatorListenerAdapter glowVisibilityController = new AnimatorListener ();
			glowTopAnimation = ObjectAnimator.OfFloat (null, "alpha", 0f);
			glowTopAnimation.AddListener (glowVisibilityController);
			glowBottomAnimation = ObjectAnimator.OfFloat (null, "alpha", 0f);
			glowBottomAnimation.AddListener (glowVisibilityController);
			glowAnimationSet = new AnimatorSet();
			glowAnimationSet.Play (glowTopAnimation).With(glowBottomAnimation);
			glowAnimationSet.SetDuration(GlowDuration);

			detector = new DoubleSwipeDetector(context, new GestureDetector (this));
		}
Exemplo n.º 9
0
        /// <summary>
        ///   Builds the AnimatorSet that will create the expanding animation - the user will perceive the thumbnail getting bigger.
        /// </summary>
        /// <param name="expandedView">This is the ImageView that the thumbnail will scale up to.</param>
        /// <param name="startBounds">The visible rectangle of the thumbnail (global coordinates).</param>
        /// <param name="finalBounds">The visible rectangle of the full sized image (global coordinates).</param>
        /// <param name="startScale"></param>
        /// <returns></returns>
        private AnimatorSet BuildExpandingAnimatorSet(ImageView expandedView, Rect startBounds, Rect finalBounds, float startScale)
        {
			// Each expanding animator is unique to the start location - we'll cache the AnimatorSet
			// instance based on the starting location.
			int key = startBounds.GetHashCode ();
            if (_expandingAnimators.ContainsKey(key))
            {
                return _expandingAnimators[key];
            }

            AnimatorSet expandSet = new AnimatorSet();
            expandSet.Play(ObjectAnimator.OfFloat(expandedView, View.X, startBounds.Left, finalBounds.Left))
                     .With(ObjectAnimator.OfFloat(expandedView, View.Y, startBounds.Top, finalBounds.Top))
                     .With(ObjectAnimator.OfFloat(expandedView, "ScaleX", startScale, 1f))
                     .With(ObjectAnimator.OfFloat(expandedView, "ScaleY", startScale, 1f));
            expandSet.SetDuration(_shortAnimationDuration);
            expandSet.SetInterpolator(new DecelerateInterpolator());
            expandSet.AnimationEnd += NullOutCurrentAnimator;
            expandSet.AnimationCancel += NullOutCurrentAnimator;

            _expandingAnimators.Add(key, expandSet);
            return expandSet;
        }
Exemplo n.º 10
0
        /// <summary>
        ///   Builds the AnimatorSet to shrink the full sized image back to the thumbnail.
        /// </summary>
        /// <param name="bigView">The full sized view.</param>
        /// <param name="thumbView">The thumbnail view.</param>
        /// <param name="startBounds">The visible rectangle of the thumbnail when it is visible.</param>
        /// <param name="scale">Scale ratio.</param>
        /// <returns></returns>
        private AnimatorSet BuildShrinkingAnimatorSet(View bigView, View thumbView, Rect startBounds, float scale)
        {
            if (_shrinkingAnimators.ContainsKey(thumbView.Id))
            {
                return _shrinkingAnimators[thumbView.Id];
            }

            AnimatorSet shrinkSet = new AnimatorSet();
            shrinkSet.Play(ObjectAnimator.OfFloat(bigView, View.X, startBounds.Left))
                     .With(ObjectAnimator.OfFloat(bigView, View.Y, startBounds.Top))
                     .With(ObjectAnimator.OfFloat(bigView, "ScaleX", scale))
                     .With(ObjectAnimator.OfFloat(bigView, "ScaleY", scale));
            shrinkSet.SetDuration(_shortAnimationDuration);
            shrinkSet.SetInterpolator(new DecelerateInterpolator());
            shrinkSet.AnimationEnd += (sender1, args1) =>{
                thumbView.Alpha = 1.0f;
                bigView.Visibility = ViewStates.Gone;
                NullOutCurrentAnimator(sender1, args1);
            };

            shrinkSet.AnimationCancel += (sender1, args1) =>{
                thumbView.Alpha = 1.0f;
                bigView.Visibility = ViewStates.Gone;
                NullOutCurrentAnimator(sender1, args1);
            };

            _shrinkingAnimators.Add(thumbView.Id, shrinkSet);
            return shrinkSet;
        }
        private async Task FallbackAnimationAsync()
        {
            if (_icon == null)
                return;

            var rotate = ObjectAnimator.OfFloat(_icon, "rotationY", 0f, 180f);
            var fade = ObjectAnimator.OfFloat(_icon, "alpha", 1f, 0f);
            var scale = ObjectAnimator.OfPropertyValuesHolder(_icon, PropertyValuesHolder.OfFloat("scaleX", 0.4f), PropertyValuesHolder.OfFloat("scaleY", 0.4f));
            rotate.SetDuration(200);
            fade.SetDuration(600);
            scale.SetDuration(600);

            var animation = new AnimatorSet();
            animation.Play(rotate).Before(scale);
            animation.Play(fade).With(scale);
            await animation.StartAsync();
        }
        private void CreateCustomAnimation()
        {
            FloatingActionMenu menu3 = FindViewById<FloatingActionMenu>(Resource.Id.menu3);

            AnimatorSet set = new AnimatorSet();

            ObjectAnimator scaleOutX = ObjectAnimator.OfFloat(menu3.MenuIconView, "scaleX", 1.0f, 0.2f);
            ObjectAnimator scaleOutY = ObjectAnimator.OfFloat(menu3.MenuIconView, "scaleY", 1.0f, 0.2f);

            ObjectAnimator scaleInX = ObjectAnimator.OfFloat(menu3.MenuIconView, "scaleX", 0.2f, 1.0f);
            ObjectAnimator scaleInY = ObjectAnimator.OfFloat(menu3.MenuIconView, "scaleY", 0.2f, 1.0f);

            scaleOutX.SetDuration(50);
            scaleOutY.SetDuration(50);

            scaleInX.SetDuration(150);
            scaleInY.SetDuration(150);

            scaleInX.AnimationStart += (object sender, EventArgs e) =>
            {
                menu3.MenuIconView.SetImageResource(menu3.IsOpened ? Resource.Drawable.ic_close : Resource.Drawable.ic_star);
            };

            set.Play(scaleOutX).With(scaleOutY);
            set.Play(scaleInX).With(scaleInY).After(scaleOutX);
            set.SetInterpolator(new OvershootInterpolator(2));

            menu3.IconToggleAnimatorSet = set;
        }