当前位置: 首页>>代码示例>>Java>>正文


Java GestureDetectorCompat.onTouchEvent方法代码示例

本文整理汇总了Java中android.support.v4.view.GestureDetectorCompat.onTouchEvent方法的典型用法代码示例。如果您正苦于以下问题:Java GestureDetectorCompat.onTouchEvent方法的具体用法?Java GestureDetectorCompat.onTouchEvent怎么用?Java GestureDetectorCompat.onTouchEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.GestureDetectorCompat的用法示例。


在下文中一共展示了GestureDetectorCompat.onTouchEvent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:SimpleClickListener.java

示例2: 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);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:34,代码来源:PendingDrag.java

示例3: 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;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:27,代码来源:SimpleClickListener.java

示例4: processRawEvent

import android.support.v4.view.GestureDetectorCompat; //导入方法依赖的package包/类
public void processRawEvent(GestureDetectorCompat mDetector, MotionEvent e) {
    // record the touches
    setTouches(e);
    if (edgesTouched == 0 && e.getAction() == MotionEvent.ACTION_DOWN) {
        edgesTouched = getEdgesTouched((int) e.getX(), (int) e.getY());
        if (edgesTouched != 0) {
            log.debug("Edges Touched: {}", edgesTouched);
        }
    }
    mDetector.onTouchEvent(e);

    if (touchFocusEnabled) {
        if (e.getAction() == MotionEvent.ACTION_MOVE) {
            if (logTouch) log.debug("onMouseMove: {},{}", X(e), Y(e));
            client.getCurrentConnection().postMouseEvent(new MouseEvent(this, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, X(e), Y(e), 0, 0, 0));
        }
    }

    if (edgesTouched != 0 && (e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_POINTER_UP)) {
        log.debug("Clearing Touched Edges");
        edgesTouched = 0;
    }
}
 
开发者ID:OpenSageTV,项目名称:sagetv-miniclient,代码行数:24,代码来源:UIGestureListener.java

示例5: 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() != IRecyclerView.FETCHING_VIEW) {
                mPressedView.setPressed(false);
            }
            mPressedView = null;
        }
        mIsShowPress = false;
        mIsPrepressed = false;
    }

    return false;
}
 
开发者ID:netease-im,项目名称:NIM_Android_UIKit,代码行数:27,代码来源:SimpleClickListener.java

示例6: onInterceptTouchEvent

import android.support.v4.view.GestureDetectorCompat; //导入方法依赖的package包/类
@Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
                LogUtil.e("onInterceptTouchEvent_RecyclerView");
                if (mRecyclerView == null) {
                        mRecyclerView = rv;
                        mBaseWrappedAdapter = (BaseWrappedAdapter) mRecyclerView.getAdapter();
                        mGestureDetectorCompat = new GestureDetectorCompat(mRecyclerView.getContext(),
                                new CustomOnGestureListener(mRecyclerView));
                }
//                这里恢复长按下效果
                if (!mGestureDetectorCompat.onTouchEvent(e) && e.getAction() == MotionEvent.ACTION_UP
                        && isPressing) {
                        if (mPressedView != null) {
//                                这里要排除头部和底部view
                                RecyclerView.ViewHolder viewHolder = mRecyclerView.getChildViewHolder(mPressedView);
                                if (viewHolder == null || !isHeaderViewOrFooterView(viewHolder.getItemViewType())) {
                                        mPressedView.setPressed(false);
                                        if (mPressedView instanceof ViewGroup) {
                                                ViewGroup viewGroup = (ViewGroup) mPressedView;
                                                for (int i = 0; i < viewGroup.getChildCount(); i++) {
                                                        if (!viewGroup.getChildAt(i).isPressed()) {
                                                                viewGroup.getChildAt(i).setPressed(false);
                                                        }
                                                }
                                        }
                                }
                        }
//                        重置
                        isPressing = false;
                }
//                不中断
                return false;
        }
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:34,代码来源:BaseItemClickListener.java


注:本文中的android.support.v4.view.GestureDetectorCompat.onTouchEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。