コード例 #1
0
        void SetInterpolator(int position)
        {
            IInterpolator CurrentInterpolator;

            switch (position)
            {
            case 1:
                CurrentInterpolator    = new LinearInterpolator();
                _seekBarFactor.Enabled = false;
                break;

            case 2:
                CurrentInterpolator    = new AccelerateDecelerateInterpolator();
                _seekBarFactor.Enabled = false;
                break;

            case 3:
                CurrentInterpolator    = new DecelerateInterpolator(_factor);
                _seekBarFactor.Enabled = true;
                break;

            case 0:
            default:
                CurrentInterpolator    = new AccelerateInterpolator(_factor);
                _seekBarFactor.Enabled = true;
                break;
            }

            _progressBar.SetSmoothProgressDrawableInterpolator(CurrentInterpolator);
            _progressBar.SetSmoothProgressDrawableColors(Resources.GetIntArray(Resource.Array.gplus_colors));
        }
コード例 #2
0
        /**
         * Constructor that is called when inflating SwipeRefreshLayout from XML.
         *
         * @param context
         * @param attrs
         */
        public SwipeRefreshLayout(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            mRefreshListener          = new CustomRefreshListener(this);
            mAnimateToCorrectPosition = new CustommAnimateToCorrectPosition(this);
            mAnimateToStartPosition   = new CustommAnimateToStartPosition(this);

            mTouchSlop = ViewConfiguration.Get(context).ScaledTouchSlop;

            mMediumAnimationDuration = Resources.GetInteger(
                AndroidResource.Integer.ConfigMediumAnimTime);

            SetWillNotDraw(false);
            mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

            TypedArray a = context.ObtainStyledAttributes(attrs, LAYOUT_ATTRS);

            Enabled = (a.GetBoolean(0, true));
            a.Recycle();

            DisplayMetrics metrics = Resources.DisplayMetrics;

            mCircleWidth  = (int)(CIRCLE_DIAMETER * metrics.Density);
            mCircleHeight = (int)(CIRCLE_DIAMETER * metrics.Density);

            createProgressView();
            ViewCompat.SetChildrenDrawingOrderEnabled(this, true);
            // the absolute offset has to take into account that the circle starts at an offset
            mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.Density;
            mTotalDragDistance  = mSpinnerFinalOffset;

            RequestDisallowInterceptTouchEvent(true);
        }
コード例 #3
0
        private void SetValues()
        {
            _progressBar.SmoothProgressDrawableSpeed           = _speed;
            _progressBar.SmoothProgressDrawableSectionsCount   = _sectionsCount;
            _progressBar.SmoothProgressDrawableSeparatorLength = DpToPx(_separatorLength);
            _progressBar.SmoothProgressDrawableStrokeWidth     = DpToPx(_strokeWidth);
            _progressBar.SmoothProgressDrawableReversed        = _checkBoxReversed.Checked;
            _progressBar.SmoothProgressDrawableMirrorMode      = _checkBoxMirror.Checked;

            IInterpolator interpolator;

            switch (_spinnerInterpolators.SelectedItemPosition)
            {
            case 1:
                interpolator = new LinearInterpolator();
                break;

            case 2:
                interpolator = new AccelerateDecelerateInterpolator();
                break;

            case 3:
                interpolator = new DecelerateInterpolator();
                break;

            default:
                interpolator = new AccelerateInterpolator();
                break;
            }

            _progressBar.SmoothProgressDrawableInterpolator = interpolator;
            _progressBar.SmoothProgressDrawableColors       = IntsToColors(Resources.GetIntArray(Resource.Array.colors));
        }
コード例 #4
0
        /**
         * Constructor that is called when inflating SwipeRefreshLayout from XML.
         *
         * @param context
         * @param attrs
         */
        public SwipeRefreshLayout(Context context, IAttributeSet attrs = null)
            : base(context, attrs)
        {
            _refreshListener          = new CustomRefreshListener(this);
            _animateToCorrectPosition = new CustommAnimateToCorrectPosition(this);
            _animateToStartPosition   = new CustommAnimateToStartPosition(this);

            _touchSlop = ViewConfiguration.Get(context).ScaledTouchSlop;

            _mediumAnimationDuration = Resources.GetInteger(
                AndroidResource.Integer.ConfigMediumAnimTime);

            SetWillNotDraw(false);
            _decelerateInterpolator = new DecelerateInterpolator(DecelerateInterpolationFactor);

            var a = context.ObtainStyledAttributes(attrs, LayoutAttrs);

            Enabled = (a.GetBoolean(0, true));
            a.Recycle();

            var metrics = Resources.DisplayMetrics;

            _circleWidth  = (int)(CircleDiameter * metrics.Density);
            _circleHeight = (int)(CircleDiameter * metrics.Density);

            CreateProgressView();
#pragma warning disable 618
            ViewCompat.SetChildrenDrawingOrderEnabled(this, true);
#pragma warning restore 618
            // the absolute offset has to take into account that the circle starts at an offset
            _spinnerFinalOffset = DefaultCircleTarget * metrics.Density;
            _totalDragDistance  = _spinnerFinalOffset;

            RequestDisallowInterceptTouchEvent(true);
        }
コード例 #5
0
        private void ShowView(View v)
        {
            var intrpltr = new DecelerateInterpolator(5);

            v.Animate().SetInterpolator(intrpltr)
            .TranslationX(0)
            .SetDuration(500);
        }
コード例 #6
0
        public SlideAnimation(View v, int marginStartX, int marginEndX)
        {
            _mStartX = marginStartX;
            _mView   = v;

            _mChangeX    = marginEndX - _mStartX;
            Interpolator = new DecelerateInterpolator(0.9f);
        }
コード例 #7
0
        private ITimeInterpolator GetAndroidInterpolator(
            EasingFunction ease)
        {
            ITimeInterpolator androidEase = null;

            if (null != ease)
            {
                var cubicEase   = ease as CubicEase;
                var elasticEase = ease as SpringEase;

                if (null != cubicEase)
                {
                    if (ease.EasingMode == EasingMode.EaseIn)
                    {
                        androidEase = new AccelerateInterpolator(1.5f);
                    }
                    else if (ease.EasingMode == EasingMode.EaseOut)
                    {
                        androidEase = new DecelerateInterpolator(1.5f);
                    }
                    else if (ease.EasingMode == EasingMode.EaseInOut)
                    {
                        // TODO: A custom interpolator. This is actually a circular ease, not a cubic ease-in-out
                        androidEase = new AccelerateDecelerateInterpolator();
                    }
                    else
                    {
                        throw new NotSupportedException("Unsupported easing mode.");
                    }
                }
                else if (null != elasticEase)
                {
                    // TODO: Custom interpolators
                    if (ease.EasingMode == EasingMode.EaseIn)
                    {
                        androidEase = new BounceInterpolator();
                    }
                    else if (ease.EasingMode == EasingMode.EaseOut)
                    {
                        androidEase = new BounceInterpolator();
                    }
                    else if (ease.EasingMode == EasingMode.EaseInOut)
                    {
                        androidEase = new BounceInterpolator();
                    }
                    else
                    {
                        throw new NotSupportedException("Unsupported easing mode.");
                    }
                }
                else
                {
                    throw new NotSupportedException("Unsupported easing function.");
                }
            }

            return(androidEase);
        }
コード例 #8
0
        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();
        }