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


Java MotionEvent.obtainNoHistory方法代碼示例

本文整理匯總了Java中android.view.MotionEvent.obtainNoHistory方法的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.obtainNoHistory方法的具體用法?Java MotionEvent.obtainNoHistory怎麽用?Java MotionEvent.obtainNoHistory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.MotionEvent的用法示例。


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

示例1: duplicateTouchEventForChildren

import android.view.MotionEvent; //導入方法依賴的package包/類
/**
 * Duplicate touch events to child views.
 * We want to dispatch a down motion event and the move events to
 * child views, but calling dispatchTouchEvent() causes StackOverflowError.
 * Therefore we do it manually.
 *
 * @param ev            motion event to be passed to children
 * @param pendingEvents pending events like ACTION_DOWN. This will be passed to the children before ev
 */
private void duplicateTouchEventForChildren(MotionEvent ev, MotionEvent... pendingEvents) {
    if (ev == null) {
        return;
    }
    for (int i = getChildCount() - 1; 0 <= i; i--) {
        View childView = getChildAt(i);
        if (childView != null) {
            Rect childRect = new Rect();
            childView.getHitRect(childRect);
            MotionEvent event = MotionEvent.obtainNoHistory(ev);
            if (!childRect.contains((int) event.getX(), (int) event.getY())) {
                continue;
            }
            float offsetX = -childView.getLeft();
            float offsetY = -childView.getTop();
            boolean consumed = false;
            if (pendingEvents != null) {
                for (MotionEvent pe : pendingEvents) {
                    if (pe != null) {
                        MotionEvent peAdjusted = MotionEvent.obtainNoHistory(pe);
                        peAdjusted.offsetLocation(offsetX, offsetY);
                        consumed |= childView.dispatchTouchEvent(peAdjusted);
                    }
                }
            }
            event.offsetLocation(offsetX, offsetY);
            consumed |= childView.dispatchTouchEvent(event);
            if (consumed) {
                break;
            }
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:43,代碼來源:TouchInterceptionLayout.java

示例2: onTouchForwarded

import android.view.MotionEvent; //導入方法依賴的package包/類
private boolean onTouchForwarded(MotionEvent srcEvent) {
    boolean z = true;
    View src = this.mSrc;
    ListPopupWindow popup = getPopup();
    if (popup == null || !popup.isShowing()) {
        return false;
    }
    DropDownListView dst = popup.mDropDownList;
    if (dst == null || !dst.isShown()) {
        return false;
    }
    MotionEvent dstEvent = MotionEvent.obtainNoHistory(srcEvent);
    toGlobalMotionEvent(src, dstEvent);
    toLocalMotionEvent(dst, dstEvent);
    boolean handled = dst.onForwardedEvent(dstEvent, this.mActivePointerId);
    dstEvent.recycle();
    int action = MotionEventCompat.getActionMasked(srcEvent);
    boolean keepForwarding;
    if (action == 1 || action == 3) {
        keepForwarding = false;
    } else {
        keepForwarding = true;
    }
    if (!(handled && keepForwarding)) {
        z = false;
    }
    return z;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:29,代碼來源:ListPopupWindow.java

示例3: obtainMotionEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
private MotionEvent obtainMotionEvent(MotionEvent base, int action) {
    MotionEvent ev = MotionEvent.obtainNoHistory(base);
    ev.setAction(action);
    return ev;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:TouchInterceptionLayout.java


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