use of android.view.GestureDetector in project BaseProject by feer921.
the class RippleView method init.
/**
* Method that initializes all fields and sets listeners
*
* @param context Context used to create this view
* @param attrs Attribute used to initialize fields
*/
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);
rippleDuration = typedArray.getInteger(R.styleable.RippleView_rv_rippleDuration, rippleDuration);
frameRate = typedArray.getInteger(R.styleable.RippleView_rv_framerate, frameRate);
rippleAlpha = typedArray.getInteger(R.styleable.RippleView_rv_alpha, rippleAlpha);
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);
typedArray.recycle();
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
paint.setColor(rippleColor);
paint.setAlpha(rippleAlpha);
this.setWillNotDraw(false);
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public void onLongPress(MotionEvent event) {
super.onLongPress(event);
animateRipple(event);
sendClickEvent(true);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return true;
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
this.setDrawingCacheEnabled(true);
this.setClickable(true);
}
use of android.view.GestureDetector in project AndroidStudy by tinggengyan.
the class LongPressedTextView method init.
private void init() {
gestureListener = new GestureDetector.SimpleOnGestureListener() {
@Override
public void onLongPress(MotionEvent e) {
if (pressedChangedListener != null) {
pressedChangedListener.onLongPress();
}
}
};
gestureDetector = new GestureDetector(getContext(), gestureListener);
}
use of android.view.GestureDetector in project MyApp by MatthewDevelop.
the class BaseSetupActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
preference = getSharedPreferences("config", MODE_PRIVATE);
mDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
/**
* 监听手势滑动事件
* @param e1 手势滑动的起点
* @param e2 手势滑动的终点
* @param velocityX 水平速度
* @param velocityY 垂直速度
* @return
*/
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
// 判断纵向滑动幅度是否过大,过大则不切换界面
if (Math.abs(e2.getRawY() - e1.getRawY()) > 100) {
return true;
}
// 判断用户的滑动速度是否过慢
if (Math.abs(velocityX) < 100) {
return true;
}
// 向右划,到上一页
if ((e2.getRawX() - e1.getRawX()) > 200) {
showPreviousPage();
return true;
}
// 向左划,下一页
if ((e1.getRawX() - e2.getRawX()) > 200) {
showNextPage();
return true;
}
return super.onFling(e1, e2, velocityX, velocityY);
}
});
}
use of android.view.GestureDetector in project GomoTest by suReZj.
the class ImageViewTouch method init.
@Override
protected void init() {
super.init();
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
mGestureListener = getGestureListener();
mScaleListener = getScaleListener();
mScaleDetector = new ScaleGestureDetector(getContext(), mScaleListener);
mGestureDetector = new GestureDetector(getContext(), mGestureListener, null, true);
mDoubleTapDirection = 1;
}
use of android.view.GestureDetector in project quran_android by quran.
the class QuranImagePageLayout method setPageController.
@Override
public void setPageController(PageController controller, int pageNumber) {
super.setPageController(controller, pageNumber);
final GestureDetector gestureDetector = new GestureDetector(context, new PageGestureDetector());
OnTouchListener gestureListener = (v, event) -> gestureDetector.onTouchEvent(event);
imageView.setOnTouchListener(gestureListener);
imageView.setClickable(true);
imageView.setLongClickable(true);
}
Aggregations