Example usage for android.view ViewConfiguration getScaledMinimumFlingVelocity

List of usage examples for android.view ViewConfiguration getScaledMinimumFlingVelocity

Introduction

In this page you can find the example usage for android.view ViewConfiguration getScaledMinimumFlingVelocity.

Prototype

public int getScaledMinimumFlingVelocity() 

Source Link

Usage

From source file:com.kerkr.edu.recycleView.SwipeToDismissTouchListener.java

/**
 * Constructs a new swipe-to-dismiss OnItemTouchListener for RecyclerView
 *
 * @param recyclerView RecyclerView//from   w  ww.  ja va2s . c  om
 * @param callbacks    The callback to trigger when the user has indicated that she would like to
 *                     dismiss this view.
 */
public SwipeToDismissTouchListener(RecyclerView recyclerView, DismissCallbacks callbacks) {
    ViewConfiguration vc = ViewConfiguration.get(recyclerView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 4;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = recyclerView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    mRecyclerView = recyclerView;
    mCallbacks = callbacks;
}

From source file:com.baoyz.dribble.widget.SuperRecyclerView.java

public SuperRecyclerView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    super.setOnScrollListener(new OnScrollListener() {
        @Override/*ww  w  .j  av  a2 s. com*/
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
                if (layoutManager.findLastVisibleItemPosition() == (layoutManager.getItemCount() - 1)) {
                    setLoadMore(true);
                }
            }

            if (mScrollListener != null)
                mScrollListener.onScrollStateChanged(recyclerView, newState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (mScrollListener != null)
                mScrollListener.onScrolled(recyclerView, dx, dy);
        }
    });

    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mTouchDistance = viewConfiguration.getScaledOverflingDistance();
    mFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();

    mGesutureDetector = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (mOnQuickScrollListener != null && Math.abs(velocityY) > mFlingVelocity) {
                if (velocityY > 0)
                    mOnQuickScrollListener.onQuickDown();
                else
                    mOnQuickScrollListener.onQuickUp();
            }
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    });
}

From source file:com.amitupadhyay.aboutexample.ui.widget.BottomSheet.java

public BottomSheet(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    MIN_FLING_VELOCITY = viewConfiguration.getScaledMinimumFlingVelocity();
}

From source file:cn.meiqu.baseproject.view.superrecyclerview.swipe.SwipeDismissRecyclerViewTouchListener.java

/**
 * Constructs a new swipe-to-dismiss touch listener for the given list view.
 *
 * @param recyclerView The list view whose items should be dismissable.
 * @param callbacks    The callback to trigger when the user has indicated that she would like to
 *                     dismiss one or more list items.
 *//*  ww  w  . j  a  v  a 2s . co  m*/
public SwipeDismissRecyclerViewTouchListener(RecyclerView recyclerView, DismissCallbacks callbacks) {
    ViewConfiguration vc = ViewConfiguration.get(recyclerView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = recyclerView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    mRecyclerView = recyclerView;
    mCallbacks = callbacks;
}

From source file:com.github.shareme.gwsswwipetodismiss.library.SwipeDismissListViewTouchListener.java

/**
 * Constructs a new swipe-to-dismiss touch listener for the given list view.
 *
 * @param listView The list view whose items should be dismissable.
 * @param callback The callback to trigger when the user has indicated that she would like to
 *                 dismiss one or more list items.
 *//*w w  w. j  a  va  2 s  .c  om*/
public SwipeDismissListViewTouchListener(AbsListView listView, OnDismissCallback callback) {
    ViewConfiguration vc = ViewConfiguration.get(listView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime);
    mListView = listView;
    mCallback = callback;
}

From source file:com.lovejjfg.blogdemo.ui.BottomSheet.java

public BottomSheet(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    MIN_FLING_VELOCITY = viewConfiguration.getScaledMinimumFlingVelocity();
    MAX_FLING_VELOCITY = viewConfiguration.getScaledMaximumFlingVelocity();
}

From source file:com.baoyz.dribble.widget.SwipeHoverLayout.java

private void init() {

    ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
    mScrollDistance = DimenUtil.dp2px(getContext(), 60);
    mCanScrollDistance = viewConfiguration.getScaledOverscrollDistance();
    mFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
    mTouchSlop = viewConfiguration.getScaledTouchSlop();

    mGestureDetector = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {

        @Override/*from  www  .  j  a  v a2  s  .  c om*/
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            mFlingShow = Math.abs(velocityX) >= mFlingVelocity;
            return false;
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            int distance = Math.abs((int) (e2.getX() - mDownX));
            mDistanceShow = distance >= 10;
            dispatchSwipe(distance);
            return false;
        }

        @Override
        public boolean onDown(MotionEvent e) {
            mDownX = (int) e.getX();
            mFlingShow = false;
            mDistanceShow = false;
            return true;
        }
    });
}

From source file:com.app.gongza.libs.view.scrollablelayout.ScrollableLayout.java

private void init(Context context) {
    mHelper = new ScrollableHelper();
    mScroller = new Scroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:com.example.tt.pullrefresh.widget.CurveLayout.java

public CurveLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    MIN_FLING_VELOCITY = viewConfiguration.getScaledMinimumFlingVelocity();
}

From source file:com.waz.zclient.pages.main.conversationlist.views.listview.SwipeListView.java

/**
 * CTOR - checking animation const and wrapping context to get rod of overscroll animation.
 *//*from  w  ww .  j  av a 2 s. c o  m*/
public SwipeListView(Context context) {
    super(new ContextWrapperEdgeEffect(context));
    ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(Color.TRANSPARENT);

    touchSlop = 10; //ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    ViewConfiguration vc = ViewConfiguration.get(getContext());
    minFlingVelocity = vc.getScaledMinimumFlingVelocity();
    maxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    listRowMenuIndicatorMaxSwipeOffset = context.getResources()
            .getDimensionPixelSize(R.dimen.list__menu_indicator__max_swipe_offset);
}