您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
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; } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。