本文整理汇总了Java中android.support.v4.view.GestureDetectorCompat类的典型用法代码示例。如果您正苦于以下问题:Java GestureDetectorCompat类的具体用法?Java GestureDetectorCompat怎么用?Java GestureDetectorCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GestureDetectorCompat类属于android.support.v4.view包,在下文中一共展示了GestureDetectorCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInterceptTouchEvent
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if (recyclerView == null) {
this.recyclerView = rv;
this.baseQuickAdapter = (BaseQuickAdapter) recyclerView.getAdapter();
mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView));
}
if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) {
if (mPressedView!=null){
mPressedView.setPressed(false);
mPressedView = null;
}
mIsShowPress = false;
mIsPrepressed = false;
}
return false;
}
示例2: Attacher
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
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));
}
示例3: init
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
private void init(Context context, AttributeSet attrs) {
//获取相关属性设置
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlideLayout);
mAlphaColor = ta.getColor(R.styleable.SlideLayout_sl_anim_alpha_color, DEF_ANIM_ALPHA_COLOR);
mEdgeEnable = ta.getBoolean(R.styleable.SlideLayout_sl_edge_enable, DEF_EDGE_ENABLE);
mMainAlphaEnable = ta.getBoolean(R.styleable.SlideLayout_sl_main_alpha_enable, DEF_MAIN_ALPHA_ENABLE);
ta.recycle();
//初始化ViewDragHelper相关
mCallback = new DragCallback();
mDragHelper = ViewDragHelper.create(this, DEF_SENSITIVITY, mCallback);
if (mEdgeEnable) {
//设置边缘滑动检测
mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
//设置最小滑动速度
mDragHelper.setMinVelocity(DEF_SENSITIVITY * DEF_MIN_FLING_VELOCITY);
}
//初始化屏幕触控处理相关
mGestureListener = new GestureListener();
mGestureDetector = new GestureDetectorCompat(context, mGestureListener);
//设置初始状态为关闭
mStatus = Status.CLOSED;
}
示例4: CalendarView
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
/**
* Constructor with arguments. It receives a
* Context used to get the resources.
*
* @param context - the context used to get the resources.
* @param attrs - attribute set with custom styles.
*/
public CalendarView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
//Initialize the gesture listener needed..
mGestureDetector = new GestureDetectorCompat(context, new CalendarGestureDetector());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) {
if (isInEditMode()) {
return;
}
}
getAttributes(attrs);
init();
}
示例5: DraggableSquareView
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
public DraggableSquareView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mDragHelper = ViewDragHelper
.create(this, 10f, new DragHelperCallback());
moveDetector = new GestureDetectorCompat(context,
new MoveDetector());
moveDetector.setIsLongpressEnabled(false); // 不能处理长按事件,否则违背最初设计的初衷
spaceInterval = (int) getResources().getDimension(R.dimen.drag_square_interval); // 小方块之间的间隔
// 滑动的距离阈值由系统提供
ViewConfiguration configuration = ViewConfiguration.get(getContext());
mTouchSlop = configuration.getScaledTouchSlop();
anchorHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (draggingView != null) {
// 开始移动重心的动画
draggingView.startAnchorAnimation();
}
}
};
}
示例6: Window
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
public Window(Context context) {
super(context);
this.setFocusable(true);
this.setFocusableInTouchMode(true);
//used for checking the total size needed for all the bubble to be reachable but not being able to go for miles
//without any stops
totalscreensize.put("up",0);
totalscreensize.put("down",0);
totalscreensize.put("right",0);
totalscreensize.put("left",0);
currentmessage="";
mDetector=new GestureDetectorCompat(getContext(),this);
WindowManager wm =(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display dis = wm.getDefaultDisplay();
Point pt = new Point();
dis.getSize(pt);
Center = new Point(pt.x/centerX,pt.y/centerY);
}
示例7: PendingDrag
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
/**
* Constructs a new PendingDrag that, if accepted by the DragHandler, begins with the
* {@code actionDown} event.
*
* @param controller The activity's {@link BlocklyController}.
* @param touchedView The initial touched {@link BlockView} of the drag.
* @param actionDown The first {@link MotionEvent#ACTION_DOWN} event.
*/
PendingDrag(@NonNull BlocklyController controller,
@NonNull BlockView touchedView, @NonNull MotionEvent actionDown) {
if (actionDown.getAction() != MotionEvent.ACTION_DOWN) {
throw new IllegalArgumentException();
}
mController = controller;
mHelper = controller.getWorkspaceHelper();
mLatestEventTime = actionDown.getEventTime();
mTouchedView = touchedView;
mPointerId = actionDown.getPointerId(actionDown.getActionIndex());
int pointerIdx = actionDown.findPointerIndex(mPointerId);
mTouchDownBlockX = (int) actionDown.getX(pointerIdx);
mTouchDownBlockY = (int) actionDown.getY(pointerIdx);
touchedView.getTouchLocationOnScreen(actionDown, mTouchDownScreen);
mHelper.screenToWorkspaceCoordinates(mTouchDownScreen, mTouchDownWorkspace);
mGestureDetector = new GestureDetectorCompat(mController.getContext(),
new GestureListener());
mGestureDetector.onTouchEvent(actionDown);
}
示例8: prepare
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
private void prepare(AttributeSet attrs)
{
setFocusable(true);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setWillNotDraw(false);
mScroller = new Scroller(getContext());
mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener);
mGestureDetector = new GestureDetectorCompat(getContext(), mGestureListener);
if (attrs != null)
{
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomViewExtension, 0, 0);
autoScrollMargins = a.getDimensionPixelSize(R.styleable.CustomViewExtension_autoScrollMargins, 0);
a.recycle();
}
mEdgeGlowLeft = new EdgeEffectCompat(getContext());
mEdgeGlowTop = new EdgeEffectCompat(getContext());
mEdgeGlowRight = new EdgeEffectCompat(getContext());
mEdgeGlowBottom = new EdgeEffectCompat(getContext());
setWillNotDraw(false);
}
示例9: CropView
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
public CropView(Context context, AttributeSet attrs) {
super(context, attrs);
mDetectorCompat = new GestureDetectorCompat(getContext(), new GestureListener());
mScaleDetector = new ScaleGestureDetector(getContext(), new ScaleGestureListener());
mBitmapOptions = new BitmapFactory.Options();
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
mRectPaint = new Paint();
mRectPaint.setStyle(Paint.Style.STROKE);
mRectPaint.setStrokeWidth(1f);
mBorderPaint = new Paint();
mBorderPaint.setColor(Color.BLACK);
mCanvasDrawRect = new Rect();
mImageDrawRect = new Rect();
mCacheRect = new Rect();
mOutputRect = new Rect();
mSmallImage = false;
mImageOK = false;
mLabelCollection = new LabelCollection();
}
示例10: init
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
private void init(Context context) {
this.context = context;
paint = new Paint();
paint.setAntiAlias(true);
loadDataThread.start();
gestureDetectorCompat = new GestureDetectorCompat(context,new GestureDetector.SimpleOnGestureListener(){
@Override
public boolean onDown(MotionEvent e) {
handlerTouch(e.getX(),e.getY());
return true;
}
});
minWidth = context.getResources().getDimensionPixelOffset(R.dimen.min_width);
minHeight = context.getResources().getDimensionPixelOffset(R.dimen.min_height);
}
示例11: onInterceptTouchEvent
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if (!shouldDetectGesture()) {
return false; // 拦截手势检测
}
// 手势检测
if (recyclerView == null) {
this.recyclerView = rv;
this.baseAdapter = (T) recyclerView.getAdapter();
mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView));
}
if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) {
if (mPressedView != null) {
BaseViewHolder vh = (BaseViewHolder) recyclerView.getChildViewHolder(mPressedView);
if (vh == null || vh.getItemViewType() != IRecyclerView.LOADING_VIEW || vh.getItemViewType() != FETCHING_VIEW) {
mPressedView.setPressed(false);
}
mPressedView = null;
}
mIsShowPress = false;
mIsPrepressed = false;
}
return false;
}
示例12: onDoubleTap
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
/**
* 双击
*/
public static void onDoubleTap(@NonNull View targetView, @NonNull final OnDoubleTapListener onDoubleTapListener) {
final GestureDetectorCompat gestureDetectorCompat = new GestureDetectorCompat(targetView.getContext(),
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
onDoubleTapListener.onDoubleTap();
return super.onDoubleTap(e);
}
});
targetView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
gestureDetectorCompat.onTouchEvent(event);
return false;
}
});
}
示例13: initLayout
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
private void initLayout() {
mOverScroller = new OverScroller(getContext());
mGestureDetectorCompat = new GestureDetectorCompat(getContext(),
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, final float velocityY) {
if (Math.abs(velocityX) > Math.abs(velocityY)) {
return false;
}
if (isFloat() /*&& velocityY < 0*/) {
return false;
}
fling(velocityY);
return true;
}
});
}
示例14: TagViewGroup
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
public TagViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
Resources.Theme theme = context.getTheme();
TypedArray array = theme.obtainStyledAttributes(attrs, R.styleable.TagViewGroup, defStyleAttr, 0);
mRadius = array.getDimensionPixelSize(R.styleable.TagViewGroup_radius, DipConvertUtils.dip2px(context, DEFAULT_RADIUS));
mInnerRadius = array.getDimensionPixelSize(R.styleable.TagViewGroup_inner_radius, DipConvertUtils.dip2px(context, DEFAULT_INNER_RADIUS));
mTDistance = array.getDimensionPixelSize(R.styleable.TagViewGroup_tilt_distance, DipConvertUtils.dip2px(context, DEFAULT_TILT_DISTANCE));
mVDistance = array.getDimensionPixelSize(R.styleable.TagViewGroup_v_distance, DipConvertUtils.dip2px(context, DEFAULT_V_DISTANCE));
mLinesWidth = array.getDimensionPixelSize(R.styleable.TagViewGroup_line_width, DipConvertUtils.dip2px(context, DEFAULT_LINES_WIDTH));
mRippleMaxRadius = array.getDimensionPixelSize(R.styleable.TagViewGroup_ripple_maxRadius, DipConvertUtils.dip2px(context, DEFAULT_RIPPLE_MAX_RADIUS));
mRippleAlpha = array.getInteger(R.styleable.TagViewGroup_ripple_alpha, DEFULT_RIPPLE_ALPHA);
mRippleMinRadius = mInnerRadius + (mRadius - mInnerRadius) / 2;
array.recycle();
mPaint = new Paint();
mPath = new Path();
mDstPath = new Path();
mPathMeasure = new PathMeasure();
mPaint.setAntiAlias(true);
mGestureDetector = new GestureDetectorCompat(context, new TagOnGestureListener());
mChildUsed = new int[4];
mCenterRect = new RectF();
}
示例15: onCreate
import android.support.v4.view.GestureDetectorCompat; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
mGestureDetector = new GestureDetectorCompat(getActivity(), new GestureListener());
if ( mLandscape ) {
mainActivity.mViewPagerListeners.add(this);
}
if ( savedInstanceState != null ) {
long date = savedInstanceState.getLong(SAVE_DATE, -1);
if ( date > 0 )
mCalendar.setTimeInMillis(date);
}
}