use of android.view.MotionEvent in project superCleanMaster by joyoyao.
the class RippleView method init.
@SuppressLint("Recycle")
private void init(final Context context, final AttributeSet attrs) {
if (isInEditMode())
return;
final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleView);
rippleColor = typedArray.getColor(R.styleable.RippleView_rv_color, getResources().getColor(R.color.white));
rippleType = typedArray.getInt(R.styleable.RippleView_rv_type, 0);
hasToZoom = typedArray.getBoolean(R.styleable.RippleView_rv_zoom, false);
isCentered = typedArray.getBoolean(R.styleable.RippleView_rv_centered, false);
DURATION = typedArray.getInteger(R.styleable.RippleView_rv_rippleDuration, DURATION);
FRAME_RATE = typedArray.getInteger(R.styleable.RippleView_rv_framerate, FRAME_RATE);
PAINT_ALPHA = typedArray.getInteger(R.styleable.RippleView_rv_alpha, PAINT_ALPHA);
ripplePadding = typedArray.getDimensionPixelSize(R.styleable.RippleView_rv_ripplePadding, 0);
canvasHandler = new Handler();
zoomScale = typedArray.getFloat(R.styleable.RippleView_rv_zoomScale, 1.03f);
zoomDuration = typedArray.getInt(R.styleable.RippleView_rv_zoomDuration, 200);
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
paint.setColor(rippleColor);
paint.setAlpha(PAINT_ALPHA);
this.setWillNotDraw(false);
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return true;
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
this.setDrawingCacheEnabled(true);
}
use of android.view.MotionEvent in project QLibrary by DragonsQC.
the class QLazyViewPager method fakeDragBy.
/**
* Fake drag by an offset in pixels. You must have called {@link #beginFakeDrag()} first.
*
* @param xOffset Offset in pixels to drag by.
* @see #beginFakeDrag()
* @see #endFakeDrag()
*/
public void fakeDragBy(float xOffset) {
if (!mFakeDragging) {
throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
}
mLastMotionX += xOffset;
float scrollX = getScrollX() - xOffset;
final int width = getWidth();
final int widthWithMargin = width + mPageMargin;
final float leftBound = Math.max(0, (mCurItem - 1) * widthWithMargin);
final float rightBound = Math.min(mCurItem + 1, mAdapter.getCount() - 1) * widthWithMargin;
if (scrollX < leftBound) {
scrollX = leftBound;
} else if (scrollX > rightBound) {
scrollX = rightBound;
}
// Don't lose the rounded component
mLastMotionX += scrollX - (int) scrollX;
scrollTo((int) scrollX, getScrollY());
if (mOnPageChangeListener != null) {
final int position = (int) scrollX / widthWithMargin;
final int positionOffsetPixels = (int) scrollX % widthWithMargin;
final float positionOffset = (float) positionOffsetPixels / widthWithMargin;
mOnPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
// Synthesize an event for the VelocityTracker.
final long time = SystemClock.uptimeMillis();
final MotionEvent ev = MotionEvent.obtain(mFakeDragBeginTime, time, MotionEvent.ACTION_MOVE, mLastMotionX, 0, 0);
mVelocityTracker.addMovement(ev);
ev.recycle();
}
use of android.view.MotionEvent in project XobotOS by xamarin.
the class Switch method cancelSuperTouch.
private void cancelSuperTouch(MotionEvent ev) {
MotionEvent cancel = MotionEvent.obtain(ev);
cancel.setAction(MotionEvent.ACTION_CANCEL);
super.onTouchEvent(cancel);
cancel.recycle();
}
use of android.view.MotionEvent in project android_frameworks_base by ResurrectionRemix.
the class StatusBarWindowView method onInterceptTouchEvent.
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
boolean intercept = false;
if (mDoubleTapToSleepEnabled && ev.getY() < mStatusBarHeaderHeight) {
if (DEBUG)
Log.w(TAG, "logging double tap gesture");
mDoubleTapGesture.onTouchEvent(ev);
}
if (mNotificationPanel.isFullyExpanded() && mStackScrollLayout.getVisibility() == View.VISIBLE && mService.getBarState() == StatusBarState.KEYGUARD && !mService.isBouncerShowing()) {
intercept = mDragDownHelper.onInterceptTouchEvent(ev);
// wake up on a touch down event, if dozing
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
mService.wakeUpIfDozing(ev.getEventTime(), ev);
}
}
if (!intercept) {
super.onInterceptTouchEvent(ev);
}
if (intercept) {
MotionEvent cancellation = MotionEvent.obtain(ev);
cancellation.setAction(MotionEvent.ACTION_CANCEL);
mStackScrollLayout.onInterceptTouchEvent(cancellation);
mNotificationPanel.onInterceptTouchEvent(cancellation);
cancellation.recycle();
}
return intercept;
}
use of android.view.MotionEvent in project android_frameworks_base by ResurrectionRemix.
the class ZoomButtonsController method onTouch.
/**
* @hide The ZoomButtonsController implements the OnTouchListener, but this
* does not need to be shown in its public API.
*/
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
if (event.getPointerCount() > 1) {
// ZoomButtonsController doesn't handle mutitouch. Give up control.
return false;
}
if (mReleaseTouchListenerOnUp) {
// The controls were dismissed but we need to throw away all events until the up
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
mOwnerView.setOnTouchListener(null);
setTouchTargetView(null);
mReleaseTouchListenerOnUp = false;
}
// Eat this event
return true;
}
dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
View targetView = mTouchTargetView;
switch(action) {
case MotionEvent.ACTION_DOWN:
targetView = findViewForTouch((int) event.getRawX(), (int) event.getRawY());
setTouchTargetView(targetView);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
setTouchTargetView(null);
break;
}
if (targetView != null) {
// The upperleft corner of the target view in raw coordinates
int targetViewRawX = mContainerRawLocation[0] + mTouchTargetWindowLocation[0];
int targetViewRawY = mContainerRawLocation[1] + mTouchTargetWindowLocation[1];
MotionEvent containerEvent = MotionEvent.obtain(event);
// Convert the motion event into the target view's coordinates (from
// owner view's coordinates)
containerEvent.offsetLocation(mOwnerViewRawLocation[0] - targetViewRawX, mOwnerViewRawLocation[1] - targetViewRawY);
/* Disallow negative coordinates (which can occur due to
* ZOOM_CONTROLS_TOUCH_PADDING) */
// These are floats because we need to potentially offset away this exact amount
float containerX = containerEvent.getX();
float containerY = containerEvent.getY();
if (containerX < 0 && containerX > -ZOOM_CONTROLS_TOUCH_PADDING) {
containerEvent.offsetLocation(-containerX, 0);
}
if (containerY < 0 && containerY > -ZOOM_CONTROLS_TOUCH_PADDING) {
containerEvent.offsetLocation(0, -containerY);
}
boolean retValue = targetView.dispatchTouchEvent(containerEvent);
containerEvent.recycle();
return retValue;
} else {
return false;
}
}
Aggregations