本文整理匯總了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);
}
}