当前位置: 首页>>代码示例>>Java>>正文


Java SimpleOnGestureListener类代码示例

本文整理汇总了Java中android.view.GestureDetector.SimpleOnGestureListener的典型用法代码示例。如果您正苦于以下问题:Java SimpleOnGestureListener类的具体用法?Java SimpleOnGestureListener怎么用?Java SimpleOnGestureListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SimpleOnGestureListener类属于android.view.GestureDetector包,在下文中一共展示了SimpleOnGestureListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ClipZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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);
}
 
开发者ID:lingganhezi,项目名称:dedecmsapp,代码行数:27,代码来源:ClipZoomImageView.java

示例2: ZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:25,代码来源:ZoomImageView.java

示例3: init

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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());
}
 
开发者ID:PhongHuynh93,项目名称:SwipeMenuRecyclerView-master,代码行数:24,代码来源:SwipeMenuLayout.java

示例4: WheelScroller

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:vondear,项目名称:RxTools,代码行数:31,代码来源:WheelScroller.java

示例5: ZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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);
}
 
开发者ID:baiqiantao,项目名称:GestureDetectorTest,代码行数:23,代码来源:ZoomImageView.java

示例6: ClipRectZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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);
}
 
开发者ID:lingganhezi,项目名称:dedecmsapp,代码行数:27,代码来源:ClipRectZoomImageView.java

示例7: onDoubleTap

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:markzhai,项目名称:GitHubExplorer,代码行数:23,代码来源:Gestures.java

示例8: DragLayout

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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());
        }
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:14,代码来源:DragLayout.java

示例9: ZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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);
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:35,代码来源:ZoomImageView.java

示例10: ClipZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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);
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:30,代码来源:ClipZoomImageView.java

示例11: WheelScroller

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:35,代码来源:WheelScroller.java

示例12: startDelayConfirmation

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
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);
            }
        });
    }
}
 
开发者ID:mobvoi,项目名称:ticdesign,代码行数:38,代码来源:FloatingActionButton.java

示例13: SwipableOverlayView

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:20,代码来源:SwipableOverlayView.java

示例14: RecyclerItemClickListener

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
public RecyclerItemClickListener(Context context, OnItemClickListener onItemClickListener) {
	listener = onItemClickListener;

	gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
		@Override
		public boolean onSingleTapUp(MotionEvent e) {
			return true;
		}
	});
}
 
开发者ID:punchup,项目名称:Superuser-UI,代码行数:11,代码来源:RecyclerItemClickListener.java

示例15: ZoomCropImageView

import android.view.GestureDetector.SimpleOnGestureListener; //导入依赖的package包/类
@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);
}
 
开发者ID:CrazyOrr,项目名称:ZoomCropImage,代码行数:30,代码来源:ZoomCropImageView.java


注:本文中的android.view.GestureDetector.SimpleOnGestureListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。