當前位置: 首頁>>代碼示例>>Java>>正文


Java MotionEventCompat類代碼示例

本文整理匯總了Java中android.support.v4.view.MotionEventCompat的典型用法代碼示例。如果您正苦於以下問題:Java MotionEventCompat類的具體用法?Java MotionEventCompat怎麽用?Java MotionEventCompat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MotionEventCompat類屬於android.support.v4.view包,在下文中一共展示了MotionEventCompat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = MotionEventCompat.getActionMasked(ev);

    if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        mReturningToStart = false;
    }
    if (!isEnabled() || mReturningToStart
            || (!isChildScrollToTop() && !isChildScrollToBottom())) {
        // 如果子View可以滑動,不攔截事件,交給子View處理
        return false;
    }

    if (isChildScrollToBottom()) {
        // 上拉加載更多
        return handlerPushTouchEvent(ev, action);
    } else {
        // 下拉刷新
        return handlerPullTouchEvent(ev, action);
    }
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:22,代碼來源:SuperSwipeRefreshLayout.java

示例2: onGenericMotionEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
public boolean onGenericMotionEvent(MotionEvent event) {
    if (!(this.mLayout == null || this.mLayoutFrozen || (MotionEventCompat.getSource(event) & 2) == 0 || event.getAction() != 8)) {
        float vScroll;
        float hScroll;
        if (this.mLayout.canScrollVertically()) {
            vScroll = -MotionEventCompat.getAxisValue(event, 9);
        } else {
            vScroll = 0.0f;
        }
        if (this.mLayout.canScrollHorizontally()) {
            hScroll = MotionEventCompat.getAxisValue(event, 10);
        } else {
            hScroll = 0.0f;
        }
        if (!(vScroll == 0.0f && hScroll == 0.0f)) {
            float scrollFactor = getScrollFactor();
            scrollByInternal((int) (hScroll * scrollFactor), (int) (vScroll * scrollFactor), event);
        }
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:22,代碼來源:RecyclerView.java

示例3: dispatchTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
	if (mAutoScrollable) {
		int action = MotionEventCompat.getActionMasked(ev);

		if (action == MotionEvent.ACTION_DOWN) {
			stopScroll();
		} else if (ev.getAction() == MotionEvent.ACTION_UP) {
			resumeScroll();
		}

		this.getParent().requestDisallowInterceptTouchEvent(true);
	}

	return super.dispatchTouchEvent(ev);
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:17,代碼來源:AutoScrollViewPager.java

示例4: onTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
@Override
public boolean onTouchEvent(@NotNull MotionEvent event) {
    int action = MotionEventCompat.getActionMasked(event);

    switch(action) {
        case (MotionEvent.ACTION_DOWN):
        case (MotionEvent.ACTION_MOVE):
        case (MotionEvent.ACTION_UP):
            int band = Math.max(0, Math.min(mSourcePathPoints.length - 1, (int)(mSourcePathPoints.length * event.getX() / getWidth())));
            float value = 30 * (getHeight() - event.getY()) / getHeight();
            if (listener != null)
                listener.OnBandUpdated(band, value);
            return true;
        case (MotionEvent.ACTION_CANCEL):
            return true;
        case (MotionEvent.ACTION_OUTSIDE):
            return true;
        default :
            return super.onTouchEvent(event);
    }
}
 
開發者ID:dmllr,項目名稱:IdealMedia,代碼行數:22,代碼來源:Wave.java

示例5: bindDragHandle

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
/**
 * this functions binds the view's touch listener to start the drag via the touch helper...
 *
 * @param holder the view holder
 * @param holder the item
 */
public static void bindDragHandle(final RecyclerView.ViewHolder holder, final IExtendedDraggable item) {
    // if necessary, init the drag handle, which will start the drag when touched
    if (item.getTouchHelper() != null && item.getDragView(holder) != null) {
        item.getDragView(holder).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
                    if (item.isDraggable())
                        item.getTouchHelper().startDrag(holder);
                }
                return false;
            }
        });
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:DragDropUtil.java

示例6: onTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent event) {
	if (event.getAction() == MotionEvent.ACTION_DOWN) {
		// Selection may be beginning. Sync the TextView with the buffer.
		refreshTextFromBuffer();
	}

	// Mouse input is treated differently:
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
			MotionEventCompat.getSource(event) == InputDevice.SOURCE_MOUSE) {
		if (onMouseEvent(event, terminalView.bridge)) {
			return true;
		}
		terminalView.viewPager.setPagingEnabled(true);
	} else {
		if (terminalView.onTouchEvent(event)) {
			return true;
		}
	}

	return super.onTouchEvent(event);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:TerminalTextViewOverlay.java

示例7: onTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent event) {

    //Check pointer index to avoid -1 (error)
    if (MotionEventCompat.findPointerIndex(event, 0) == -1) {
        return super.onTouchEvent(event);
    }

    if (event.getPointerCount() >= 1) {
        requestDisallowInterceptTouchEvent(true);
    } else {
        requestDisallowInterceptTouchEvent(false);
    }

    return super.onTouchEvent(event);
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:17,代碼來源:CustomWebView.java

示例8: onTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
public boolean onTouchEvent(MotionEvent ev) {
    int action = MotionEventCompat.getActionMasked(ev);
    if (action == 0) {
        this.mEatingTouch = false;
    }
    if (!this.mEatingTouch) {
        boolean handled = super.onTouchEvent(ev);
        if (action == 0 && !handled) {
            this.mEatingTouch = true;
        }
    }
    if (action == 1 || action == 3) {
        this.mEatingTouch = false;
    }
    return true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:Toolbar.java

示例9: onInterceptTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
@Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
//        L.e("call: onInterceptTouchEvent([ev])-> " + ev.getAction());
        int action = MotionEventCompat.getActionMasked(ev);
        if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
            onTouchUp();
            onTouchEnd();

            if (Math.abs(mStartScrollY - getScrollY()) >
                    ViewConfiguration.get(getContext()).getScaledTouchSlop()) {
                //ev.setAction(MotionEvent.ACTION_CANCEL);
                return true;
            }
        }
        return super.onInterceptTouchEvent(ev);
    }
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:17,代碼來源:StickLayout2.java

示例10: findSwipedView

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
private ViewHolder findSwipedView(MotionEvent motionEvent) {
    final RecyclerView.LayoutManager lm = mRecyclerView.getLayoutManager();
    if (mActivePointerId == ACTIVE_POINTER_ID_NONE) {
        return null;
    }
    final int pointerIndex = MotionEventCompat.findPointerIndex(motionEvent, mActivePointerId);
    final float dx = MotionEventCompat.getX(motionEvent, pointerIndex) - mInitialTouchX;
    final float dy = MotionEventCompat.getY(motionEvent, pointerIndex) - mInitialTouchY;
    final float absDx = Math.abs(dx);
    final float absDy = Math.abs(dy);

    if (absDx < mSlop && absDy < mSlop) {
        return null;
    }
    if (absDx > absDy && lm.canScrollHorizontally()) {
        return null;
    } else if (absDy > absDx && lm.canScrollVertically()) {
        return null;
    }
    View child = findChildView(motionEvent);
    if (child == null) {
        return null;
    }
    return mRecyclerView.getChildViewHolder(child);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:26,代碼來源:ItemTouchHelper.java

示例11: onTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = MotionEventCompat.getActionMasked(ev);
    if (isBackToStart && action == MotionEvent.ACTION_DOWN) isBackToStart = false;
    switch (mType) {
        case BOTTOM:
            if (!isEnabled() || isBackToStart || canChildScrollDown() || isRefreshing) {
                return false;
            }
            break;
        case TOP:
        default:
            if (!isEnabled() || isBackToStart || canChildScrollUp() || isRefreshing) {
                return false;
            }
            break;
    }
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            isReady = false;
            break;
        case MotionEvent.ACTION_MOVE:
            if (TouchActionMove(ev)) return false;
            break;
        case MotionEventCompat.ACTION_POINTER_DOWN:
            final int index = MotionEventCompat.getActionIndex(ev);
            mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            break;
        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL: {
            return TouchActionCancel(ev);
        }
    }
    return true;
}
 
開發者ID:shenhuanet,項目名稱:AndroidOpen,代碼行數:40,代碼來源:SwipeToRefreshLayout.java

示例12: onTouch

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
public boolean onTouch(View v, MotionEvent event) {
    boolean z = true;
    if (!this.mEnabled) {
        return false;
    }
    switch (MotionEventCompat.getActionMasked(event)) {
        case 0:
            this.mNeedsCancel = true;
            this.mAlreadyDelayed = false;
            break;
        case 1:
        case 3:
            requestStop();
            break;
        case 2:
            break;
    }
    this.mScroller.setTargetVelocity(computeTargetVelocity(0, event.getX(), (float) v.getWidth(), (float) this.mTarget.getWidth()), computeTargetVelocity(1, event.getY(), (float) v.getHeight(), (float) this.mTarget.getHeight()));
    if (!this.mAnimating && shouldAnimate()) {
        startAnimating();
    }
    if (!(this.mExclusive && this.mAnimating)) {
        z = false;
    }
    return z;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:27,代碼來源:AutoScrollHelper.java

示例13: onTouchEvent

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
@Override
public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
    if (!child.isShown()) {
        return false;
    }

    int action = MotionEventCompat.getActionMasked(event);
    if (mState == STATE_DRAGGING && action == MotionEvent.ACTION_DOWN) {
        return true;
    }

    mViewDragHelper.processTouchEvent(event);

    if (action == MotionEvent.ACTION_DOWN) {
        reset();
    }

    // The ViewDragHelper tries to capture only the top-most View. We have to explicitly tell it
    // to capture the bottom sheet in case it is not captured and the touch slop is passed.
    if (action == MotionEvent.ACTION_MOVE && !mIgnoreEvents) {
        if (Math.abs(mInitialY - event.getY()) > mViewDragHelper.getTouchSlop()) {
            mViewDragHelper.captureChildView(child, event.getPointerId(event.getActionIndex()));
        }
    }
    return !mIgnoreEvents;
}
 
開發者ID:aliumujib,項目名稱:Nibo,代碼行數:27,代碼來源:BottomSheetBehaviorGoogleMapsLike.java

示例14: determineDrag

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
private void determineDrag(MotionEvent ev) {
	final int activePointerId = mActivePointerId;
	final int pointerIndex = getPointerIndex(ev, activePointerId);
	if (activePointerId == INVALID_POINTER || pointerIndex == INVALID_POINTER)
		return;
	final float x = MotionEventCompat.getX(ev, pointerIndex);
	final float dx = x - mLastMotionX;
	final float xDiff = Math.abs(dx);
	final float y = MotionEventCompat.getY(ev, pointerIndex);
	final float dy = y - mLastMotionY;
	final float yDiff = Math.abs(dy);
	if (xDiff > (isMenuOpen()?mTouchSlop/2:mTouchSlop) && xDiff > yDiff && thisSlideAllowed(dx)) {		
		startDrag();
		mLastMotionX = x;
		mLastMotionY = y;
		setScrollingCacheEnabled(true);
		// TODO add back in touch slop check
	} else if (xDiff > mTouchSlop) {
		mIsUnableToDrag = true;
	}
}
 
開發者ID:ChenTianSaber,項目名稱:DailyZhiHu,代碼行數:22,代碼來源:CustomViewAbove.java

示例15: a

import android.support.v4.view.MotionEventCompat; //導入依賴的package包/類
private boolean a(char c) {
    switch (c) {
        case '\t':
        case '\n':
        case '\f':
        case '\r':
        case ' ':
        case MotionEventCompat.AXIS_GENERIC_13 /*44*/:
        case ':':
        case '[':
        case ']':
        case '{':
        case '}':
            break;
        case '#':
        case MotionEventCompat.AXIS_GENERIC_16 /*47*/:
        case ';':
        case '=':
        case '\\':
            v();
            break;
        default:
            return true;
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:27,代碼來源:a.java


注:本文中的android.support.v4.view.MotionEventCompat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。