本文整理汇总了Java中android.view.GestureDetector.SimpleOnGestureListener方法的典型用法代码示例。如果您正苦于以下问题:Java GestureDetector.SimpleOnGestureListener方法的具体用法?Java GestureDetector.SimpleOnGestureListener怎么用?Java GestureDetector.SimpleOnGestureListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.GestureDetector
的用法示例。
在下文中一共展示了GestureDetector.SimpleOnGestureListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PhotoViewAttacher
import android.view.GestureDetector; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
mImageView = new WeakReference<ImageView>(imageView);
imageView.setOnTouchListener(this);
mViewTreeObserver = imageView.getViewTreeObserver();
mViewTreeObserver.addOnGlobalLayoutListener(this);
// Make sure we using MATRIX Scale Type
setImageViewScaleTypeMatrix(imageView);
if (!imageView.isInEditMode()) {
// Create Gesture Detectors...
mScaleDragDetector = VersionedGestureDetector.newInstance(
imageView.getContext(), this);
mGestureDetector = new GestureDetector(imageView.getContext(),
new GestureDetector.SimpleOnGestureListener() {
// forward long click listener
@Override
public void onLongPress(MotionEvent e) {
if (null != mLongClickListener) {
mLongClickListener.onLongClick(mImageView.get());
}
}
});
mGestureDetector.setOnDoubleTapListener(this);
// Finally, update the UI so that we're zoomable
setZoomable(true);
}
}
示例2: FlingPlayBackController
import android.view.GestureDetector; //导入方法依赖的package包/类
public FlingPlayBackController(Context context) {
flingPlayBackController = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (Math.abs(velocityX) > Math.abs(velocityY)) {
if (velocityX < 0) {
MusicPlayerRemote.playNextSong();
return true;
} else if (velocityX > 0) {
MusicPlayerRemote.playPreviousSong();
return true;
}
}
return false;
}
});
}
示例3: PhotoViewAttacher
import android.view.GestureDetector; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
mImageView = new WeakReference<ImageView>(imageView);
imageView.setOnTouchListener(this);
mViewTreeObserver = imageView.getViewTreeObserver();
mViewTreeObserver.addOnGlobalLayoutListener(this);
// Make sure we using MATRIX Scale Type
setImageViewScaleTypeMatrix(imageView);
if (!imageView.isInEditMode()) {
// Create Gesture Detectors...
mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);
mGestureDetector = new GestureDetector(imageView.getContext(),
new GestureDetector.SimpleOnGestureListener() {
// forward long click listener
@Override
public void onLongPress(MotionEvent e) {
if (null != mLongClickListener) {
mLongClickListener.onLongClick(mImageView.get());
}
}
});
mGestureDetector.setOnDoubleTapListener(this);
// Finally, update the UI so that we're zoomable
setZoomable(true);
}
}
示例4: PhotoViewAttacher
import android.view.GestureDetector; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
mImageView = new WeakReference<ImageView>(imageView);
imageView.setOnTouchListener(this);
mViewTreeObserver = imageView.getViewTreeObserver();
mViewTreeObserver.addOnGlobalLayoutListener(this);
// Make sure we using MATRIX Scale Type
setImageViewScaleTypeMatrix(imageView);
if (!imageView.isInEditMode()) {
// Create Gesture Detectors...
mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);
mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() {
// forward long click listener
@Override
public void onLongPress(MotionEvent e) {
if (null != mLongClickListener) {
mLongClickListener.onLongClick(mImageView.get());
}
}
});
mGestureDetector.setOnDoubleTapListener(this);
// Finally, addOrUpdate the UI so that we're zoomable
setZoomable(true);
}
}
示例5: PhotoViewAttacher
import android.view.GestureDetector; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
mImageView = new WeakReference<ImageView>(imageView);
imageView.setDrawingCacheEnabled(true);
imageView.setOnTouchListener(this);
ViewTreeObserver observer = imageView.getViewTreeObserver();
if (null != observer)
observer.addOnGlobalLayoutListener(this);
// Make sure we using MATRIX Scale Type
setImageViewScaleTypeMatrix(imageView);
if (imageView.isInEditMode()) {
return;
}
// Create Gesture Detectors...
mScaleDragDetector = VersionedGestureDetector.newInstance(
imageView.getContext(), this);
mGestureDetector = new GestureDetector(imageView.getContext(),
new GestureDetector.SimpleOnGestureListener() {
// forward long click listener
@Override
public void onLongPress(MotionEvent e) {
try {
if (null != mLongClickListener) {
mLongClickListener.onLongClick(getImageView());
}
}catch (Exception exception){}
}
});
mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
// Finally, update the UI so that we're zoomable
setZoomable(true);
}
示例6: PhotoViewAttacher
import android.view.GestureDetector; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
mImageView = new WeakReference<ImageView>(imageView);
imageView.setOnTouchListener(this);
mViewTreeObserver = imageView.getViewTreeObserver();
mViewTreeObserver.addOnGlobalLayoutListener(this);
// Make sure we using MATRIX Scale Type
setImageViewScaleTypeMatrix(imageView);
if (!imageView.isInEditMode()) {
// Create Gesture Detectors...
mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);
mGestureDetector = new GestureDetector(imageView.getContext(),
new GestureDetector.SimpleOnGestureListener() {
// forward long click listener
@Override
public void onLongPress(MotionEvent e) {
if (null != mLongClickListener) {
mLongClickListener.onLongClick(mImageView.get());
}
}
});
mGestureDetector.setOnDoubleTapListener(this);
// Finally, update the UI so that we're zoomable
setZoomable(true);
}
}
示例7: setFilingGesture
import android.view.GestureDetector; //导入方法依赖的package包/类
private void setFilingGesture(Context context) {
mFlingDetector = new GestureDetector(context,new GestureDetector.SimpleOnGestureListener(){
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (mTranslateEnabled && mReadySent && mViewTranslate != null && e1 != null && e2 != null
&& (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50)
&& (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500) && !mIsZooming) {
PointF vTranslateEnd =
new PointF(mViewTranslate.x + (velocityX * 0.25f), mViewTranslate.y + (velocityY * 0.25f));
float sCenterXEnd = ((getWidth() / 2.0F) - vTranslateEnd.x) / mScale;
float sCenterYEnd = ((getHeight() / 2.0F) - vTranslateEnd.y) / mScale;
startFilingAnimation(sCenterXEnd, sCenterYEnd);
if (BuildConfig.DEBUG) Log.d(TAG, "onFling: 正在滑行");
return true;
}
return false;
}
});
}
示例8: initGestureDetector
import android.view.GestureDetector; //导入方法依赖的package包/类
private void initGestureDetector() {
//手势处理
mGestureDetector = new GestureDetector(getContext(),
new GestureDetector.SimpleOnGestureListener(){
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (mOnItemClickListener!=null){
if (mAdapter instanceof LoopPagerAdapter){
int i = mViewPager.getCurrentItem() % ((LoopPagerAdapter) mAdapter)
.getRealCount();
mOnItemClickListener.onItemClick(i);
}else {
mOnItemClickListener.onItemClick(mViewPager.getCurrentItem());
}
}
return super.onSingleTapUp(e);
}
});
}
示例9: RecyclerItemClickListener
import android.view.GestureDetector; //导入方法依赖的package包/类
public RecyclerItemClickListener(Context context, OnItemClickListener listener) {
mListener = listener;
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
}
示例10: init
import android.view.GestureDetector; //导入方法依赖的package包/类
private void init() {
inflate(getContext(), R.layout.image_viewer, this);
backgroundView = findViewById(R.id.backgroundView);
pager = (MultiTouchViewPager) findViewById(R.id.pager);
dismissContainer = (ViewGroup) findViewById(R.id.container);
swipeDismissListener = new SwipeToDismissListener(findViewById(R.id.dismissView), this, this);
dismissContainer.setOnTouchListener(swipeDismissListener);
directionDetector = new SwipeDirectionDetector(getContext()) {
@Override
public void onDirectionDetected(Direction direction) {
ImageViewerView.this.direction = direction;
}
};
scaleDetector = new ScaleGestureDetector(getContext(),
new ScaleGestureDetector.SimpleOnScaleGestureListener());
gestureDetector = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if (pager.isScrolled()) {
onClick(e, isOverlayWasClicked);
}
return false;
}
});
}
示例11: OnItemSelectedListener
import android.view.GestureDetector; //导入方法依赖的package包/类
protected OnItemSelectedListener(Context context) {
gestureDetector = new GestureDetector(context,
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
}
示例12: CustomTouchListener
import android.view.GestureDetector; //导入方法依赖的package包/类
public CustomTouchListener(Context context, final OnItemClickListener clickListener) {
this.clickListener = clickListener;
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
}
示例13: TabItemView
import android.view.GestureDetector; //导入方法依赖的package包/类
public TabItemView(Context context) {
super(context);
mTextView = new InnerTextView(getContext());
mTextView.setSingleLine(true);
mTextView.setGravity(Gravity.CENTER);
mTextView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
// 用于提供给customView布局用
mTextView.setId(R.id.qmui_tab_segment_item_id);
RelativeLayout.LayoutParams tvLp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
tvLp.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
addView(mTextView, tvLp);
// 添加双击事件
mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
if (mSelectedListeners == null) {
return false;
} else {
if (mIsAnimating) {
return false;
}
int index = (int) TabItemView.this.getTag();
Tab model = getAdapter().getItem(index);
if (model != null) {
dispatchTabDoubleTap(index);
return true;
}
return false;
}
}
});
}
示例14: OnItemTouchListener
import android.view.GestureDetector; //导入方法依赖的package包/类
public OnItemTouchListener(Context context, OnItemClickListener listener) {
mListener = listener;
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
}
示例15: setLongPress
import android.view.GestureDetector; //导入方法依赖的package包/类
private void setLongPress(Context context) {
mLongPressDetector = new GestureDetector(context,new GestureDetector.SimpleOnGestureListener(){
@Override
public void onLongPress(MotionEvent e) {
if (isLongClickable() && mOnLongClickListener != null){
mOnLongClickListener.onLongClick(HDImageView.this);
}
super.onLongPress(e);
}
});
}