您好,登錄后才能下訂單哦!
boolean com.citrix.client.gui.ReceiverView.onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
/** * Gesture detector callback */ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { boolean bResult = false; // 滾動模式 if (m_bScrollMode && !m_bIslockScreen) { // 鎖屏模式 } else if (m_bScrollMode && m_bIslockScreen) { } // 平移模式 else { m_motionEventListener.onFlingStart(); m_flingSupport.startFling(e1, e2, velocityX, velocityY); float xDistance = m_flingSupport.getXPixelsSinceLastCompute(); float yDistance = m_flingSupport.getYPixelsSinceLastCompute(); onScrollWorker(-1 * xDistance, -1 * yDistance); bResult = true; } return bResult; }
com.citrix.client.gui.FlingSupport
/** * This class is used to support flinging */ public class FlingSupport { private boolean m_bFlinging; /**<Are we in a fling now?*/ private long m_lastComputeTime; /**<The last time we recalculated*/ private long m_elapsedTime; /**<Time that has elapsed since the last compute time*/ private float m_decay; private float m_xVelocity; private float m_yVelocity; private final float INITIAL_DECAY = 1; private final float DECAY_CONSTANT = (float) 0.99; public FlingSupport() { } public void startFling(MotionEvent startEvent,MotionEvent moveEvent,float velocityX,float velocityY) { m_bFlinging = true; m_lastComputeTime = startEvent.getEventTime(); m_decay = INITIAL_DECAY; m_xVelocity = velocityX/1000; m_yVelocity = velocityY/1000; } public void logFling(long timeNowMs) { Log.i("ReceiverViewTest", "FlingSupport::m_bFlinging:"+m_bFlinging +",m_elapsedTime:"+m_elapsedTime +",m_decay:"+m_decay +",m_xVelocity:"+m_xVelocity +",m_yVelocity:"+m_yVelocity); } public void stopFling() { m_bFlinging = false; } /** * Recalculates the velocity */ public void reCompute() { if(m_bFlinging) { long timeNowMs = SystemClock.uptimeMillis(); m_elapsedTime = timeNowMs - m_lastComputeTime; m_lastComputeTime = timeNowMs; m_decay *= DECAY_CONSTANT; m_xVelocity *= m_decay; m_yVelocity *= m_decay; logFling(timeNowMs); } } /** * Returns how many x pixels we've moved since the last move * @return */ public float getXPixelsSinceLastCompute() { return getPixelsSinceLastCompute(true); } /** * Returns how many y pixels we've moved since the last move * @return */ public float getYPixelsSinceLastCompute() { return getPixelsSinceLastCompute(false); } private float getPixelsSinceLastCompute(boolean bX) { float pixels = 0; if(this.m_bFlinging) { // Distance = velocity * time so we look how long it has been since the last time we recomputed pixels = m_elapsedTime * (bX ? m_xVelocity : m_yVelocity); } return pixels; } /** * Returns flag indicating whether fling is in progress */ boolean bFlingInProgress() { return m_bFlinging; } }
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。