Пример #1
0
        private AnimatorSet createContentTextShowAnimation(View currentContentText, View newContentText)
        {
            int         positionDeltaPx      = dpToPixels(CONTENT_TEXT_POS_DELTA_Y_DP);
            AnimatorSet animations           = new AnimatorSet();
            Animator    currentContentMoveUp = ObjectAnimator.OfFloat(currentContentText, "y", 0, -positionDeltaPx);

            currentContentMoveUp.SetDuration(ANIM_CONTENT_TEXT_HIDE_TIME);
            var endListener = new AnimatorEndListener();

            endListener.OnEndAnimation += () =>
            {
                mContentTextContainer.RemoveView(currentContentText);
            };
            currentContentMoveUp.AddListener(endListener);

            Animator currentContentFadeOut = ObjectAnimator.OfFloat(currentContentText, "alpha", 1, 0);

            currentContentFadeOut.SetDuration(ANIM_CONTENT_TEXT_HIDE_TIME);

            animations.PlayTogether(currentContentMoveUp, currentContentFadeOut);

            Animator newContentMoveUp = ObjectAnimator.OfFloat(newContentText, "y", positionDeltaPx, 0);

            newContentMoveUp.SetDuration(ANIM_CONTENT_TEXT_SHOW_TIME);

            Animator newContentFadeIn = ObjectAnimator.OfFloat(newContentText, "alpha", 0, 1);

            newContentFadeIn.SetDuration(ANIM_CONTENT_TEXT_SHOW_TIME);

            animations.PlayTogether(newContentMoveUp, newContentFadeIn);

            animations.SetInterpolator(new DecelerateInterpolator());

            return(animations);
        }
Пример #2
0
 private void setAnimatorEndAction(Animator animator, Runnable endAction)
 {
     if (endAction != null)
     {
         animator.AddListener(new CustomAnimatorListenerAdapter(endAction));
     }
 }
Пример #3
0
        private void showWinnerAnimation(string winnerImageUrl)
        {
            if (_cxPosition == 0)
            {
                _cxPosition  = _ivWinner.MeasuredWidth / 2;
                _cyPosition  = _ivWinner.MeasuredHeight / 2;
                _finalRadius = Math.Max(_ivWinner.Width, val2: _ivWinner.Height);
            }

            Glide
            .With(_activity)
            .Load(winnerImageUrl)
            .Apply(RequestOptions.CenterCropTransform()).Into(_ivWinner);

            _isWinnerRevealing = true;


            Animator anim =
                ViewAnimationUtils.CreateCircularReveal(_groupWinner, _cxPosition, _cyPosition, 0, _finalRadius);

            _groupWinner.Visibility = ViewStates.Visible;
            _winnerView.PlayAnimation();
            anim.SetDuration(2000);
            anim.AddListener(this);
            anim.Start();
        }
Пример #4
0
        void InternalReveal(bool revealed)
        {
            // make sure we're not doubly requesting the same thing. That would
            // cause a hitch in the animation.
            if (Revealed != revealed)
            {
                Revealed = revealed;

                // if we're currently animating, cancel the animation
                if (Animator != null)
                {
                    Animator.Cancel( );
                }

                int yOffset = revealed ? 0 : ButtonLayout.LayoutParameters.Height;

                // setup an animation from our current mask scale to the new one.
                Animator = ValueAnimator.OfInt((int)ButtonLayout.GetY( ), yOffset);

                Animator.AddUpdateListener(this);
                Animator.AddListener(new NavToolbarAnimationListener()
                {
                    NavbarToolbar = this
                });
                Animator.SetDuration((long)(PrivateSubNavToolbarConfig.SlideRate * 1000.0f));

                Animator.Start( );
            }
        }
Пример #5
0
        public static Task StartAsync(this Animator animator)
        {
            var listener = new TaskAnimationListener();

            animator.AddListener(listener);
            animator.Start();
            return(listener.Task);
        }
Пример #6
0
            public override void AddListener(IAnimatorListener listener)
            {
                var wrapper = new AnimatorListenerWrapper(this, listener);

                if (_listeners.ContainsKey(listener))
                {
                    _listeners.Add(listener, wrapper);
                    _animator.AddListener(listener);
                }
            }
        protected void Init(float duration, AnimationUpdate updateDelegate, AnimationComplete completeDelegate)
        {
            Animator = ValueAnimator.OfFloat(0.00f, 1.00f);

            Animator.AddUpdateListener(this);
            Animator.AddListener(this);

            // convert duration to milliseconds
            Animator.SetDuration((int)(duration * 1000.0f));

            AnimationUpdateDelegate   = updateDelegate;
            AnimationCompleteDelegate = completeDelegate;
        }
        protected Animator CreateAnimator()
        {
            // Calculate the longest distance from the hot spot to the edge of the circle.
            int endRadius = Width / 2 + ((int)Math.Sqrt(Math.Pow(Width / 2 - touchPoint.Y, 2)
                                                        + Math.Pow(Width / 2 - touchPoint.X, 2)));

            // Make sure the touch point is defined or set it to the middle of the view.
            if (touchPoint == null)
            {
                touchPoint = new Point(Width / 2, Height / 2);
            }

            Animator anim = ViewAnimationUtils.CreateCircularReveal(revealView, touchPoint.X, touchPoint.Y, 0, endRadius);

            anim.AddListener(new MyAnimatorListenerAdapter(this));
            return(anim);
        }
Пример #9
0
 public void OnAnimationEnd(Animator animation)
 {
     if (_isWinnerRevealing)
     {
         Animator animClose =
             ViewAnimationUtils.CreateCircularReveal(_groupWinner, _cxPosition, _cyPosition, _finalRadius, 0);
         animClose.StartDelay = 3000;
         animClose.SetDuration(2000);
         animClose.AddListener(this);
         _isWinnerRevealing = false;
         animClose.Start();
     }
     else
     {
         _groupWinner.Visibility = ViewStates.Gone;
         _winnerView.CancelAnimation();
     }
 }
Пример #10
0
        public override Animator CreateAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues)
        {
            if (startValues == null || endValues == null)
            {
                return(null);
            }
            var startBounds = (Rect)startValues.Values[PROPERTY_BOUNDS];
            var endBounds   = (Rect)endValues.Values[PROPERTY_BOUNDS];

            if (startBounds == null || endBounds == null || startBounds.Equals(endBounds))
            {
                return(null);
            }

            var      startImage      = (Bitmap)startValues.Values[PROPERTY_IMAGE];
            Drawable startBackground = new BitmapDrawable(sceneRoot.Context.Resources, startImage);

            _startView = AddViewToOverlay(sceneRoot, startImage.Width,
                                          startImage.Height, startBackground);
            Drawable shrinkingBackground = new ColorDrawable(new Color(_color));

            _shrinkingView = AddViewToOverlay(sceneRoot, startImage.Width,
                                              startImage.Height, shrinkingBackground);

            var sceneRootLoc = new int[2];

            sceneRoot.GetLocationInWindow(sceneRootLoc);
            var startLoc          = (int[])startValues.Values[PROPERTY_POSITION];
            var startTranslationX = startLoc[0] - sceneRootLoc[0];
            var startTranslationY = startLoc[1] - sceneRootLoc[1];

            _startView.TranslationX     = startTranslationX;
            _startView.TranslationY     = startTranslationY;
            _shrinkingView.TranslationX = startTranslationX;
            _shrinkingView.TranslationY = startTranslationY;

            _endView = endValues.View;
            var startRadius = CalculateMaxRadius(_shrinkingView);
            var minRadius   = Math.Min(CalculateMinRadius(_shrinkingView), CalculateMinRadius(_endView));

            var circleBackground = new ShapeDrawable(new OvalShape());

            circleBackground.Paint.Color = new Color(_color);
            _circleView = AddViewToOverlay(sceneRoot, minRadius * 2, minRadius * 2,
                                           circleBackground);
            float circleStartX = startLoc[0] - sceneRootLoc[0] +
                                 ((_startView.Width - _circleView.Width) / 2);
            float circleStartY = startLoc[1] - sceneRootLoc[1] +
                                 ((_startView.Height - _circleView.Height) / 2);

            _circleView.TranslationX = circleStartX;
            _circleView.TranslationY = circleStartY;

            _circleView.Visibility = ViewStates.Invisible;
            _shrinkingView.Alpha   = 0f;
            _endView.Alpha         = 0f;

            var shrinkingAnimator = CreateCircularReveal(_shrinkingView, startRadius, minRadius);

            shrinkingAnimator.AddListener(new ShrinkingAnimator());

            var startAnimator  = CreateCircularReveal(_startView, startRadius, minRadius);
            var fadeInAnimator = ObjectAnimator.OfFloat(_shrinkingView, "angle", 0, 1);  // <<<<==================

            var shrinkFadeSet = new AnimatorSet();

            shrinkFadeSet.PlayTogether(shrinkingAnimator, startAnimator, fadeInAnimator);

            var   endLoc     = (int[])endValues.Values[PROPERTY_POSITION];
            float circleEndX = endLoc[0] - sceneRootLoc[0] +
                               ((_endView.Width - _circleView.Width) / 2);
            float circleEndY = endLoc[1] - sceneRootLoc[1] +
                               ((_endView.Height - _circleView.Height) / 2);
            var      circlePath     = PathMotion.GetPath(circleStartX, circleStartY, circleEndX, circleEndY);
            Animator circleAnimator = ObjectAnimator.OfFloat(_circleView, View.X,
                                                             View.Y, circlePath);

            _growingView = AddViewToOverlay(sceneRoot, _endView.Width,
                                            _endView.Height, shrinkingBackground);
            _growingView.Visibility = ViewStates.Invisible;
            float endTranslationX = endLoc[0] - sceneRootLoc[0];
            float endTranslationY = endLoc[1] - sceneRootLoc[1];

            _growingView.TranslationX = endTranslationX;
            _growingView.TranslationY = endTranslationY;

            var endRadius = CalculateMaxRadius(_endView);

            circleAnimator.AddListener(new CircleAnimator());

            Animator fadeOutAnimator = ObjectAnimator.OfFloat(_growingView, "angle", 1, 0); //<<<============
            var      endAnimator     = CreateCircularReveal(_endView, minRadius, endRadius);
            var      growingAnimator = CreateCircularReveal(_growingView, minRadius, endRadius);

            growingAnimator.AddListener(new GrowingAnimator(sceneRoot));
            var growingFadeSet = new AnimatorSet();

            growingFadeSet.PlayTogether(fadeOutAnimator, endAnimator, growingAnimator);

            var animatorSet = new AnimatorSet();

            animatorSet.PlaySequentially(shrinkFadeSet, circleAnimator, growingFadeSet);
            return(animatorSet);
        }