コード例 #1
0
 public void captured()
 {
     a = ValueAnimator.OfFloat(0, 1f);
     a.SetDuration(600);
     a.setInterpolator(BaseChartView.INTERPOLATOR);
     a.AddUpdateListener(new AnimatorUpdateListener(animation =>
     {
         aValue = (float)animation.GetAnimatedValue();
         view.Invalidate();
     }));
     a.Start();
 }
コード例 #2
0
        public bool Uncapture(PointerPoint point, int pointerIndex)
        {
            if (pointerIndex == 0)
            {
                if (tryMoveTo)
                {
                    tryMoveTo = false;
                    float dx = moveToX - (int)point.Position.X;
                    float dy = moveToY - (int)point.Position.Y;
                    if (/*@event.getAction() == MotionEvent.ACTION_UP &&*/ DateTime.Now.ToTimestamp() * 1000 - startTapTime < 300 && Math.Sqrt(dx * dx + dy * dy) < 10)
                    {
                        float moveToX     = (this.moveToX - BaseChartView.HORIZONTAL_PADDING) / pickerWidth;
                        float w           = pickerEnd - pickerStart;
                        float moveToLeft  = moveToX - w / 2f;
                        float moveToRight = moveToX + w / 2f;
                        if (moveToLeft < 0f)
                        {
                            moveToLeft  = 0;
                            moveToRight = w;
                        }
                        else if (moveToRight > 1f)
                        {
                            moveToLeft  = 1f - w;
                            moveToRight = 1f;
                        }
                        float moveFromLeft  = pickerStart;
                        float moveFromRight = pickerEnd;

                        moveToAnimator = ValueAnimator.OfFloat(0f, 1f);
                        float finalMoveToLeft  = moveToLeft;
                        float finalMoveToRight = moveToRight;
                        view.OnPickerJumpTo(finalMoveToLeft, finalMoveToRight, true);
                        moveToAnimator.AddUpdateListener(new AnimatorUpdateListener(animation =>
                        {
                            float v     = (float)animation.GetAnimatedValue();
                            pickerStart = moveFromLeft + (finalMoveToLeft - moveFromLeft) * v;
                            pickerEnd   = moveFromRight + (finalMoveToRight - moveFromRight) * v;
                            view.OnPickerJumpTo(finalMoveToLeft, finalMoveToRight, false);
                        }));
                        moveToAnimator.setInterpolator(BaseChartView.INTERPOLATOR);
                        moveToAnimator.Start();
                    }
                    return(true);
                }

                if (capturedStates[0] != null)
                {
                    capturedStates[0].uncapture();
                }

                capturedStates[0] = null;
                if (capturedStates[1] != null)
                {
                    capturedStates[0] = capturedStates[1];
                    capturedStates[1] = null;
                }
            }
            else
            {
                if (capturedStates[1] != null)
                {
                    capturedStates[1].uncapture();
                }

                capturedStates[1] = null;
            }
            return(false);
        }