本文整理匯總了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);
}