Exemplo n.º 1
0
        /**
         * Fling the scroll view
         *
         * @param velocityY The initial velocity in the Y direction. Positive
         *                  numbers mean that the finger/curor is moving down the screen,
         *                  which means we want to scroll towards the top.
         */
        public void Fling(int velocityX, int velocityY)
        {
            if (ChildCount > 0)
            {
                int height = Height - PaddingBottom - PaddingTop;
                int bottom = GetChildAt(0).Height;
                int width  = Width - PaddingRight - PaddingLeft;
                int right  = GetChildAt(0).Width;

                mScroller.Fling(ScrollX, ScrollY, velocityX, velocityY, 0, right - width, 0, bottom - height);

                bool movingDown  = velocityY > 0;
                bool movingRight = velocityX > 0;

                View newFocused = findFocusableViewInMyBounds(movingRight, mScroller.FinalX, movingDown, mScroller.FinalY, FindFocus());
                if (newFocused == null)
                {
                    newFocused = this;
                }

                if (newFocused != FindFocus() && newFocused.RequestFocus(movingDown ? FocusSearchDirection.Down : FocusSearchDirection.Up))
                {
                    mTwoDScrollViewMovedFocus = true;
                    mTwoDScrollViewMovedFocus = false;
                }

                AwakenScrollBars(mScroller.Duration);
                Invalidate();
            }
        }
Exemplo n.º 2
0
        public bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
        {
            var x = e2.GetX();
            var y = e2.GetY();

            Scroller.Fling((int)x, (int)y, (int)velocityX / 4, (int)velocityY / 4, 0, Width * 5, 0, Height * 5);

            Device.StartTimer(new TimeSpan(1), () => {
                if (Scroller.ComputeScrollOffset())
                {
                    var xx = Scroller.CurrX;
                    var yy = Scroller.CurrY;

                    Element.ViewPoint = Element.ViewPoint.Offset(-(xx - x) / Element.ViewScale, -(yy - y) / Element.ViewScale);

                    DrawImage = Element.DrawImmageRequest(Element.ViewPoint, Matrix2.Enlargement(ViewSize, 1 / Element.ViewScale, 1 / Element.ViewScale));

                    Invalidate();
                }
                return(!Scroller.IsFinished);
            });


            return(true);
        }
Exemplo n.º 3
0
            public Fling(TouchImageView view, int velocityX, int velocityY)
            {
                this.view = view;
                view.SetState(TouchState.FLING);
                scroller = new Scroller(view.context);
                view.matrix.GetValues(view.m);

                int startX = (int)view.m[Matrix.MtransX];
                int startY = (int)view.m[Matrix.MtransY];
                int minX, maxX, minY, maxY;

                if (view.GetImageWidth() > view.viewWidth)
                {
                    minX = view.viewWidth - (int)view.GetImageWidth();
                    maxX = 0;
                }
                else
                {
                    minX = maxX = startX;
                }

                if (view.GetImageHeight() > view.viewHeight)
                {
                    minY = view.viewHeight - (int)view.GetImageHeight();
                    maxY = 0;
                }
                else
                {
                    minY = maxY = startY;
                }

                scroller.Fling(startX, startY, (int)velocityX, (int)velocityY, minX, maxX, minY, maxY);
                currX = startX;
                currY = startY;
            }
Exemplo n.º 4
0
        protected bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
        {
            lock (this)
            {
                Scroller.Fling(_nextX, 0, (int)-velocityX, 0, 0, _maxX, 0, 0);
            }
            RequestLayout();

            return(true);
        }
Exemplo n.º 5
0
 public void Fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY)
 {
     if (isPreGingerbread)
     {
         scroller.Fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY);
     }
     else
     {
         overScroller.Fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY);
     }
 }
Exemplo n.º 6
0
            public Fling(ScaleImageView view, int velocityX, int velocityY)
            {
                try
                {
                    _view = view;
                    view.SetState(TouchState.Fling);
                    _scroller = new Scroller(view._context);
                    view._matrix.GetValues(view._m);

                    var startX = (int)view._m[Matrix.MtransX];
                    var startY = (int)view._m[Matrix.MtransY];
                    int minX, maxX, minY, maxY;

                    if (view.GetImageWidth() > view.ViewWidth)
                    {
                        minX = view.ViewWidth - (int)view.GetImageWidth();
                        maxX = 0;
                    }
                    else
                    {
                        minX = maxX = startX;
                    }
                    if (view.GetImageHeight() > view.ViewHeight)
                    {
                        minY = view.ViewHeight - (int)view.GetImageHeight();
                        maxY = 0;
                    }
                    else
                    {
                        minY = maxY = startY;
                    }
                    _scroller.Fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY);
                    _currX = startX;
                    _currY = startY;
                }
                catch
                {
                    //todo nothing
                }
            }
Exemplo n.º 7
0
 public override void Fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY, int overX, int overY)
 {
     mScroller.Fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY);
 }