Search in sources :

Example 6 with GestureDetectorCompat

use of androidx.core.view.GestureDetectorCompat in project RxTools by vondear.

the class RxRulerWheelView method init.

protected void init(AttributeSet attrs) {
    float density = getResources().getDisplayMetrics().density;
    mCenterMarkWidth = (int) (density * 1.5f + 0.5f);
    mMarkWidth = density;
    mHighlightColor = 0xFFF74C39;
    mMarkTextColor = 0xFF666666;
    mMarkColor = 0xFFEEEEEE;
    mCursorSize = density * 18;
    mCenterTextSize = density * 22;
    mNormalTextSize = density * 18;
    mBottomSpace = density * 6;
    TypedArray ta = attrs == null ? null : getContext().obtainStyledAttributes(attrs, R.styleable.lwvWheelView);
    if (ta != null) {
        mHighlightColor = ta.getColor(R.styleable.lwvWheelView_lwvHighlightColor, mHighlightColor);
        mMarkTextColor = ta.getColor(R.styleable.lwvWheelView_lwvMarkTextColor, mMarkTextColor);
        mMarkColor = ta.getColor(R.styleable.lwvWheelView_lwvMarkColor, mMarkColor);
        mIntervalFactor = ta.getFloat(R.styleable.lwvWheelView_lwvIntervalFactor, mIntervalFactor);
        mMarkRatio = ta.getFloat(R.styleable.lwvWheelView_lwvMarkRatio, mMarkRatio);
        mAdditionCenterMark = ta.getString(R.styleable.lwvWheelView_lwvAdditionalCenterMark);
        mCenterTextSize = ta.getDimension(R.styleable.lwvWheelView_lwvCenterMarkTextSize, mCenterTextSize);
        mNormalTextSize = ta.getDimension(R.styleable.lwvWheelView_lwvMarkTextSize, mNormalTextSize);
        mCursorSize = ta.getDimension(R.styleable.lwvWheelView_lwvCursorSize, mCursorSize);
    }
    mFadeMarkColor = mHighlightColor & 0xAAFFFFFF;
    mIntervalFactor = Math.max(1, mIntervalFactor);
    mMarkRatio = Math.min(1, mMarkRatio);
    mTopSpace = mCursorSize + density * 2;
    mMarkPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mMarkTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mMarkTextPaint.setTextAlign(Paint.Align.CENTER);
    mMarkTextPaint.setColor(mHighlightColor);
    mMarkPaint.setColor(mMarkColor);
    mMarkPaint.setStrokeWidth(mCenterMarkWidth);
    mMarkTextPaint.setTextSize(mCenterTextSize);
    calcIntervalDis();
    mScroller = new OverScroller(getContext());
    mContentRectF = new RectF();
    mGestureDetectorCompat = new GestureDetectorCompat(getContext(), this);
    selectIndex(0);
}
Also used : RectF(android.graphics.RectF) TypedArray(android.content.res.TypedArray) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) GestureDetectorCompat(androidx.core.view.GestureDetectorCompat) TextPaint(android.text.TextPaint) OverScroller(android.widget.OverScroller)

Example 7 with GestureDetectorCompat

use of androidx.core.view.GestureDetectorCompat in project Signal-Android by WhisperSystems.

the class PictureInPictureGestureHelper method applyTo.

@SuppressLint("ClickableViewAccessibility")
public static PictureInPictureGestureHelper applyTo(@NonNull View child) {
    TouchInterceptingFrameLayout parent = (TouchInterceptingFrameLayout) child.getParent();
    PictureInPictureGestureHelper helper = new PictureInPictureGestureHelper(parent, child);
    GestureDetectorCompat gestureDetector = new GestureDetectorCompat(child.getContext(), helper);
    parent.setOnInterceptTouchEventListener((event) -> {
        final int action = event.getAction();
        final int pointerIndex = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
        if (pointerIndex > 0) {
            return false;
        }
        if (helper.velocityTracker == null) {
            helper.velocityTracker = VelocityTracker.obtain();
        }
        helper.velocityTracker.addMovement(event);
        return false;
    });
    parent.setOnTouchListener((v, event) -> {
        if (helper.velocityTracker != null) {
            helper.velocityTracker.recycle();
            helper.velocityTracker = null;
        }
        return false;
    });
    child.setOnTouchListener((v, event) -> {
        boolean handled = gestureDetector.onTouchEvent(event);
        if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
            if (!handled) {
                handled = helper.onGestureFinished(event);
            }
            if (helper.velocityTracker != null) {
                helper.velocityTracker.recycle();
                helper.velocityTracker = null;
            }
        }
        return handled;
    });
    return helper;
}
Also used : TouchInterceptingFrameLayout(org.thoughtcrime.securesms.util.views.TouchInterceptingFrameLayout) GestureDetectorCompat(androidx.core.view.GestureDetectorCompat) Point(android.graphics.Point) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 8 with GestureDetectorCompat

use of androidx.core.view.GestureDetectorCompat in project Douya by DreaminginCodeZH.

the class DoubleClickToolbar method init.

private void init() {
    mGestureDetectorCompat = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onDoubleTap(MotionEvent event) {
            if (mOnDoubleClickListener != null) {
                return mOnDoubleClickListener.onDoubleClick(DoubleClickToolbar.this);
            }
            return false;
        }
    });
    mGestureDetectorCompat.setIsLongpressEnabled(false);
}
Also used : GestureDetectorCompat(androidx.core.view.GestureDetectorCompat) MotionEvent(android.view.MotionEvent)

Example 9 with GestureDetectorCompat

use of androidx.core.view.GestureDetectorCompat in project Carbon by ZieIony.

the class ItemTouchHelper method startGestureDetection.

private void startGestureDetection() {
    mItemTouchHelperGestureListener = new ItemTouchHelperGestureListener();
    mGestureDetector = new GestureDetectorCompat(mRecyclerView.getContext(), mItemTouchHelperGestureListener);
}
Also used : GestureDetectorCompat(androidx.core.view.GestureDetectorCompat)

Example 10 with GestureDetectorCompat

use of androidx.core.view.GestureDetectorCompat in project materialistic by hidroh.

the class NavFloatingActionButton method bindNavigationPad.

@Synthetic
void bindNavigationPad() {
    GestureDetectorCompat detectorCompat = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onDown(MotionEvent e) {
            return mNavigable != null;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            Toast.makeText(getContext(), R.string.hint_nav_short, Toast.LENGTH_LONG).show();
            return true;
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            trackKonami(DOUBLE_TAP);
            return super.onDoubleTap(e);
        }

        @Override
        public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float velocityX, float velocityY) {
            int direction;
            if (Math.abs(velocityX) > Math.abs(velocityY)) {
                direction = velocityX < 0 ? Navigable.DIRECTION_LEFT : Navigable.DIRECTION_RIGHT;
            } else {
                direction = velocityY < 0 ? Navigable.DIRECTION_UP : Navigable.DIRECTION_DOWN;
            }
            mNavigable.onNavigate(direction);
            if (mVibrationEnabled) {
                mVibrator.vibrate(VIBRATE_DURATION_MS);
            }
            trackKonami(direction);
            return false;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            if (mNavigable == null) {
                return;
            }
            startDrag(e.getX(), e.getY());
        }
    });
    // noinspection Convert2Lambda
    super.setOnTouchListener(new OnTouchListener() {

        @SuppressLint("ClickableViewAccessibility")
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return detectorCompat.onTouchEvent(motionEvent);
        }
    });
}
Also used : SuppressLint(android.annotation.SuppressLint) GestureDetector(android.view.GestureDetector) GestureDetectorCompat(androidx.core.view.GestureDetectorCompat) View(android.view.View) MotionEvent(android.view.MotionEvent) Synthetic(io.github.hidroh.materialistic.annotation.Synthetic)

Aggregations

GestureDetectorCompat (androidx.core.view.GestureDetectorCompat)11 SuppressLint (android.annotation.SuppressLint)3 MotionEvent (android.view.MotionEvent)3 Point (android.graphics.Point)2 View (android.view.View)2 Message (com.applozic.mobicomkit.api.conversation.Message)2 AlRichMessage (com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage)2 TouchInterceptingFrameLayout (org.thoughtcrime.securesms.util.views.TouchInterceptingFrameLayout)2 Context (android.content.Context)1 Intent (android.content.Intent)1 Configuration (android.content.res.Configuration)1 TypedArray (android.content.res.TypedArray)1 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 RectF (android.graphics.RectF)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 Bundle (android.os.Bundle)1 CountDownTimer (android.os.CountDownTimer)1 ResultReceiver (android.os.ResultReceiver)1 Editable (android.text.Editable)1