android.view.VelocityTracker的实例源码

项目:GitHub    文件Utils.java   
public static void veLocityTrackerPointerUpCleanUpIfNecessary(MotionEvent ev,VeLocityTracker tracker) {

    // Check the dot product of current veLocities.
    // If the pointer that left was opposing another veLocity vector,clear.
    tracker.computeCurrentVeLocity(1000,mMaximumFlingVeLocity);
    final int upIndex = ev.getActionIndex();
    final int id1 = ev.getPointerId(upIndex);
    final float x1 = tracker.getXVeLocity(id1);
    final float y1 = tracker.getYVeLocity(id1);
    for (int i = 0,count = ev.getPointerCount(); i < count; i++) {
        if (i == upIndex)
            continue;

        final int id2 = ev.getPointerId(i);
        final float x = x1 * tracker.getXVeLocity(id2);
        final float y = y1 * tracker.getYVeLocity(id2);

        final float dot = x + y;
        if (dot < 0) {
            tracker.clear();
            break;
        }
    }
}
项目:GitHub    文件DirectionalViewpager.java   
/**
 * Start a fake drag of the pager.
 *
 * @return true if the fake drag began successfully,false if it Could not be started.
 */
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    if (isHorizontal()) {
        mInitialMotionX = mLastMotionX = 0;
    } else {
        mInitialMotionY = mLastMotionY = 0;
    }
    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    } else {
        mVeLocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time,time,MotionEvent.ACTION_DOWN,0);
    mVeLocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:GitHub    文件VerticalViewPager.java   
/**
 * Start a fake drag of the pager.
 * <p/>
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view,while still letting the ViewPager
 * control the snapping motion and fling behavior. (e.g. parallax-scrolling tabs.)
 * Call {@link #fakeDragBy(float)} to simulate the actual drag motion. Call
 * {@link #endFakeDrag()} to complete the fake drag and fling as necessary.
 * <p/>
 * <p>During a fake drag the ViewPager will ignore all touch events. If a real drag
 * is already in progress,this method will return false.
 *
 * @return true if the fake drag began successfully,false if it Could not be started.
 * @see #fakeDragBy(float)
 * @see #endFakeDrag()
 */
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    mInitialMotionY = mLastMotionY = 0;
    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    } else {
        mVeLocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time,0);
    mVeLocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:GitHub    文件VerticalViewPager.java   
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    final VeLocityTracker veLocityTracker = mVeLocityTracker;
    veLocityTracker.computeCurrentVeLocity(1000,mMaximumVeLocity);
    int initialVeLocity = (int) VeLocityTrackerCompat.getYVeLocity(
            veLocityTracker,mActivePointerId);
    mPopulatePending = true;
    final int height = getClientHeight();
    final int scrollY = getScrollY();
    final ItemInfo ii = infoForCurrentScrollPosition();
    final int currentPage = ii.position;
    final float pageOffset = (((float) scrollY / height) - ii.offset) / ii.heightFactor;
    final int totalDelta = (int) (mLastMotionY - mInitialMotionY);
    int nextPage = determineTargetPage(currentPage,pageOffset,initialVeLocity,totalDelta);
    setCurrentItemInternal(nextPage,true,initialVeLocity);
    endDrag();

    mFakeDragging = false;
}
项目:GitHub    文件BaseViewPager.java   
/**
 * Start a fake drag of the pager.
 * <p/>
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view,false if it Could not be started.
 * @see #fakeDragBy(float)
 * @see #endFakeDrag()
 */
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    if (isHorizontalDirection()) {
        mInitialMotionX = mLastMotionX = 0;
    } else if (isverticalDirection()) {
        mInitialMotionY = mLastMotionY = 0;
    }
    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    } else {
        mVeLocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time,0);
    mVeLocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:GitHub    文件BaseViewPager.java   
private void endFakeDragHorizontally() {
    if (mAdapter != null) {
        final VeLocityTracker veLocityTracker = mVeLocityTracker;
        veLocityTracker.computeCurrentVeLocity(1000,mMaximumVeLocity);
        int initialVeLocity = (int) VeLocityTrackerCompat.getXVeLocity(
                veLocityTracker,mActivePointerId);
        mPopulatePending = true;
        final int width = getClientWidth();
        final int scrollX = getScrollX();
        final ItemInfo ii = infoForCurrentScrollPosition();
        final int currentPage = ii.position;
        final float pageOffset = (((float) scrollX / width) - ii.offset) / ii.widthFactor;
        final int totalDelta = (int) (mLastMotionX - mInitialMotionX);
        int nextPage = determineTargetPage(currentPage,totalDelta);
        setCurrentItemInternal(nextPage,initialVeLocity);
    }
    endDrag();

    mFakeDragging = false;
}
项目:GitHub    文件BaseViewPager.java   
private void endFakeDragVertically() {
    if (mAdapter != null) {
        final VeLocityTracker veLocityTracker = mVeLocityTracker;
        veLocityTracker.computeCurrentVeLocity(1000,mMaximumVeLocity);
        int initialVeLocity = (int) VeLocityTrackerCompat.getYVeLocity(
                veLocityTracker,mActivePointerId);
        mPopulatePending = true;
        final int height = getClientHeight();
        final int scrollY = getScrollY();
        final ItemInfo ii = infoForCurrentScrollPosition();
        final int currentPage = ii.position;
        final float pageOffset = (((float) scrollY / height) - ii.offset) / ii.heightFactor;
        final int totalDelta = (int) (mLastMotionY - mInitialMotionY);
        int nextPage = determineTargetPage(currentPage,initialVeLocity);
    }
    endDrag();

    mFakeDragging = false;
}
项目:OpenWithX    文件ResolverDrawerLayout.java   
public ResolverDrawerLayout(Context context,AttributeSet attrs,int defStyleAttr) {
    super(context,attrs,defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs,R.styleable.ResolverDrawerLayout,defStyleAttr,0);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ResolverDrawerLayout_android_maxWidth,-1);
    mMaxCollapsedHeight = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeight,0);
    mMaxCollapsedHeightSmall = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall,mMaxCollapsedHeight);
    a.recycle();

    mScrollIndicatorDrawable = context.getDrawable(R.drawable.scroll_indicator_material);

    mScroller = new OverScroller(context,AnimationUtils.loadInterpolator(context,android.R.interpolator.decelerate_quint));
    mVeLocityTracker = VeLocityTracker.obtain();

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVeLocity = vc.getScaledMinimumFlingVeLocity();

    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
项目:KUtils-master    文件BGAViewPager.java   
private float getXVeLocity() {
    float xVeLocity = 0;
    Class viewpagerClass = ViewPager.class;
    try {
        Field veLocityTrackerField = viewpagerClass.getDeclaredField("mVeLocityTracker");
        veLocityTrackerField.setAccessible(true);
        VeLocityTracker veLocityTracker = (VeLocityTracker) veLocityTrackerField.get(this);

        Field activePointerIdField = viewpagerClass.getDeclaredField("mActivePointerId");
        activePointerIdField.setAccessible(true);

        Field maximumVeLocityField = viewpagerClass.getDeclaredField("mMaximumVeLocity");
        maximumVeLocityField.setAccessible(true);
        int maximumVeLocity = maximumVeLocityField.getInt(this);

        veLocityTracker.computeCurrentVeLocity(1000,maximumVeLocity);
        xVeLocity = VeLocityTrackerCompat.getXVeLocity(veLocityTracker,activePointerIdField.getInt(this));
    } catch (Exception e) {
    }
    return xVeLocity;
}
项目:StackCardsView    文件SwipetouchHelper.java   
private void onTouchRelease() {
    final StackCardsView.LayoutParams lp = (StackCardsView.LayoutParams) mTouchChild.getLayoutParams();
    if (lp.fastdismissAllowed) {
        final VeLocityTracker veLocityTracker2 = mVeLocityTracker;
        veLocityTracker2.computeCurrentVeLocity(1000,mMaxVeLocity);
        float xv = veLocityTracker2.getXVeLocity(mActivePointerId);
        float yv = veLocityTracker2.getYVeLocity(mActivePointerId);
        if (doFastdisappear(xv,yv)) {
            resetTouch();
            return;
        }
    }
    if (isdistanceAllowdismiss() && isDirectionAllowdismiss()) {
        doslowdisappear();
    } else {
        animatetoInitPos();
    }
    resetTouch();
    mswipeview.onCoverStatusChanged(isCoverIdle());
}
项目:PageScrollView    文件PageScrollView.java   
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mVirtualCount == 0 || !isEnabled()) {
        return super.onTouchEvent(event);
    }
    if (event.getAction() == MotionEvent.ACTION_DOWN && event.getEdgeFlags() != 0) {
        return false;
    }
    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    }
    mVeLocityTracker.addMovement(event);
    final int action = event.getAction() & MotionEventCompat.ACTION_MASK;
    if (action == MotionEvent.ACTION_MOVE) {
        handletouchActionMove(event);
    } else {
        if (action == MotionEvent.ACTION_DOWN) {
            handletouchActionDown(event);
        }
        if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
            handletouchActionUp(event);
        }
    }
    return true;
}
项目:PureMusic    文件LyricView.java   
@Override
public boolean onTouchEvent(MotionEvent event) {

    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    }
    mVeLocityTracker.addMovement(event);
    switch (event.getAction()) {
        case MotionEvent.ACTION_CANCEL:
            actionCancel(event);
            break;
        case MotionEvent.ACTION_DOWN:
            actionDown(event);
            break;
        case MotionEvent.ACTION_MOVE:
            actionMove(event);
            break;
        case MotionEvent.ACTION_UP:
            actionUp(event);
            break;
        default:
            break;
    }
    invalidateView();
    return true;
}
项目:KUtils    文件BGAViewPager.java   
private float getXVeLocity() {
    float xVeLocity = 0;
    Class viewpagerClass = ViewPager.class;
    try {
        Field veLocityTrackerField = viewpagerClass.getDeclaredField("mVeLocityTracker");
        veLocityTrackerField.setAccessible(true);
        VeLocityTracker veLocityTracker = (VeLocityTracker) veLocityTrackerField.get(this);

        Field activePointerIdField = viewpagerClass.getDeclaredField("mActivePointerId");
        activePointerIdField.setAccessible(true);

        Field maximumVeLocityField = viewpagerClass.getDeclaredField("mMaximumVeLocity");
        maximumVeLocityField.setAccessible(true);
        int maximumVeLocity = maximumVeLocityField.getInt(this);

        veLocityTracker.computeCurrentVeLocity(1000,activePointerIdField.getInt(this));
    } catch (Exception e) {
    }
    return xVeLocity;
}
项目:Renrentou    文件XCCycleViewPager.java   
/**
 * Start a fake drag of the pager.
 *
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view,while still letting the ViewPager
 * control the snapping motion and fling behavior. (e.g. parallax-scrolling tabs.)
 * Call {@link #fakeDragBy(float)} to simulate the actual drag motion. Call
 * {@link #endFakeDrag()} to complete the fake drag and fling as necessary.
 *
 * <p>During a fake drag the ViewPager will ignore all touch events. If a real drag
 * is already in progress,false if it Could not be started.
 *
 * @see #fakeDragBy(float)
 * @see #endFakeDrag()
 */
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    mInitialMotionX = mLastMotionX = 0;
    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    } else {
        mVeLocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time,0);
    mVeLocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:Renrentou    文件XCCycleViewPager.java   
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    final VeLocityTracker veLocityTracker = mVeLocityTracker;
    veLocityTracker.computeCurrentVeLocity(1000,mMaximumVeLocity);
    int initialVeLocity = (int) VeLocityTrackerCompat.getXVeLocity(
            veLocityTracker,mActivePointerId);
    mPopulatePending = true;
    final int width = getClientWidth();
    final int scrollX = getScrollX();
    final ItemInfo ii = infoForCurrentScrollPosition();
    final int currentPage = ii.position;
    final float pageOffset = (((float) scrollX / width) - ii.offset) / ii.widthFactor;
    final int totalDelta = (int) (mLastMotionX - mInitialMotionX);
    int nextPage = determineTargetPage(currentPage,initialVeLocity);
    endDrag();

    mFakeDragging = false;
}
项目:VerticalWebView    文件VerticalParentViewPager.java   
/**
 * Start a fake drag of the pager.
 *
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view,0);
    mVeLocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:VerticalWebView    文件VerticalParentViewPager.java   
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    final VeLocityTracker veLocityTracker = mVeLocityTracker;
    veLocityTracker.computeCurrentVeLocity(1000,initialVeLocity);
    endDrag();

    mFakeDragging = false;
}
项目:android-project-gallery    文件ViewPagerCompat.java   
/**
 * Start a fake drag of the pager.
 *
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view,0);
    mVeLocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:TextReader    文件DirectionalViewpager.java   
/**
 * Start a fake drag of the pager.
 *
 * @return true if the fake drag began successfully,0);
    mVeLocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:YViewPagerDemo    文件YViewPager.java   
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    mInitialMotionX = mLastMotionX = 0;
    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    } else {
        mVeLocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time,0);
    mVeLocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:boohee_v5.6    文件ViewPager.java   
public void endFakeDrag() {
    if (this.mFakeDragging) {
        if (this.mAdapter != null) {
            VeLocityTracker veLocityTracker = this.mVeLocityTracker;
            veLocityTracker.computeCurrentVeLocity(1000,(float) this.mMaximumVeLocity);
            int initialVeLocity = (int) VeLocityTrackerCompat.getXVeLocity(veLocityTracker,this.mActivePointerId);
            this.mPopulatePending = true;
            int width = getClientWidth();
            int scrollX = getScrollX();
            ItemInfo ii = infoForCurrentScrollPosition();
            setCurrentItemInternal(determineTargetPage(ii.position,((((float) scrollX) / ((float) width)) - ii.offset) / ii.widthFactor,(int) (this.mLastMotionX - this.mInitialMotionX)),initialVeLocity);
        }
        endDrag();
        this.mFakeDragging = false;
        return;
    }
    throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
}
项目:android-project-gallery    文件ViewPagerCompat.java   
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    final VeLocityTracker veLocityTracker = mVeLocityTracker;
    veLocityTracker.computeCurrentVeLocity(1000,initialVeLocity);
    endDrag();

    mFakeDragging = false;
}
项目:letv    文件ViewPager.java   
public boolean beginFakeDrag() {
    if (this.mIsBeingDragged) {
        return false;
    }
    this.mFakeDragging = true;
    setScrollState(1);
    this.mLastMotionX = 0.0f;
    this.mInitialMotionX = 0.0f;
    if (this.mVeLocityTracker == null) {
        this.mVeLocityTracker = VeLocityTracker.obtain();
    } else {
        this.mVeLocityTracker.clear();
    }
    long time = SystemClock.uptimeMillis();
    MotionEvent ev = MotionEvent.obtain(time,0.0f,0);
    this.mVeLocityTracker.addMovement(ev);
    ev.recycle();
    this.mFakeDragBeginTime = time;
    return true;
}
项目:boohee_v5.6    文件BottomSheetBehavior.java   
public boolean onTouchEvent(CoordinatorLayout parent,V child,MotionEvent event) {
    if (!child.isShown()) {
        return false;
    }
    int action = MotionEventCompat.getActionMasked(event);
    if (this.mState == 1 && action == 0) {
        return true;
    }
    this.mViewDragHelper.processtouchEvent(event);
    if (action == 0) {
        reset();
    }
    if (this.mVeLocityTracker == null) {
        this.mVeLocityTracker = VeLocityTracker.obtain();
    }
    this.mVeLocityTracker.addMovement(event);
    if (action != 2 || Math.abs(((float) this.mInitialY) - event.getY()) <= ((float) this.mViewDragHelper.getTouchSlop())) {
        return true;
    }
    this.mViewDragHelper.captureChildView(child,event.getPointerId(event.getActionIndex()));
    return true;
}
项目:OSchina_resources_android    文件BannerView.java   
public BannerView(Context context,defStyleAttr);
    setonClickListener(this);
    mScroller = new Scroller(context);
    mVeLocityTracker = VeLocityTracker.obtain();
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getdisplayMetrics().density;

    mMaximumVeLocity = configuration.getScaledMaximumFlingVeLocity();

    TypedArray array = context.obtainStyledAttributes(attrs,R.styleable.BannerView);
    mHorizontalOffset = array.getDimension(R.styleable.BannerView_horizontal_offset,0);
    mVerticalOffset = array.getDimension(R.styleable.BannerView_vertical_offset,0);
    duration = array.getInt(R.styleable.BannerView_scroll_duration,500);
    array.recycle();

}
项目:WeatherStream    文件Confetto.java   
public boolean onTouchDown(MotionEvent event) {
    final float x = event.getX();
    final float y= event.getY();

    if (doesLocationIntercept(x,y)) {
        this.touchOverride = true;
        this.overrideX = x;
        this.overrideY = y;
        this.overrideDeltaX = currentX - x;
        this.overrideDeltaY = currentY - y;

        veLocityTracker = VeLocityTracker.obtain();
        veLocityTracker.addMovement(event);

        return true;
    } else {
        return false;
    }
}
项目:RetroMusicPlayer    文件LyricView.java   
@Override
public boolean onTouchEvent(MotionEvent event) {

    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    }
    mVeLocityTracker.addMovement(event);
    switch (event.getAction()) {
        case MotionEvent.ACTION_CANCEL:
            actionCancel(event);
            break;
        case MotionEvent.ACTION_DOWN:
            actionDown(event);
            break;
        case MotionEvent.ACTION_MOVE:
            actionMove(event);
            break;
        case MotionEvent.ACTION_UP:
            actionUp(event);
            break;
        default:
            break;
    }
    invalidateView();
    return true;
}
项目:ChromeLikeTabSwitcher    文件AbstractTouchEventHandler.java   
/**
 * Handles,when a drag gesture has been started.
 *
 * @param event
 *         The motion event,which started the drag gesture,as an instance of the class {@link
 *         MotionEvent}. The motion event may not be null
 */
private void handleDown(@NonNull final MotionEvent event) {
    pointerId = event.getPointerId(0);

    if (veLocityTracker == null) {
        veLocityTracker = VeLocityTracker.obtain();
    } else {
        veLocityTracker.clear();
    }

    veLocityTracker.addMovement(event);
    onDown(event);
}
项目:Linphone4Android    文件SlidingDrawer.java   
private void prepareTracking(int position) {
    mTracking = true;
    mVeLocityTracker = VeLocityTracker.obtain();
    boolean opening = !mExpanded;

    if (opening) {
        mAnimatedacceleration = mMaximumacceleration;
        mAnimatedVeLocity = mMaximumMajorVeLocity;
        if (mInvert)
            mAnimationPosition = mTopOffset;
        else
            mAnimationPosition = mBottomOffset
                    + (mVertical ? getHeight() - mHandleHeight : getWidth()
                            - mHandleWidth);
        moveHandle((int) mAnimationPosition);
        mAnimating = true;
        mHandler.removeMessages(MSG_ANIMATE);
        long Now = SystemClock.uptimeMillis();
        mAnimationLastTime = Now;
        mCurrentAnimationTime = Now + ANIMATION_FRAME_DURATION;
        mAnimating = true;
    } else {
        if (mAnimating) {
            mAnimating = false;
            mHandler.removeMessages(MSG_ANIMATE);
        }
        moveHandle(position);
    }
}
项目:LaunchEnr    文件SwipeHelper.java   
SwipeHelper(int swipeDirection,Callback callback,Context context) {
    mCallback = callback;
    mHandler = new Handler();
    mSwipeDirection = swipeDirection;
    mVeLocityTracker = VeLocityTracker.obtain();
    mDensityScale =  context.getResources().getdisplayMetrics().density;
    mPagingTouchSlop = ViewConfiguration.get(context).getScaledPagingTouchSlop();

    mLongPresstimeout = (long) (ViewConfiguration.getLongPresstimeout() * 1.5f); // extra long-press!
    mFalsingThreshold = context.getResources().getDimensionPixelSize(
            R.dimen.swipe_helper_falsing_threshold);
    mFlingAnimationUtils = new FlingAnimationUtils(context,getMaxEscapeAnimDuration() / 1000f);
}
项目:AppFirCloud    文件SwipeMenuLayout.java   
/**
 * @param event 向VeLocityTracker添加MotionEvent
 * @see VeLocityTracker#obtain()
 * @see VeLocityTracker#addMovement(MotionEvent)
 */
private void acquireVeLocityTracker(final MotionEvent event) {
    if (null == mVeLocityTracker) {
        mVeLocityTracker = VeLocityTracker.obtain();
    }
    mVeLocityTracker.addMovement(event);
}
项目:boohee_v5.6    文件BooheeRulerView.java   
public boolean onTouchEvent(MotionEvent event) {
    int action = event.getAction();
    float xPosition = event.getX();
    if (this.veLocityTracker == null) {
        this.veLocityTracker = VeLocityTracker.obtain();
    }
    this.veLocityTracker.addMovement(event);
    switch (action) {
        case 0:
            this.isActionUp = false;
            this.scroller.forceFinished(true);
            if (this.animator != null) {
                this.animator.cancel();
                break;
            }
            break;
        case 1:
        case 3:
            this.isActionUp = true;
            this.f = true;
            countVeLocityTracker(event);
            return false;
        case 2:
            this.isActionUp = false;
            float off = xPosition - this.mLastX;
            if ((this.moveX > this.maxRightOffset || off >= 0.0f) && (this.moveX < this
                    .maxLeftOffset || off <= 0.0f)) {
                this.moveX += off;
                postInvalidate();
                break;
            }
    }
    this.mLastX = xPosition;
    return true;
}
项目:android_ui    文件VerticalPullHelper.java   
/**
 */
@Override
float computeOverScroll(int scrollX,int scrollY,boolean clampedX,boolean clampedY,VeLocityTracker tracker,int units) {
    if (scrollY != 0 && clampedY) {
        return tracker.getYVeLocity() / (units * 0.05f);
    }
    return 0;
}
项目:OSchina_resources_android    文件BannerView.java   
@Override
public boolean onTouchEvent(MotionEvent event) {
    isTouch = true;
    if (event.getPointerCount() >= 2) return false;
    if (mAdapter == null) return super.onTouchEvent(event);
    int count = mAdapter.getCount();
    if (count <= 1) return super.onTouchEvent(event);
    float x = event.getRawX();
    mVeLocityTracker.addMovement(event);
    int action = event.getAction();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            if (!mScroller.isFinished()) { // 如果上次的调用没有执行完就取消。
                return false;
            }
            mLastX = x;
            return true;
        case MotionEvent.ACTION_MOVE:
            requestdisallowInterceptTouchEvent(true);
            int dxMove = (int) (mLastX - x);
            mTotalDx += dxMove;
            onScrollBy(dxMove);
            mLastX = x;
            return true;
        case MotionEvent.ACTION_UP:
            isTouch = false;
            if (Math.abs(mTotalDx) <= 10)
                performClick();
        case MotionEvent.ACTION_CANCEL: {
            final VeLocityTracker veLocityTracker = mVeLocityTracker;
            veLocityTracker.computeCurrentVeLocity(1000,mMaximumVeLocity);
            mXVeLocity = veLocityTracker.getXVeLocity();
            isTouch = false;
            scrollToItem();
            scrollFinish(count);
            break;
        }
    }
    return super.onTouchEvent(event);
}
项目:EasyReader    文件horizontalscrollview.java   
private void init() {
    WindowManager wm = (WindowManager) getContext()
            .getSystemService(Context.WINDOW_SERVICE);
    windowWidth = wm.getDefaultdisplay().getWidth();//获取屏幕宽度
    halfWindowWidth = windowWidth / 2;
    oneThirdWindowWidth = windowWidth / visualCount;

    mVeLocityTracker = VeLocityTracker.obtain();
}
项目:FabulousFilter    文件ViewPagerBottomSheetBehavior.java   
@Override
public boolean onTouchEvent(CoordinatorLayout parent,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);
    // Record the veLocity
    if (action == MotionEvent.ACTION_DOWN) {
        reset();
    }
    if (mVeLocityTracker == null) {
        mVeLocityTracker = VeLocityTracker.obtain();
    }
    mVeLocityTracker.addMovement(event);
    // 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;
}
项目:RX_Demo    文件SwipeMenuLayout.java   
/**
 * @param event 向VeLocityTracker添加MotionEvent
 * @see VeLocityTracker#obtain()
 * @see VeLocityTracker#addMovement(MotionEvent)
 */
private void acquireVeLocityTracker(final MotionEvent event) {
    if (null == mVeLocityTracker) {
        mVeLocityTracker = VeLocityTracker.obtain();
    }
    mVeLocityTracker.addMovement(event);
}
项目:MyLife    文件ElasticDrawer.java   
protected float getXVeLocity(VeLocityTracker veLocityTracker) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        return veLocityTracker.getXVeLocity(mActivePointerId);
    }

    return veLocityTracker.getXVeLocity();
}
项目:letv    文件nestedScrollView.java   
private void initOrResetVeLocityTracker() {
    if (this.mVeLocityTracker == null) {
        this.mVeLocityTracker = VeLocityTracker.obtain();
    } else {
        this.mVeLocityTracker.clear();
    }
}
项目:Hotspot-master-devp    文件CoverFlowView.java   
private void touchBegan(MotionEvent event) {
        endAnimation();
        float x = event.getX();
        mTouchStartX = x;
        mTouchStartY = event.getY();
        mStartTime = AnimationUtils.currentAnimationTimeMillis();
        mStartOffset = mOffset;

        mTouchMoved = false;

        mTouchStartPos = (mTouchStartY / mHeight) * MOVE_POS_MULTIPLE - 5;
        mTouchStartPos /= 2;

        mVeLocity = VeLocityTracker.obtain();
        mVeLocity.addMovement(event);
//        float x = event.getX();
//        mTouchStartX = x;
//        mTouchStartY = event.getY();
//        mStartTime = AnimationUtils.currentAnimationTimeMillis();
//        mStartOffset = mOffset;
//
//        mTouchMoved = false;
//
//        mTouchStartPos = (x / mWidth) * MOVE_POS_MULTIPLE - 5;
//        mTouchStartPos /= 2;
//
//        mVeLocity = VeLocityTracker.obtain();
//        mVeLocity.addMovement(event);
    }

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...