android.view.GestureDetector Java Examples
The following examples show how to use
android.view.GestureDetector.
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: CropImageView.java From YImagePicker with Apache License 2.0 | 6 votes |
private void init() { super.setScaleType(ScaleType.MATRIX); if (mScaleType == null) mScaleType = ScaleType.CENTER_CROP; mRotateDetector = new RotateGestureDetector(mRotateListener); mDetector = new GestureDetector(getContext(), mGestureListener); mScaleDetector = new ScaleGestureDetector(getContext(), mScaleListener); float density = getResources().getDisplayMetrics().density; MAX_FLING_OVER_SCROLL = (int) (density * 30); MAX_OVER_RESISTANCE = (int) (density * 140); mMinRotate = MIN_ROTATE; mAnimDuring = ANIM_DURING; mMaxScale = MAX_SCALE; initCropLineRect(); initCropRect(); }
Example #2
Source File: TouchImageView.java From touch-image-view with MIT License | 6 votes |
@Override protected GestureDetector.OnGestureListener getGestureListener() { return new ImageViewTouch.GestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { mUserScaled = true; float scale = getScale(); float targetScale = onDoubleTapPost(scale, getMaxScale(), getMinScale()); targetScale = Math.min(getMaxScale(), Math.max(targetScale, getMinScale())); zoomTo(targetScale, e.getX(), e.getY(), (long) mDefaultAnimationDuration); if (null != mDoubleTapListener) { mDoubleTapListener.onDoubleTap(); } return false; } }; }
Example #3
Source File: TouchImageView.java From MarkdownEditors with Apache License 2.0 | 6 votes |
private void sharedConstructing(Context context) { super.setClickable(true); this.context = context; mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); matrix = new Matrix(); prevMatrix = new Matrix(); m = new float[9]; normalizedScale = 1; if (mScaleType == null) { mScaleType = ScaleType.FIT_CENTER; } minScale = 1; maxScale = 3; superMinScale = SUPER_MIN_MULTIPLIER * minScale; superMaxScale = SUPER_MAX_MULTIPLIER * maxScale; setImageMatrix(matrix); setScaleType(ScaleType.MATRIX); setState(State.NONE); onDrawReady = false; super.setOnTouchListener(new PrivateOnTouchListener()); }
Example #4
Source File: HighlightEditor.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
private void setup(Context context) { this.mContext = context; lineUtils = new LineUtils(); mPaintNumbers = new Paint(); mPaintNumbers.setColor(getResources().getColor(R.color.color_number_color)); mPaintNumbers.setAntiAlias(true); mPaintHighlight = new Paint(); mScale = context.getResources().getDisplayMetrics().density; mPadding = (int) (mPaddingDP * mScale); mHighlightedLine = mHighlightStart = -1; mDrawingRect = new Rect(); mLineBounds = new Rect(); mGestureDetector = new GestureDetector(getContext(), HighlightEditor.this); mChangeListener = new EditTextChangeListener(); mBracketHighlighter = new BracketHighlighter(this, codeTheme); updateFromSettings(); enableTextChangedListener(); }
Example #5
Source File: DragSortController.java From onpc with GNU General Public License v3.0 | 6 votes |
/** * By default, sorting is enabled, and removal is disabled. * * @param dslv The DSLV instance * @param dragHandleId The resource id of the View that represents * the drag handle in a list item. */ DragSortController(DragSortListView dslv, int dragHandleId, int dragInitMode, int removeMode, int clickRemoveId, int flingHandleId) { super(dslv); mDslv = dslv; mDetector = new GestureDetector(dslv.getContext(), this); mFlingRemoveDetector = new GestureDetector(dslv.getContext(), mFlingRemoveListener); mFlingRemoveDetector.setIsLongpressEnabled(false); mTouchSlop = ViewConfiguration.get(dslv.getContext()).getScaledTouchSlop(); mDragHandleId = dragHandleId; mClickRemoveId = clickRemoveId; mFlingHandleId = flingHandleId; setRemoveMode(removeMode); setDragInitMode(dragInitMode); }
Example #6
Source File: TouchImageView.java From TiTouchImageView with MIT License | 6 votes |
private void sharedConstructing(Context context) { super.setClickable(true); this.context = context; mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); matrix = new Matrix(); prevMatrix = new Matrix(); m = new float[9]; normalizedScale = 1; if (mScaleType == null) { mScaleType = ScaleType.FIT_CENTER; } minScale = 1; maxScale = 3; superMinScale = SUPER_MIN_MULTIPLIER * minScale; superMaxScale = SUPER_MAX_MULTIPLIER * maxScale; setImageMatrix(matrix); setScaleType(ScaleType.MATRIX); setState(State.NONE); onDrawReady = false; super.setOnTouchListener(new PrivateOnTouchListener()); }
Example #7
Source File: EntityView.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public EntityView(Context context, Point pos) { super(context); uuid = UUID.randomUUID(); position = pos; gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { public void onLongPress(MotionEvent e) { if (hasPanned || hasTransformed || hasReleased) { return; } recognizedLongPress = true; if (delegate != null) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); delegate.onEntityLongClicked(EntityView.this); } } }); }
Example #8
Source File: WXSlider.java From ucar-weex-core with Apache License 2.0 | 6 votes |
private void hackTwoItemsInfiniteScroll() { if (mViewPager == null || mAdapter == null) { return; } if (isInfinite) { if (mAdapter.getRealCount() == 2) { final GestureDetector gestureDetector = new GestureDetector(getContext(), new FlingGestureListener(mViewPager)); mViewPager.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }); } else { mViewPager.setOnTouchListener(null); } } }
Example #9
Source File: CompassView.java From CompassView with Apache License 2.0 | 6 votes |
private void init() { mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setTextAlign(Paint.Align.CENTER); mMainLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mMainLinePaint.setStrokeWidth(8f); mSecondaryLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mSecondaryLinePaint.setStrokeWidth(6f); mTerciaryLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTerciaryLinePaint.setStrokeWidth(3f); mMarkerPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mMarkerPaint.setStyle(Paint.Style.FILL); pathMarker = new Path(); mDetector = new GestureDetector(getContext(), new mGestureListener()); }
Example #10
Source File: OverlayPanelEventFilter.java From delion with Apache License 2.0 | 6 votes |
/** * Creates a {@link GestureEventFilter} with offset touch events. * @param context The {@link Context} for Android. * @param host The {@link EventFilterHost} for this event filter. * @param panelManager The {@link OverlayPanelManager} responsible for showing panels. */ public OverlayPanelEventFilter(Context context, EventFilterHost host, OverlayPanel panel) { super(context, host, panel, false, false); mGestureDetector = new GestureDetector(context, new InternalGestureDetector()); mPanel = panel; mSwipeRecognizer = new SwipeRecognizerImpl(context); // Store the square of the platform touch slop in pixels to use in the scroll detection. // See {@link OverlayPanelEventFilter#isDistanceGreaterThanTouchSlop}. float touchSlopPx = ViewConfiguration.get(context).getScaledTouchSlop(); mTouchSlopSquarePx = touchSlopPx * touchSlopPx; reset(); }
Example #11
Source File: TipsFloatView.java From imsdk-android with MIT License | 6 votes |
private void init(Context context){ gestureDetector = new GestureDetector(context, this); View view = LayoutInflater.from(context).inflate(R.layout.atom_ui_view_search_line,null); text = (TextView) view.findViewById(R.id.text); int size = Utils.dipToPixels(context, 40); setOrientation(LinearLayout.HORIZONTAL); setGravity(Gravity.CENTER_VERTICAL); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.setMargins(0, size * 4, 0, 0); setLayoutParams(layoutParams); addView(view); }
Example #12
Source File: BarcodeCaptureFragment.java From MVBarcodeReader with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View content = inflater.inflate(R.layout.barcode_capture, container, false); mPreview = content.findViewById(R.id.preview); mGraphicOverlay = content.findViewById(R.id.graphicOverlay); topLayout = content.findViewById(R.id.topLayout); flashToggle = content.findViewById(R.id.flash_torch); flashToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d("SCANNER-FRAGMENT", "Got tap on Flash"); if (mCameraSource.setFlashMode(mFlashOn ? Camera.Parameters.FLASH_MODE_OFF : Camera.Parameters.FLASH_MODE_TORCH)) { mFlashOn = !mFlashOn; flashToggle.setImageResource(mFlashOn ? R.drawable.ic_torch_on : R.drawable.ic_torch); } } }); mPreview.setScaletype(mPreviewScaleType); gestureDetector = new GestureDetector(getActivity(), new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(getActivity(), new ScaleListener()); mPreview.setOnTouchListener(this); return content; }
Example #13
Source File: Attacher.java From CanPhotos with Apache License 2.0 | 6 votes |
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) { mDraweeView = new WeakReference<>(draweeView); draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); draweeView.setOnTouchListener(this); mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this); mGestureDetector = new GestureDetectorCompat(draweeView.getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent e) { super.onLongPress(e); if (null != mLongClickListener) { mLongClickListener.onLongClick(getDraweeView()); } } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); }
Example #14
Source File: SpinnerNoSwipe.java From ankihelper with GNU General Public License v3.0 | 5 votes |
private void setup() { mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return performClick(); } }); }
Example #15
Source File: CustomViewPager.java From NClientV2 with Apache License 2.0 | 5 votes |
private void setup() { final GestureDetector tapGestureDetector = new GestureDetector(getContext(), new TapGestureListener()); setOnTouchListener((v, event) -> { tapGestureDetector.onTouchEvent(event); performClick(); return false; }); }
Example #16
Source File: WXGesture.java From weex with Apache License 2.0 | 5 votes |
public WXGesture(WXComponent wxComponent, Context context) { this.component = wxComponent; globalRect = new Rect(); globalOffset = new Point(); globalEventOffset = new Point(); locEventOffset = new PointF(); locLeftTop = new PointF(); mGestureDetector = new GestureDetector(context, new GestureListener(), new GestureHandler()); }
Example #17
Source File: PanView.java From wear-notify-for-reddit with Apache License 2.0 | 5 votes |
public PanView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Sets up interactions mGestureDetector = new GestureDetector(context, new ScrollFlingGestureListener()); mScroller = new OverScroller(context); mEdgeEffectLeft = new EdgeEffect(context); mEdgeEffectTop = new EdgeEffect(context); mEdgeEffectRight = new EdgeEffect(context); mEdgeEffectBottom = new EdgeEffect(context); mDrawBlurredPaint = new Paint(); mDrawBlurredPaint.setDither(true); }
Example #18
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 #19
Source File: WXGesture.java From weex-uikit with MIT License | 5 votes |
public WXGesture(WXComponent wxComponent, Context context) { this.component = wxComponent; globalRect = new Rect(); globalOffset = new Point(); globalEventOffset = new Point(); locEventOffset = new PointF(); locLeftTop = new PointF(); mGestureDetector = new GestureDetector(context, this, new GestureHandler()); }
Example #20
Source File: DrawingBoardView.java From imsdk-android with MIT License | 5 votes |
public DrawingBoardView(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.context = context; brushGestureListener = new BrushGestureListener(); brushGestureDetector = new GestureDetector(context, brushGestureListener); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setFilterBitmap(true); mPaint.setDither(true); }
Example #21
Source File: DragSortController.java From android-kernel-tweaker with GNU General Public License v3.0 | 5 votes |
/** * By default, sorting is enabled, and removal is disabled. * * @param dslv The DSLV instance * @param dragHandleId The resource id of the View that represents * the drag handle in a list item. */ public DragSortController(DragSortListView dslv, int dragHandleId, int dragInitMode, int removeMode, int clickRemoveId, int flingHandleId) { super(dslv); mDslv = dslv; mDetector = new GestureDetector(dslv.getContext(), this); mFlingRemoveDetector = new GestureDetector(dslv.getContext(), mFlingRemoveListener); mFlingRemoveDetector.setIsLongpressEnabled(false); mTouchSlop = ViewConfiguration.get(dslv.getContext()).getScaledTouchSlop(); mDragHandleId = dragHandleId; mClickRemoveId = clickRemoveId; mFlingHandleId = flingHandleId; setRemoveMode(removeMode); setDragInitMode(dragInitMode); }
Example #22
Source File: PreviewOverlay.java From Camera2 with Apache License 2.0 | 5 votes |
/** * Each module can pass in their own gesture listener through App UI. When a gesture * is detected, the {@link GestureDetector.OnGestureListener} will be notified of * the gesture. * * @param gestureListener a listener from a module that defines how to handle gestures */ public void setGestureListener(GestureDetector.OnGestureListener gestureListener) { if (gestureListener != null) { mGestureDetector = new GestureDetector(getContext(), gestureListener); } }
Example #23
Source File: MyRecyclerItemClickListener.java From Musync with MIT License | 5 votes |
public MyRecyclerItemClickListener(Context context, OnItemClickListener listener) { mListener = listener; mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }); }
Example #24
Source File: ClipZoomImageView.java From umeng_community_android with MIT License | 5 votes |
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); }
Example #25
Source File: ZImageSwitcher.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
public ZImageSwitcher(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.imageLoader = ImageLoader.getInstance(); this.displayImageOptions = ImageLoaderOptions.getOptionsCachedBoth(); this.detector = new GestureDetector(context, new MyOnGestureListener()); this.setLongClickable(true); }
Example #26
Source File: MaterialRippleLayoutNineOld.java From KickAssSlidingMenu with Apache License 2.0 | 5 votes |
public MaterialRippleLayoutNineOld(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setWillNotDraw(false); gestureDetector = new GestureDetector(context, longClickListener); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialRippleLayout); rippleColor = a.getColor(R.styleable.MaterialRippleLayout_mrlsxm_rippleColor, DEFAULT_COLOR); rippleDiameter = a.getDimensionPixelSize( R.styleable.MaterialRippleLayout_mrlsxm_rippleDimension, (int) dpToPx(getResources(), DEFAULT_DIAMETER_DP) ); rippleOverlay = a.getBoolean(R.styleable.MaterialRippleLayout_mrlsxm_rippleOverlay, DEFAULT_RIPPLE_OVERLAY); rippleHover = a.getBoolean(R.styleable.MaterialRippleLayout_mrlsxm_rippleHover, DEFAULT_HOVER); rippleDuration = a.getInt(R.styleable.MaterialRippleLayout_mrlsxm_rippleDuration, DEFAULT_DURATION); rippleAlpha = (int) (255 * a.getFloat(R.styleable.MaterialRippleLayout_mrlsxm_rippleAlpha, DEFAULT_ALPHA)); rippleDelayClick = a.getBoolean(R.styleable.MaterialRippleLayout_mrlsxm_rippleDelayClick, DEFAULT_DELAY_CLICK); rippleFadeDuration = a.getInteger(R.styleable.MaterialRippleLayout_mrlsxm_rippleFadeDuration, DEFAULT_FADE_DURATION); rippleBackground = new ColorDrawable(a.getColor(R.styleable.MaterialRippleLayout_mrlsxm_rippleBackground, DEFAULT_BACKGROUND)); ripplePersistent = a.getBoolean(R.styleable.MaterialRippleLayout_mrlsxm_ripplePersistent, DEFAULT_PERSISTENT); rippleInAdapter = a.getBoolean(R.styleable.MaterialRippleLayout_mrlsxm_rippleInAdapter, DEFAULT_SEARCH_ADAPTER); rippleRoundedCorners = a.getDimensionPixelSize(R.styleable.MaterialRippleLayout_mrlsxm_rippleRoundedCorners, DEFAULT_ROUNDED_CORNERS); a.recycle(); paint.setColor(rippleColor); paint.setAlpha(rippleAlpha); enableClipPathSupportIfNecessary(); }
Example #27
Source File: DocumentScannerFragment.java From CVScanner with GNU General Public License v3.0 | 5 votes |
void initializeViews(View view){ mPreview = view.findViewById(R.id.preview); mGraphicOverlay = view.findViewById(R.id.graphicOverlay); flashToggle = view.findViewById(R.id.flash); gestureDetector = new GestureDetector(getActivity(), new CaptureGestureListener()); view.setOnTouchListener(this); }
Example #28
Source File: CustomTabToolbar.java From AndroidChromium with Apache License 2.0 | 5 votes |
public InterceptTouchLayout(Context context, AttributeSet attrs) { super(context, attrs); mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapConfirmed(MotionEvent e) { if (LibraryLoader.isInitialized()) { RecordUserAction.record("CustomTabs.TapUrlBar"); } return super.onSingleTapConfirmed(e); } }); }
Example #29
Source File: PhotoViewAttacher.java From monolog-android with MIT License | 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 #30
Source File: OnItemTouchListener.java From Nimbus with GNU General Public License v3.0 | 5 votes |
public OnItemTouchListener(Context context, OnItemClickListener listener) { mListener = listener; mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }); }