Java 类android.view.GestureDetector.SimpleOnGestureListener 实例源码

项目:OSchina_resources_android    文件:ZoomImageView.java   
public ZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale)
                        return true;
                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < SCALE_MID) {
                        postDelayed(new ScaleRunnable(SCALE_MID, x, y), 16);
                        isAutoScale = true;
                    } else {
                        postDelayed(new ScaleRunnable(mScale, x, y), 16);
                        isAutoScale = true;
                    }
                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
项目:SwipeMenuRecyclerView-master    文件:SwipeMenuLayout.java   
public void init() {
    mGestureListener = new SimpleOnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2,
                               float velocityX, float velocityY) {

            if (velocityX > mViewConfiguration.getScaledMinimumFlingVelocity() || velocityY > mViewConfiguration.getScaledMinimumFlingVelocity())
                isFling = true;
            return isFling;
        }
    };
    mGestureDetector = new GestureDetectorCompat(getContext(),
            mGestureListener);

    mCloseScroller = ScrollerCompat.create(getContext());
    mOpenScroller = ScrollerCompat.create(getContext());
}
项目:RxTools    文件:WheelScroller.java   
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call immediately
            //  when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:msb-android    文件:WheelScroller.java   
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call immediately
            //  when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:GestureDetectorTest    文件:ZoomImageView.java   
public ZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setScaleType(ScaleType.MATRIX);//用矩阵来绘制
    mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {//双击时
            if (isAutoScale == true) return true;
            float x = e.getX();
            float y = e.getY();
            Log.i(TAG, "双击onDoubleTap," + "缩放比例:" + getScale() + " , " + initScale);
            if (getScale() < SCALE_MID) postDelayed(new AutoScaleRunnable(SCALE_MID, x, y), 10);
            else if (getScale() >= SCALE_MID && getScale() < SCALE_MAX) postDelayed(new AutoScaleRunnable(SCALE_MAX, x, y), 10);
            else postDelayed(new AutoScaleRunnable(initScale, x, y), 10);

            isAutoScale = true;

            return true;
        }
    });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
项目:dedecmsapp    文件:WheelScroller.java   
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call immediately
            //  when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:dedecmsapp    文件:ClipRectZoomImageView.java   
public ClipRectZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (isAutoScale == true)
                return true;

            float x = e.getX();
            float y = e.getY();
            if (getScale() < SCALE_MID) {
                ClipRectZoomImageView.this.postDelayed(new AutoScaleRunnable(SCALE_MID, x, y), 16);
                isAutoScale = true;
            } else {
                ClipRectZoomImageView.this.postDelayed(new AutoScaleRunnable(initScale, x, y), 16);
                isAutoScale = true;
            }

            return true;
        }
    });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
项目:dedecmsapp    文件:ClipZoomImageView.java   
public ClipZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (isAutoScale == true)
                return true;

            float x = e.getX();
            float y = e.getY();
            if (getScale() < SCALE_MID) {
                ClipZoomImageView.this.postDelayed(new AutoScaleRunnable(SCALE_MID, x, y), 16);
                isAutoScale = true;
            } else {
                ClipZoomImageView.this.postDelayed(new AutoScaleRunnable(initScale, x, y), 16);
                isAutoScale = true;
            }

            return true;
        }
    });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
项目:love    文件:WheelScroller.java   
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call immediately
            //  when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:GitHubExplorer    文件:Gestures.java   
/**
 * Register listener on double-tap gesture for view
 *
 * @param view
 * @param listener
 * @return view
 */
public static View onDoubleTap(final View view,
    final OnDoubleTapListener listener) {
  final GestureDetector detector = new GestureDetector(view.getContext(),
      new SimpleOnGestureListener());
  detector.setOnDoubleTapListener(listener);
  view.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
      return detector.onTouchEvent(event);
    }
  });

  return view;
}
项目:DateTimePicker-Android-Stylish    文件:WheelScroller.java   
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call immediately
            //  when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:github-v2    文件:Gestures.java   
/**
 * Register listener on double-tap gesture for view
 *
 * @param view
 * @param listener
 * @return view
 */
public static View onDoubleTap(final View view,
    final OnDoubleTapListener listener) {
  final GestureDetector detector = new GestureDetector(view.getContext(),
      new SimpleOnGestureListener());
  detector.setOnDoubleTapListener(listener);
  view.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
      return detector.onTouchEvent(event);
    }
  });

  return view;
}
项目:iSCAU-Android    文件:WheelScroller.java   
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call immediately
            //  when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:wishlist_hackugyo    文件:Gestures.java   
/**
 * Register listener on double-tap gesture for view
 *
 * @param view
 * @param listener
 * @return view
 */
public static View onDoubleTap(final View view,
    final OnDoubleTapListener listener) {
  final GestureDetector detector = new GestureDetector(view.getContext(),
      new SimpleOnGestureListener());
  detector.setOnDoubleTapListener(listener);
  view.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
      return detector.onTouchEvent(event);
    }
  });

  return view;
}
项目:Ghostbin-for-Android    文件:Gestures.java   
/**
 * Register listener on double-tap gesture for view
 *
 * @param view
 * @param listener
 * @return view
 */
public static View onDoubleTap(final View view,
    final OnDoubleTapListener listener) {
  final GestureDetector detector = new GestureDetector(view.getContext(),
      new SimpleOnGestureListener());
  detector.setOnDoubleTapListener(listener);
  view.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
      return detector.onTouchEvent(event);
    }
  });

  return view;
}
项目:TestChat    文件:DragLayout.java   
public DragLayout(Context context, AttributeSet attrs, int defStyleAttr) {
                super(context, attrs, defStyleAttr);
                mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
                        @Override
                        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
//                                如果水平方向的偏移量大于竖直方向的偏移量,就消化该事件,
                                return Math.abs(distanceX) > Math.abs(distanceY) || super.onScroll(e1, e2, distanceX, distanceY);

                        }
                });
//                永远要记得,该工具实现的拖拉是基于控件位置的改变来实现的
                mViewDragHelper = ViewDragHelper.create(this, new DragViewCallBack());
        }
项目:TestChat    文件:ZoomImageView.java   
public ZoomImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        super.setScaleType(ScaleType.MATRIX);
        mGestureDetector = new GestureDetector(context,
                new SimpleOnGestureListener() {
                        @Override
                        public boolean onDoubleTap(MotionEvent e) {
                                if (isAutoScale)
                                        return true;

                                float x = e.getX();
                                float y = e.getY();
                                Log.e("DoubleTap", getScale() + " , " + initScale);
                                if (getScale() < SCALE_MID) {
                                        ZoomImageView.this.postDelayed(
                                                new AutoScaleRunnable(SCALE_MID, x, y), 16);
                                        isAutoScale = true;
                                } else if (getScale() >= SCALE_MID
                                        && getScale() < SCALE_MAX) {
                                        ZoomImageView.this.postDelayed(
                                                new AutoScaleRunnable(SCALE_MAX, x, y), 16);
                                        isAutoScale = true;
                                } else {
                                        ZoomImageView.this.postDelayed(
                                                new AutoScaleRunnable(initScale, x, y), 16);
                                        isAutoScale = true;
                                }

                                return true;
                        }
                });
        mScaleGestureDetector = new ScaleGestureDetector(context, this);
        this.setOnTouchListener(this);
}
项目:LiteSDK    文件:ClipZoomImageView.java   
public ClipZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale == true)
                        return true;

                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < SCALE_MID) {
                        ClipZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(SCALE_MID, x, y), 16);
                        isAutoScale = true;
                    } else {
                        ClipZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(initScale, x, y), 16);
                        isAutoScale = true;
                    }

                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    setOnTouchListener(this);
}
项目:Tower-develop    文件:WheelScroller.java   
/**
 * Constructor
 * 
 * @param context
 *            the current context
 * @param listener
 *            the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call
            // immediately
            // when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:ticdesign    文件:FloatingActionButton.java   
public void startDelayConfirmation(long delay, DelayedConfirmationListener listener) {
    stopDelayConfirmation();

    setProgressMode(CircularProgressDrawable.MODE_DETERMINATE);
    setProgressPercent(0);
    setShowProgress(true);

    setClickable(true);

    mDelayedConfirmationListener = listener;
    mDelayedConfirmationAnimator = ValueAnimator.ofFloat(0, 1).setDuration(delay);
    mDelayedConfirmationAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float progress = (float) animation.getAnimatedValue();
            if (getProgressDrawable() != null) {
                getProgressDrawable().setProgress(progress);
            } else {
                stopDelayConfirmation();
            }
            if (progress >= 1) {
                finishDelayConfirmation(false);
            }
        }
    });
    mDelayedConfirmationAnimator.start();

    if (mGestureDetector == null) {
        mGestureDetector = new GestureDetector(getContext(), new SimpleOnGestureListener() {
            @Override
            public boolean onSingleTapConfirmed(MotionEvent e) {
                finishDelayConfirmation(true);
                return super.onSingleTapConfirmed(e);
            }
        });
    }
}
项目:Vafrinn    文件:SwipableOverlayView.java   
/**
 * Creates a SwipableOverlayView.
 * @param context Context for acquiring resources.
 * @param attrs Attributes from the XML layout inflation.
 */
public SwipableOverlayView(Context context, AttributeSet attrs) {
    super(context, attrs);
    SimpleOnGestureListener gestureListener = createGestureListener();
    mGestureDetector = new GestureDetector(context, gestureListener);
    mGestureStateListener = createGestureStateListener();
    mGestureState = GESTURE_NONE;
    mLayoutChangeListener = createLayoutChangeListener();
    mAnimatorListenerAdapter = createAnimatorListenerAdapter();
    mInterpolator = new DecelerateInterpolator(1.0f);
    mTabObserver = createTabObserver();

    // We make this view 'draw' to provide a placeholder for its animations.
    setWillNotDraw(false);
}
项目:Superuser-UI    文件:RecyclerItemClickListener.java   
public RecyclerItemClickListener(Context context, OnItemClickListener onItemClickListener) {
    listener = onItemClickListener;

    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return true;
        }
    });
}
项目:droidplanner-master    文件:WheelScroller.java   
/**
 * Constructor
 * 
 * @param context
 *            the current context
 * @param listener
 *            the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call
            // immediately
            // when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:umeng_community_android    文件:ClipZoomImageView.java   
public ClipZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale == true)
                        return true;

                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < SCALE_MID) {
                        ClipZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(SCALE_MID, x, y), 16);
                        isAutoScale = true;
                    } else {
                        ClipZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(initScale, x, y), 16);
                        isAutoScale = true;
                    }

                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    setOnTouchListener(this);
}
项目:AndroidGeek    文件:ClipZoomImageView.java   
public ClipZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale == true)
                        return true;

                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < SCALE_MID) {
                        ClipZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(SCALE_MID, x, y), 16);
                        isAutoScale = true;
                    } else {
                        ClipZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(initScale, x, y), 16);
                        isAutoScale = true;
                    }

                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    setOnTouchListener(this);
}
项目:nongfei-missionplane    文件:WheelScroller.java   
/**
 * Constructor
 * 
 * @param context
 *            the current context
 * @param listener
 *            the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call
            // immediately
            // when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:ZoomCropImage    文件:ZoomCropImageView.java   
@SuppressLint("ClickableViewAccessibility")
public ZoomCropImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale == true)
                        return true;

                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < initScale) {
                        ZoomCropImageView.this.postDelayed(
                                new AutoScaleRunnable(mScaleMax, x, y), 16);
                        isAutoScale = true;
                    } else {
                        ZoomCropImageView.this.postDelayed(
                                new AutoScaleRunnable(mScaleMin, x, y), 16);
                        isAutoScale = true;
                    }

                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
项目:love    文件:ClipZoomImageView.java   
public ClipZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
       /*设置缩放为矩阵*/
    setScaleType(ScaleType.MATRIX);
       /*缩放检测器*/
    mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
               @Override
               public boolean onDoubleTap(MotionEvent e) {
                   if (isAutoScale == true)
                       return true;

                   float x = e.getX();
                   float y = e.getY();
                   if (getScale() < SCALE_MID) {
                       ClipZoomImageView.this.postDelayed(new AutoScaleRunnable(SCALE_MID, x, y), 16);
                       isAutoScale = true;
                   } else {
                       ClipZoomImageView.this.postDelayed(
                               new AutoScaleRunnable(initScale, x, y), 16);
                       isAutoScale = true;
                   }
                   return true;
               }
       });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
项目:DroidPlanner-Tower    文件:WheelScroller.java   
/**
 * Constructor
 * 
 * @param context
 *            the current context
 * @param listener
 *            the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call
            // immediately
            // when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:Gprs_droidplanner    文件:WheelScroller.java   
/**
 * Constructor
 * 
 * @param context
 *            the current context
 * @param listener
 *            the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call
            // immediately
            // when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:hamsi-wallpaper-slideshow    文件:HamsiWallpaperSlideshow.java   
WallpaperEngine() {
    try {
        final Paint paint = mPaint;
        paint.setColor(Color.WHITE);
        paint.setTextAlign(Paint.Align.CENTER);
        paint.setAntiAlias(true);
        paint.setTextSize(18f);

        mPrefs = getSharedPreferences(SHARED_PREFS_NAME, 0);
        mPrefs.registerOnSharedPreferenceChangeListener(this);

        // Read the preferences
        onSharedPreferenceChanged(mPrefs, null);
        if (Build.VERSION.SDK_INT >= 15 ) {
            setOffsetNotificationsEnabled(true);
        }
        setTouchEventsEnabled(true);
    } catch (Exception ex) {
        Log.e("HamsiWallpaperSlideshow", "WallpaperEngine: ", ex);
    }

    doubleTapDetector = new GestureDetector(HamsiWallpaperSlideshow.this, new SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            try {
                if (mTouchEvents) {
                    mLastDrawTime = 0;
                    drawFrame(false, true);
                    return true;
                }
            } catch (Exception ex) {
                Log.e("HamsiWallpaperSlideshow", "doubleTapDetector:onDoubleTap: ", ex);
            }
            return false;
        }
    });
}
项目:MedicationReminder    文件:SwipeMenuLayout.java   
private void init() {
    setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    mGestureListener = new SimpleOnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2,
                                  float velocityX, float velocityY) {
            // TODO
            if (Math.abs(e1.getX() - e2.getX()) > MIN_FLING
                    && velocityX < MAX_VELOCITYX) {
                isFling = true;
            }
            // Log.i("byz", MAX_VELOCITYX + ", velocityX = " + velocityX);
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    };
    mGestureDetector = new GestureDetectorCompat(getContext(),
            mGestureListener);

    // mScroller = ScrollerCompat.create(getContext(), new
    // BounceInterpolator());
    if (mCloseInterpolator != null) {
        mCloseScroller = ScrollerCompat.create(getContext(),
                mCloseInterpolator);
    } else {
        mCloseScroller = ScrollerCompat.create(getContext());
    }
    if (mOpenInterpolator != null) {
        mOpenScroller = ScrollerCompat.create(getContext(),
                mOpenInterpolator);
    } else {
        mOpenScroller = ScrollerCompat.create(getContext());
    }

    LayoutParams contentParams = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContentView.setLayoutParams(contentParams);
    if (mContentView.getId() < 1) {
        mContentView.setId(CONTENT_VIEW_ID);
    }

    mMenuView.setId(MENU_VIEW_ID);
    mMenuView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));

    addView(mContentView);
    addView(mMenuView);

    // if (mContentView.getBackground() == null) {
    // mContentView.setBackgroundColor(Color.WHITE);
    // }

    // in android 2.x, MenuView height is MATCH_PARENT is not work.
    // getViewTreeObserver().addOnGlobalLayoutListener(
    // new OnGlobalLayoutListener() {
    // @Override
    // public void onGlobalLayout() {
    // setMenuHeight(mContentView.getHeight());
    // // getViewTreeObserver()
    // // .removeGlobalOnLayoutListener(this);
    // }
    // });

}
项目:SuperSelector    文件:ActionSheet.java   
protected void initialize() {
    maskView = new MaskView(getContext(), this);
    maskView.setCanCancel(true);
    maskView.setDurationMillis(durationMillis);
    maskView.setOnMaskListener(new MaskView.MaskListener() {
        @Override
        public void onShow() {
        }

        @Override
        public void onHide() {
            hide();
        }
    });

    actionSheetView = new LinearLayout(getContext());
    actionSheetView.setOrientation(LinearLayout.VERTICAL);
    // actionSheetView.setBackgroundResource(R.drawable.actionsheet_background);
    // actionSheetView.setBackgroundResource(R.color.white);
    actionSheetView.setVisibility(View.GONE);
    LayoutParams rlp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    rlp.leftMargin = rlp.rightMargin = (int)applyDimension(getContext(), TypedValue.COMPLEX_UNIT_DIP, 8);
    addView(actionSheetView, rlp);

    windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    gestureDetector = new GestureDetector(getContext(), new SimpleOnGestureListener() {
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            hide();
            return super.onSingleTapUp(e);
        }
    });
    setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (KeyEvent.KEYCODE_BACK == keyCode && KeyEvent.ACTION_DOWN == event.getAction()) {
                hide();
                return true;
            }
            return false;
        }
    });
    setFocusable(true);
    setFocusableInTouchMode(true);
}
项目:GongXianSheng    文件:SwipeMenuLayout.java   
private void init() {
    setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    mGestureListener = new SimpleOnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2,
                                  float velocityX, float velocityY) {
            // TODO
            if ((e1.getX() - e2.getX()) > MIN_FLING
                    && velocityX < MAX_VELOCITYX) {
                isFling = true;
            }
            // Log.i("byz", MAX_VELOCITYX + ", velocityX = " + velocityX);
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    };
    mGestureDetector = new GestureDetectorCompat(getContext(),
            mGestureListener);

    // mScroller = ScrollerCompat.create(getContext(), new
    // BounceInterpolator());
    if (mCloseInterpolator != null) {
        mCloseScroller = ScrollerCompat.create(getContext(),
                mCloseInterpolator);
    } else {
        mCloseScroller = ScrollerCompat.create(getContext());
    }
    if (mOpenInterpolator != null) {
        mOpenScroller = ScrollerCompat.create(getContext(),
                mOpenInterpolator);
    } else {
        mOpenScroller = ScrollerCompat.create(getContext());
    }

    LayoutParams contentParams = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContentView.setLayoutParams(contentParams);
    if (mContentView.getId() < 1) {
        mContentView.setId(CONTENT_VIEW_ID);
    }

    mMenuView.setId(MENU_VIEW_ID);
    mMenuView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));

    addView(mContentView);
    addView(mMenuView);

    // if (mContentView.getBackground() == null) {
    // mContentView.setBackgroundColor(Color.WHITE);
    // }

    // in android 2.x, MenuView height is MATCH_PARENT is not work.
    // getViewTreeObserver().addOnGlobalLayoutListener(
    // new OnGlobalLayoutListener() {
    // @Override
    // public void onGlobalLayout() {
    // setMenuHeight(mContentView.getHeight());
    // // getViewTreeObserver()
    // // .removeGlobalOnLayoutListener(this);
    // }
    // });

}
项目:RoadLab-Pro    文件:SwipeMenuLayout.java   
private void init() {
    setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    mGestureListener = new SimpleOnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2,
                float velocityX, float velocityY) {
            if ((e1.getX() - e2.getX()) > MIN_FLING
                    && velocityX < MAX_VELOCITYX) {
                isFling = true;
            }
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    };
    mGestureDetector = new GestureDetectorCompat(getContext(),
            mGestureListener);
    if (mCloseInterpolator != null) {
        mCloseScroller = ScrollerCompat.create(getContext(),
                mCloseInterpolator);
    } else {
        mCloseScroller = ScrollerCompat.create(getContext());
    }
    if (mOpenInterpolator != null) {
        mOpenScroller = ScrollerCompat.create(getContext(),
                mOpenInterpolator);
    } else {
        mOpenScroller = ScrollerCompat.create(getContext());
    }

    LayoutParams contentParams = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContentView.setLayoutParams(contentParams);
    if (mContentView.getId() < 1) {
        mContentView.setId(CONTENT);
    }

    mMenuView.setId(MENU);
    mMenuView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));

    addView(mContentView);
    addView(mMenuView);

    // if (mContentView.getBackground() == null) {
    // mContentView.setBackgroundColor(Color.WHITE);
    // }

    // in android 2.x, MenuView height is MATCH_PARENT is not work.
    // getViewTreeObserver().addOnGlobalLayoutListener(
    // new OnGlobalLayoutListener() {
    // @Override
    // public void onGlobalLayout() {
    // setMenuHeight(mContentView.getHeight());
    // // getViewTreeObserver()
    // // .removeGlobalOnLayoutListener(this);
    // }
    // });

}
项目:clip-image    文件:ClipImageView.java   
public ClipImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale)
                        return true;

                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < mScaleMin) {
                        ClipImageView.this.postDelayed(new AutoScaleRunnable(mScaleMin, x, y), 16);
                    } else {
                        ClipImageView.this.postDelayed(new AutoScaleRunnable(mInitScale, x, y), 16);
                    }
                    isAutoScale = true;

                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(Color.WHITE);

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ClipImageView);
    mAspectX = ta.getInteger(R.styleable.ClipImageView_civWidth, 1);
    mAspectY = ta.getInteger(R.styleable.ClipImageView_civHeight, 1);
    mClipPadding = ta.getDimensionPixelSize(R.styleable.ClipImageView_civClipPadding, 0);
    mTipText = ta.getString(R.styleable.ClipImageView_civTipText);
    mMaskColor = ta.getColor(R.styleable.ClipImageView_civMaskColor, 0xB2000000);
    mDrawCircleFlag = ta.getBoolean(R.styleable.ClipImageView_civClipCircle, false);
    mRoundCorner = ta.getDimension(R.styleable.ClipImageView_civClipRoundCorner, 0);
    final int textSize = ta.getDimensionPixelSize(R.styleable.ClipImageView_civTipTextSize, 24);
    mPaint.setTextSize(textSize);
    ta.recycle();

    mPaint.setDither(true);
}
项目:SwipeMenuAndRefresh    文件:SwipeMenuLayout.java   
private void init() {
    setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    mGestureListener = new SimpleOnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2,
                               float velocityX, float velocityY) {
            // TODO
            if (Math.abs(e1.getX() - e2.getX()) > MIN_FLING
                    && velocityX < MAX_VELOCITYX) {
                isFling = true;
            }
            // Log.i("byz", MAX_VELOCITYX + ", velocityX = " + velocityX);
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    };
    mGestureDetector = new GestureDetectorCompat(getContext(),
            mGestureListener);

    // mScroller = ScrollerCompat.create(getContext(), new
    // BounceInterpolator());
    if (mCloseInterpolator != null) {
        mCloseScroller = ScrollerCompat.create(getContext(),
                mCloseInterpolator);
    } else {
        mCloseScroller = ScrollerCompat.create(getContext());
    }
    if (mOpenInterpolator != null) {
        mOpenScroller = ScrollerCompat.create(getContext(),
                mOpenInterpolator);
    } else {
        mOpenScroller = ScrollerCompat.create(getContext());
    }

    LayoutParams contentParams = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContentView.setLayoutParams(contentParams);
    if (mContentView.getId() < 1) {
        mContentView.setId(CONTENT_VIEW_ID);
    }

    mMenuView.setId(MENU_VIEW_ID);
    mMenuView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            mContentView.getHeight()));

    addView(mContentView);
    addView(mMenuView);

    // if (mContentView.getBackground() == null) {
    // mContentView.setBackgroundColor(Color.WHITE);
    // }

    // in android 2.x, MenuView height is MATCH_PARENT is not work.
    // getViewTreeObserver().addOnGlobalLayoutListener(
    // new OnGlobalLayoutListener() {
    // @Override
    // public void onGlobalLayout() {
    // setMenuHeight(mContentView.getHeight());
    // // getViewTreeObserver()
    // // .removeGlobalOnLayoutListener(this);
    // }
    // });

}
项目:HttpRequest    文件:ZoomImageView.java   
public ZoomImageView(Context context, AttributeSet attrs)
{
    super(context, attrs);
    super.setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener()
            {
                @Override
                public boolean onSingleTapConfirmed(MotionEvent e) {
                    RectF rectF = getMatrixRectF();
                    onSingleTouchListener.onSingleTouch();
                    if(rectF.width() > getWidth() || rectF.height() > getHeight()){
                        getParent().requestDisallowInterceptTouchEvent(true);
                    }
                    return true;
                }

                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale == true)
                        return true;
                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < SCALE_MID) {
                        ZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(SCALE_MID, x, y), 16);
                        isAutoScale = true;
                    } else if (getScale() >= SCALE_MID
                            && getScale() < SCALE_MAX) {
                        ZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(SCALE_MAX, x, y), 16);
                        isAutoScale = true;
                    } else {
                        ZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(initScale, x, y), 16);
                        isAutoScale = true;
                    }

                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
项目:HPlayer    文件:SwipeMenuLayout.java   
private void init() {
    setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    mGestureListener = new SimpleOnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2,
                float velocityX, float velocityY) {
            // TODO
            if (Math.abs(e1.getX() - e2.getX()) > MIN_FLING
                    && velocityX < MAX_VELOCITYX) {
                isFling = true;
            }
            // Log.i("byz", MAX_VELOCITYX + ", velocityX = " + velocityX);
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    };
    mGestureDetector = new GestureDetectorCompat(getContext(),
            mGestureListener);

    // mScroller = ScrollerCompat.create(getContext(), new
    // BounceInterpolator());
    if (mCloseInterpolator != null) {
        mCloseScroller = ScrollerCompat.create(getContext(),
                mCloseInterpolator);
    } else {
        mCloseScroller = ScrollerCompat.create(getContext());
    }
    if (mOpenInterpolator != null) {
        mOpenScroller = ScrollerCompat.create(getContext(),
                mOpenInterpolator);
    } else {
        mOpenScroller = ScrollerCompat.create(getContext());
    }

    LayoutParams contentParams = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContentView.setLayoutParams(contentParams);
    if (mContentView.getId() < 1) {
        mContentView.setId(CONTENT_VIEW_ID);
    }

    mMenuView.setId(MENU_VIEW_ID);
    mMenuView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));

    addView(mContentView);
    addView(mMenuView);

    // if (mContentView.getBackground() == null) {
    // mContentView.setBackgroundColor(Color.WHITE);
    // }

    // in android 2.x, MenuView height is MATCH_PARENT is not work.
    // getViewTreeObserver().addOnGlobalLayoutListener(
    // new OnGlobalLayoutListener() {
    // @Override
    // public void onGlobalLayout() {
    // setMenuHeight(mContentView.getHeight());
    // // getViewTreeObserver()
    // // .removeGlobalOnLayoutListener(this);
    // }
    // });

}
项目:MapForTour    文件:SwipeMenuLayout.java   
private void init() {
    setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    mGestureListener = new SimpleOnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2,
                float velocityX, float velocityY) {
            // TODO
            if (Math.abs(e1.getX() - e2.getX()) > MIN_FLING
                    && velocityX < MAX_VELOCITYX) {
                isFling = true;
            }
            // Log.i("byz", MAX_VELOCITYX + ", velocityX = " + velocityX);
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    };
    mGestureDetector = new GestureDetectorCompat(getContext(),
            mGestureListener);

    // mScroller = ScrollerCompat.create(getContext(), new
    // BounceInterpolator());
    if (mCloseInterpolator != null) {
        mCloseScroller = ScrollerCompat.create(getContext(),
                mCloseInterpolator);
    } else {
        mCloseScroller = ScrollerCompat.create(getContext());
    }
    if (mOpenInterpolator != null) {
        mOpenScroller = ScrollerCompat.create(getContext(),
                mOpenInterpolator);
    } else {
        mOpenScroller = ScrollerCompat.create(getContext());
    }

    LayoutParams contentParams = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContentView.setLayoutParams(contentParams);
    if (mContentView.getId() < 1) {
        mContentView.setId(CONTENT_VIEW_ID);
    }

    mMenuView.setId(MENU_VIEW_ID);
    mMenuView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));

    addView(mContentView);
    addView(mMenuView);

    // if (mContentView.getBackground() == null) {
    // mContentView.setBackgroundColor(Color.WHITE);
    // }

    // in android 2.x, MenuView height is MATCH_PARENT is not work.
    // getViewTreeObserver().addOnGlobalLayoutListener(
    // new OnGlobalLayoutListener() {
    // @Override
    // public void onGlobalLayout() {
    // setMenuHeight(mContentView.getHeight());
    // // getViewTreeObserver()
    // // .removeGlobalOnLayoutListener(this);
    // }
    // });

}