Ejemplo n.º 1
0
 public void captured()
 {
     a = ValueAnimator.ofFloat(view, 0, 1f);
     a.setDuration(600);
     a.setInterpolator(BaseChartView.INTERPOLATOR);
     a.addUpdateListener(new AnimatorUpdateListener(animation =>
     {
         aValue = (float)animation.getAnimatedValue();
         view.invalidate();
     }));
     a.start();
 }
Ejemplo n.º 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 - 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(view, 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);
        }