コード例 #1
0
        public bool OnTouch(View v, MotionEvent ev)
        {
            bool handled = false;

            if (mZoomEnabled && HasDrawable((ImageView)v))
            {
                IViewParent parent = v.Parent;
                switch (ev.Action)
                {
                case MotionEventActions.Down:
                    // First, disable the Parent from intercepting the touch
                    // event
                    if (null != parent)
                    {
                        parent.RequestDisallowInterceptTouchEvent(true);
                    }
                    else
                    {
                        Log.Info(LOG_TAG, "onTouch getParent() returned null");
                    }

                    // If we're flinging, and the user presses down, cancel
                    // fling
                    CancelFling();
                    break;

                case MotionEventActions.Cancel:
                case MotionEventActions.Up:
                    // If the user has zoomed less than min scale, zoom back
                    // to min scale
                    if (GetScale() < mMinScale)
                    {
                        RectF rect = GetDisplayRect();
                        if (null != rect)
                        {
                            v.Post(new AnimatedZoomRunnable(this, GetScale(), mMinScale,
                                                            rect.CenterX(), rect.CenterY()));
                            handled = true;
                        }
                    }
                    break;
                }

                // Try the Scale/Drag detector
                if (null != mScaleDragDetector &&
                    mScaleDragDetector.OnTouchEvent(ev))
                {
                    handled = true;
                }

                // Check to see if the user double tapped
                if (null != mGestureDetector && mGestureDetector.OnTouchEvent(ev))
                {
                    handled = true;
                }
            }

            return(handled);
        }
コード例 #2
0
 private void DisableParentTouch(IViewParent view)
 {
     view.RequestDisallowInterceptTouchEvent(true);
     if (view.Parent != null)
     {
         DisableParentTouch((view.Parent));
     }
 }
コード例 #3
0
        private void AttemptClaimDrag()
        {
            IViewParent parent = Parent;

            if (parent != null)
            {
                parent.RequestDisallowInterceptTouchEvent(true);
            }
        }
コード例 #4
0
        public void OnDrag(float dx, float dy)
        {
            if (mScaleDragDetector.IsScaling())
            {
                return;                 // Do not drag if we are already scaling
            }
            if (DEBUG)
            {
                LogManager.GetLogger().d(LOG_TAG,
                                         Java.Lang.String.Format("onDrag: dx: %.2f. dy: %.2f", dx, dy));
            }


            ImageView imageView = GetImageView();

            mSuppMatrix.PostTranslate(dx, dy);
            CheckAndDisplayMatrix();

            IViewParent parent = imageView.Parent;

            if (mAllowParentInterceptOnEdge && !mScaleDragDetector.IsScaling())
            {
                if (mScrollEdge == EDGE_BOTH ||
                    (mScrollEdge == EDGE_LEFT && dx >= 1f) ||
                    (mScrollEdge == EDGE_RIGHT && dx <= -1f))
                {
                    if (null != parent)
                    {
                        parent.RequestDisallowInterceptTouchEvent(false);
                    }
                }
            }
            else
            {
                if (null != parent)
                {
                    parent.RequestDisallowInterceptTouchEvent(true);
                }
            }
        }
コード例 #5
0
        public bool OnTouch(Android.Views.View v, MotionEvent e)
        {
            try {
                IViewParent parent = null;

                if (v.Parent is Android.Views.View)
                {
                    parent = v.Parent;
                }

                while (parent != null || parent is Android.Widget.ListView)
                {
                    parent.RequestDisallowInterceptTouchEvent(true);

                    parent = (parent is Android.Views.View viewParent) ? viewParent.Parent : null;
                }
            }
            catch (Exception exc) {
            }

            return(false);
        }