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);
}
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;
}
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);
}
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);
}
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);
}
});
}
Aggregations