Java Code Examples for android.view.GestureDetector#setOnDoubleTapListener()
The following examples show how to use
android.view.GestureDetector#setOnDoubleTapListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapView.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
public MapView( Context context, MapDrawable map) { super(context, map); setLayerType(View.LAYER_TYPE_HARDWARE, null); mGestureDetector = new GestureDetector(context, this); mGestureDetector.setOnDoubleTapListener(this); mScaleGestureDetector = new ScaleGestureDetector(getContext(), this); mScroller = new Scroller(context); mStartMouseLocation = new PointF(); mCurrentMouseOffset = new PointF(); mCurrentFocusLocation = new PointF(); mDrawingState = DRAW_STATE_drawing_noclearbk; }
Example 2
Source File: AbstractViewQuery.java From COCOQuery with Apache License 2.0 | 6 votes |
/** * Register listener on double-tap gesture for view * * @param listener * @return view */ public T doubleTap(final GestureDetector.OnDoubleTapListener listener) { if (view != null) { final GestureDetector detector = new GestureDetector(view.getContext(), new GestureDetector.SimpleOnGestureListener()); detector.setOnDoubleTapListener(listener); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return detector.onTouchEvent(event); } }); } return self(); }
Example 3
Source File: CropView.java From ImagePicker with Apache License 2.0 | 6 votes |
public CropView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setScaleType(ScaleType.MATRIX); mDragScaleDetector = VersionedGestureDetector.newInstance(context, this); mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener()); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener()); outlinePaint.setAntiAlias(true); outlinePaint.setColor(highlightColor); outlinePaint.setStyle(Paint.Style.STROKE); outlinePaint.setStrokeWidth(dpToPx(OUTLINE_DP)); outsidePaint.setARGB(125, 50, 50, 50); ViewTreeObserver observer = getViewTreeObserver(); if (null != observer) { observer.addOnGlobalLayoutListener(this); } }
Example 4
Source File: GestureActivity.java From android-test with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.gesture_activity); gestureArea = findViewById(R.id.gesture_area); final GestureDetector simpleDetector = new GestureDetector(this, new GestureListener()); simpleDetector.setIsLongpressEnabled(true); simpleDetector.setOnDoubleTapListener(new DoubleTapListener()); gestureArea.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent m) { boolean res = simpleDetector.onTouchEvent(m); if (-1 != touchDelay) { Log.i(TAG, "sleeping for: " + touchDelay); SystemClock.sleep(touchDelay); } return res; } }); }
Example 5
Source File: ZoomImageView.java From Gank-Veaer with GNU General Public License v3.0 | 5 votes |
public MultiGestureDetector(Context context) { scaleGestureDetector = new ScaleGestureDetector(context, this); gestureDetector = new GestureDetector(context, this); gestureDetector.setOnDoubleTapListener(this); final ViewConfiguration configuration = ViewConfiguration.get(context); scaledMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); scaledTouchSlop = configuration.getScaledTouchSlop(); }
Example 6
Source File: PhotoViewAttacher.java From iBeebo with GNU General Public License v3.0 | 5 votes |
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); } }
Example 7
Source File: PhotoViewAttacher.java From Favorite-Android-Client with Apache License 2.0 | 5 votes |
public PhotoViewAttacher(ImageView imageView) { mImageView = new WeakReference<ImageView>(imageView); 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) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(this); // Finally, update the UI so that we're zoomable setZoomable(true); }
Example 8
Source File: PhotoViewAttacher.java From jmessage-android-uikit with MIT License | 5 votes |
public PhotoViewAttacher(ImageView imageView, boolean fromChatActivity, Context context) { mImageView = new WeakReference<ImageView>(imageView); mFromChatActivity = fromChatActivity; mContext = context; 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); } }
Example 9
Source File: ZoomImageView.java From Theogony with MIT License | 5 votes |
public MultiGestureDetector(Context context) { scaleGestureDetector = new ScaleGestureDetector(context, this); gestureDetector = new GestureDetector(context, this); gestureDetector.setOnDoubleTapListener(this); final ViewConfiguration configuration = ViewConfiguration.get(context); scaledMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); scaledTouchSlop = configuration.getScaledTouchSlop(); }
Example 10
Source File: ClipImageView.java From RelaxFinger with GNU General Public License v2.0 | 5 votes |
public MultiGestureDetector(Context context) { scaleGestureDetector = new ScaleGestureDetector(context, this); gestureDetector = new GestureDetector(context, this); gestureDetector.setOnDoubleTapListener(this); final ViewConfiguration configuration = ViewConfiguration .get(context); scaledTouchSlop = configuration.getScaledTouchSlop(); }
Example 11
Source File: PhotoViewAttacher.java From android-discourse with Apache License 2.0 | 5 votes |
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); } }
Example 12
Source File: PhotoViewAttacher.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
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) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); // Finally, update the UI so that we're zoomable setZoomable(true); }
Example 13
Source File: PhotoViewAttacher.java From zen4android with MIT License | 5 votes |
public PhotoViewAttacher(ImageView imageView) { mImageView = new WeakReference<ImageView>(imageView); 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) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(this); // Finally, update the UI so that we're zoomable setZoomable(true); }
Example 14
Source File: PhotoViewAttacher.java From Nimingban with Apache License 2.0 | 5 votes |
public PhotoViewAttacher(ImageView imageView, boolean zoomable) { mImageView = new WeakReference<>(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) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); mRotateGestureDetector = new RotateGestureDetector(imageView.getContext(), this); // Finally, update the UI so that we're zoomable setZoomable(zoomable); }
Example 15
Source File: VideoContainerGestureDetector.java From sealrtc-android with MIT License | 5 votes |
private void init(Context context) { matrix = new Matrix(); boxMargin = new Rect(); // scaleTrans.x = 0f; // scaleTrans.y = 0f; scaleGestureAble = true; checkBox = true; scrolling = false; translateGestureAble = true; mScaleGesture = new ScaleGestureDetector(context, this); mGesture = new GestureDetector(context, this); mGesture.setOnDoubleTapListener(this); gestureAble = true; }
Example 16
Source File: ZoomImageView.java From ZoomImageView with Apache License 2.0 | 5 votes |
public MultiGestureDetector(Context context) { scaleGestureDetector = new ScaleGestureDetector(context, this); gestureDetector = new GestureDetector(context, this); gestureDetector.setOnDoubleTapListener(this); final ViewConfiguration configuration = ViewConfiguration.get(context); scaledMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); scaledTouchSlop = configuration.getScaledTouchSlop(); }
Example 17
Source File: PhotoViewAttacher.java From BlackLight with GNU General Public License v3.0 | 5 votes |
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) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); // Finally, update the UI so that we're zoomable setZoomable(true); }
Example 18
Source File: PhotoViewAttacher.java From ZoomPreviewPicture with Apache License 2.0 | 4 votes |
public PhotoViewAttacher(ImageView imageView, boolean zoomable) { mImageView = new WeakReference<>(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) { if (null != mLongClickListener&&getImageView().getY()==0&& getImageView().getX()==0) { mLongClickListener.onLongClick(getImageView()); } } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mSingleFlingListener != null) { if (getScale() > DEFAULT_MIN_SCALE) { return false; } if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) { return false; } return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY); } return false; } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); mBaseRotation = 0.0f; // Finally, update the UI so that we're zoomable setZoomable(zoomable); }
Example 19
Source File: PhotoViewAttacher.java From AndroidPickPhotoDialog with Apache License 2.0 | 4 votes |
public PhotoViewAttacher(ImageView imageView, boolean zoomable) { mImageView = new WeakReference<>(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) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mSingleFlingListener != null) { if (getScale() > DEFAULT_MIN_SCALE) { return false; } if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) { return false; } return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY); } return false; } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); mBaseRotation = 0.0f; // Finally, update the UI so that we're zoomable setZoomable(zoomable); }
Example 20
Source File: PhotoViewAttacher.java From Album with Apache License 2.0 | 4 votes |
public PhotoViewAttacher(ImageView imageView, boolean zoomable) { mImageView = new WeakReference<>(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) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mSingleFlingListener != null) { if (getScale() > DEFAULT_MIN_SCALE) { return false; } if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) { return false; } return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY); } return false; } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); mBaseRotation = 0.0f; // Finally, update the UI so that we're zoomable setZoomable(zoomable); }