本文整理汇总了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);
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
});
}
}
示例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);
}
示例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;
}
});
}
示例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);
}