Beispiel #1
0
        public void showAnimation(ShineButton shineButton)
        {
            btnWidth    = shineButton.Width;
            btnHeight   = shineButton.Height;
            thirdLength = getThirdLength(btnHeight, btnWidth);
            int[] location = new int[2];
            shineButton.GetLocationInWindow(location);
            centerAnimX = location[0] + btnWidth / 2;
            centerAnimY = MeasuredHeight - shineButton.getBottomHeight() + btnHeight / 2;
            shineAnimator.AddUpdateListener(new XAnimatorUpdateListener()
            {
                AnimationUpdate = (valueAnimator) =>
                {
                    value = (float)valueAnimator.AnimatedValue;
                    if (shineSize != 0 && shineSize > 0)
                    {
                        paint.StrokeWidth      = (shineSize) * (shineDistanceMultiple - value);
                        paintSmall.StrokeWidth = ((float)shineSize / 3 * 2) * (shineDistanceMultiple - value);
                    }
                    else
                    {
                        paint.StrokeWidth      = (btnWidth / 2) * (shineDistanceMultiple - value);
                        paintSmall.StrokeWidth = (btnWidth / 3) * (shineDistanceMultiple - value);
                    }


                    rectF.Set(centerAnimX - (btnWidth / (3 - shineDistanceMultiple) * value), centerAnimY - (btnHeight / (3 - shineDistanceMultiple) * value), centerAnimX + (btnWidth / (3 - shineDistanceMultiple) * value), centerAnimY + (btnHeight / (3 - shineDistanceMultiple) * value));
                    rectFSmall.Set(centerAnimX - (btnWidth / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimY - (btnHeight / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimX + (btnWidth / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimY + (btnHeight / ((3 - shineDistanceMultiple) + distanceOffset) * value));

                    Invalidate();
                }
            });
            shineAnimator.startAnim(this, centerAnimX, centerAnimY);
            clickAnimator.Start();
        }
Beispiel #2
0
        public ShineView(Context context, ShineButton shineButton, ShineParams shineParams) : base(context)
        {
            initShineParams(shineParams, shineButton);


            this.shineAnimator       = new ShineAnimator(animDuration, shineDistanceMultiple, clickAnimDuration);
            ValueAnimator.FrameDelay = FRAME_REFRESH_DELAY;
            this.shineButton         = shineButton;


            paint             = new Paint();
            paint.Color       = bigShineColor;
            paint.StrokeWidth = 20;
            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeCap = Paint.Cap.Round;

            paint2             = new Paint();
            paint2.Color       = Color.White;
            paint2.StrokeWidth = 20;
            paint2.StrokeCap   = Paint.Cap.Round;

            paintSmall             = new Paint();
            paintSmall.Color       = smallShineColor;
            paintSmall.StrokeWidth = 10;
            paintSmall.SetStyle(Paint.Style.Stroke);
            paintSmall.StrokeCap = Paint.Cap.Round;

            clickAnimator            = ValueAnimator.OfFloat(0f, 1.1f);
            ValueAnimator.FrameDelay = FRAME_REFRESH_DELAY;
            clickAnimator.SetDuration(clickAnimDuration);
            clickAnimator.SetInterpolator(new XEI(Ease.QUART_OUT));

            clickAnimator.AddUpdateListener(new XAnimatorUpdateListener()
            {
                AnimationUpdate = (valueAnimator) =>
                {
                    clickValue = (float)valueAnimator.AnimatedValue;
                    Invalidate();
                }
            });

            clickAnimator.AddListener(new XAnimatorListener()
            {
                End = (animator) =>
                {
                    clickValue = 0;
                    Invalidate();
                }
            });

            shineAnimator.AddListener(new XAnimatorListener()
            {
                End = (animator) =>
                {
                    shineButton.removeView(this);
                }
            });
        }
Beispiel #3
0
            public void OnClick(View view)
            {
                ShineButton btn = view as ShineButton;

                if (!btn.isChecked())
                {
                    btn._isChecked = true;
                    btn.showAnim();
                }
                else
                {
                    btn._isChecked = false;
                    btn.setCancel();
                }

                btn.onListenerUpdate(btn._isChecked);
                if (listener != null)
                {
                    listener.OnClick(view);
                }
            }
Beispiel #4
0
        private void initShineParams(ShineParams shineParams, ShineButton shineButton)
        {
            shineCount            = shineParams.shineCount;
            turnAngle             = shineParams.shineTurnAngle;
            smallOffsetAngle      = shineParams.smallShineOffsetAngle;
            enableFlashing        = shineParams.enableFlashing;
            allowRandomColor      = shineParams.allowRandomColor;
            shineDistanceMultiple = shineParams.shineDistanceMultiple;
            animDuration          = shineParams.animDuration;
            clickAnimDuration     = shineParams.clickAnimDuration;
            smallShineColor       = shineParams.smallShineColor;
            bigShineColor         = shineParams.bigShineColor;
            shineSize             = shineParams.shineSize;
            if (smallShineColor == 0)
            {
                smallShineColor = colorRandom[6];
            }

            if (bigShineColor == 0)
            {
                bigShineColor = shineButton.getColor();
            }
        }