コード例 #1
0
ファイル: ArcLayout.cs プロジェクト: veresbogdan/MMD
        private void bindChildAnimation(View child, int index, long duration)
        {
            bool expanded = mExpanded;
            int centerX = Width / 2;
            int centerY = Height / 2;
            int radius = expanded ? 0 : mRadius;

            int childCount = ChildCount;
            float perDegrees = (mToDegrees - mFromDegrees) / (childCount - 1);
            Rect frame = computeChildFrame(centerX, centerY, radius, mFromDegrees + index * perDegrees, mChildSize);

            int toXDelta = frame.Left - child.Left;
            int toYDelta = frame.Top - child.Top;

            IInterpolator interpolator;
            if (mExpanded)
                interpolator = new AccelerateInterpolator();
            else
                interpolator = new OvershootInterpolator(1.5f);
            long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator);

            Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration,
                    interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator);

            bool isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1;
            var animationListener = new AnimationListener(isLast);
            animationListener.OnAnimationEndEvent += () =>
                {
                    PostDelayed(new Action(
                    () =>
                    {
                        onAllAnimationsEnd();
                    }), 0);
                };
            animation.SetAnimationListener(animationListener);
            child.Animation = animation;
        }
コード例 #2
0
ファイル: SplashActivity.cs プロジェクト: EckyZero/Hashtagg
        private async void OnRequestOnboardingPage(OnboardingViewModel oVm)
        {
            _viewModel = oVm;
            AnimationInitUI();
            BindEvents();
            
            var mainAnimatorSet = new AnimatorSet();

            var appNameLayoutFinalTopSpace = TypedValue.ApplyDimension(ComplexUnitType.Dip, 55.0f, Application.Context.Resources.DisplayMetrics);

            var decelerateInterpolator = new DecelerateInterpolator(1.0f);

            var appNameLayoutAnimator = new ValueAnimator();
            appNameLayoutAnimator.SetDuration(750);
            appNameLayoutAnimator.SetInterpolator(decelerateInterpolator);
            appNameLayoutAnimator.SetFloatValues(_appNameLayout.GetY(), appNameLayoutFinalTopSpace);
            appNameLayoutAnimator.Update += (o, args) => { _appNameLayout.SetY((float)args.Animation.AnimatedValue); };

            var whatAccountsAnimator = new ValueAnimator();
            whatAccountsAnimator.SetDuration(750);
            whatAccountsAnimator.SetInterpolator(decelerateInterpolator);
            whatAccountsAnimator.SetFloatValues(0.0f, 1.0f);
            whatAccountsAnimator.Update += (o, args) => { _whatAccounts.Alpha = (float)args.Animation.AnimatedValue; };

            var appNameAnimationSet = new AnimatorSet();
            appNameAnimationSet.PlayTogether(appNameLayoutAnimator, whatAccountsAnimator);


            var socialButtonsAnimatorSet = new AnimatorSet();

            var overshootInterpolator = new OvershootInterpolator(3f);

            var facebookButtonAnimator = new ValueAnimator();
            facebookButtonAnimator.SetDuration(500);
            facebookButtonAnimator.SetInterpolator(overshootInterpolator);
            facebookButtonAnimator.SetFloatValues(_facebookButton.GetY() + _facebookButton.Height, _facebookButton.GetY());
            facebookButtonAnimator.Update += (o, args) =>
                {
                    _facebookButton.SetY((float)args.Animation.AnimatedValue);
                    _facebookButton.Alpha = args.Animation.AnimatedFraction;
                };

            var twitterButtonAnimator = new ValueAnimator();
            twitterButtonAnimator.SetDuration(500);
            twitterButtonAnimator.SetInterpolator(overshootInterpolator);
            twitterButtonAnimator.SetFloatValues(_facebookButton.GetY() + _facebookButton.Height, _facebookButton.GetY());
            twitterButtonAnimator.Update += (o, args) =>
                {
                    _twitterButton.SetY((float)args.Animation.AnimatedValue);
                    _twitterButton.Alpha = args.Animation.AnimatedFraction;
                };
            socialButtonsAnimatorSet.PlaySequentially(facebookButtonAnimator, twitterButtonAnimator);
            socialButtonsAnimatorSet.StartDelay = 500;

            var letsGoButtonAnimator = new ValueAnimator();
            letsGoButtonAnimator.SetDuration(500);
            letsGoButtonAnimator.SetInterpolator(decelerateInterpolator);
            letsGoButtonAnimator.SetFloatValues(0.0f, 1.0f);
            letsGoButtonAnimator.Update += (sender, args) =>
                {
                    _goButton.Alpha = (float)args.Animation.AnimatedValue;
                };

            mainAnimatorSet.PlaySequentially(appNameAnimationSet, socialButtonsAnimatorSet, letsGoButtonAnimator);

            await _viewModel.DidLoad();

            await Task.Delay(2000);

            mainAnimatorSet.Start();
            await _viewModel.DidAppear();
        }