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


Java MotionEvent.getHistoricalEventTime方法代碼示例

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


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

示例1: pinchVelocity

import android.view.MotionEvent; //導入方法依賴的package包/類
/**
 * <p>Calculates the pinch velocity for the last <code>timeWindow</code> milliseconds.</p>
 * @param event
 * @param pointerA id of pointer A
 * @param pointerB id of pointer B
 * @param timeWindow
 * @return spacing between both pointers
 */
public static final float pinchVelocity(MotionEvent event, int pointerA, int pointerB, long timeWindow) {
	int indexA = event.findPointerIndex(pointerA);
	int indexB = event.findPointerIndex(pointerB);
	long eventTime = event.getEventTime();
	long timeDelta = 0;
	float previousSpacing = spacingByIndex(event, indexA, indexB);
	float scale = 1;
	for(int i = 0, n = event.getHistorySize(); i < n && timeDelta < timeWindow; i++) {
		int index = (n - 1) - i;
		float x = event.getHistoricalX(indexA, index) - event.getHistoricalX(indexB, index);
		float y = event.getHistoricalY(indexA, index) - event.getHistoricalY(indexB, index);
		float spacing = (float) Math.sqrt(x * x + y * y);
		scale *= previousSpacing / spacing;
		previousSpacing = spacing;
		timeDelta = eventTime - event.getHistoricalEventTime(index);
	}
	return (float) Math.pow(Math.pow(scale, 1d / timeWindow), 1000d);
}
 
開發者ID:martinwithaar,項目名稱:PinchToZoom,代碼行數:27,代碼來源:MultiTouchListener.java

示例2: onMoveEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
private void onMoveEvent(final int x, final int y, final long eventTime, final MotionEvent me) {
    if (DEBUG_MOVE_EVENT) {
        printTouchEvent("onMoveEvent:", x, y, eventTime);
    }
    if (mIsTrackingForActionDisabled) {
        return;
    }

    if (sGestureEnabler.shouldHandleGesture() && me != null) {
        // Add historical points to gesture path.
        final int pointerIndex = me.findPointerIndex(mPointerId);
        final int historicalSize = me.getHistorySize();
        for (int h = 0; h < historicalSize; h++) {
            final int historicalX = (int)me.getHistoricalX(pointerIndex, h);
            final int historicalY = (int)me.getHistoricalY(pointerIndex, h);
            final long historicalTime = me.getHistoricalEventTime(h);
            onGestureMoveEvent(historicalX, historicalY, historicalTime,
                    false /* isMajorEvent */, null);
        }
    }

    if (isShowingMoreKeysPanel()) {
        final int translatedX = mMoreKeysPanel.translateX(x);
        final int translatedY = mMoreKeysPanel.translateY(y);
        mMoreKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime);
        onMoveKey(x, y);
        if (mIsInSlidingKeyInput) {
            sDrawingProxy.showSlidingKeyInputPreview(this);
        }
        return;
    }
    onMoveEventInternal(x, y, eventTime);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:34,代碼來源:PointerTracker.java


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