Example usage for android.view ViewConfiguration getScaledTouchSlop

List of usage examples for android.view ViewConfiguration getScaledTouchSlop

Introduction

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

Prototype

public int getScaledTouchSlop() 

Source Link

Usage

From source file:se.kth.csc.stayawhile.swipe.QueueTouchListener.java

/**
 * Constructs a new swipe touch listener for the given {@link android.support.v7.widget.RecyclerView}
 *
 * @param recyclerView The recycler view whose items should be dismissable by swiping.
 * @param listener     The listener for the swipe events.
 */// ww  w.  j a  v a 2s .  c  o m
public QueueTouchListener(RecyclerView recyclerView, QueueSwipeListener listener) {
    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;
    mQueueSwipeListener = listener;

    /**
     * This will ensure that this QueueTouchListener is paused during list view scrolling.
     * If a scroll listener is already assigned, the caller should still pass scroll changes through
     * to this listener.
     */
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            setEnabled(newState != RecyclerView.SCROLL_STATE_DRAGGING);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        }
    });
}

From source file:com.evilduck.animtest.DraggedPanelLayout.java

public void initAttrs(Context context, AttributeSet attrs) {
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DraggedPanelLayout, 0, 0);

    try {/*from w  w  w  . j a v  a2 s  .  c  o  m*/
        parallaxFactor = a.getFloat(R.styleable.DraggedPanelLayout_parallax_factor, PARALLAX_FACTOR);
        if (parallaxFactor < 0.1 || parallaxFactor > 0.9) {
            parallaxFactor = PARALLAX_FACTOR;
        }

        int defaultHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100,
                getResources().getDisplayMetrics());
        bottomPanelPeekHeight = a.getDimensionPixelSize(R.styleable.DraggedPanelLayout_bottom_panel_height,
                defaultHeight);
        int shadowDrawableId = a.getResourceId(R.styleable.DraggedPanelLayout_shadow_drawable, -1);
        if (shadowDrawableId != -1) {
            shadowDrawable = getResources().getDrawable(shadowDrawableId);
            willDrawShadow = true;
            setWillNotDraw(!willDrawShadow);
        }
    } finally {
        a.recycle();
    }

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    touchSlop = configuration.getScaledTouchSlop();
}

From source file:com.huaop2p.yqs.widget.scroll.ScrollableLayout.java

public void init(Context context) {
    this.context = context;
    mHelper = new ScrollableHelper();
    mScroller = new Scroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    sysVersion = Build.VERSION.SDK_INT;/*  ww  w.j a v  a2s .c om*/
}

From source file:ti.modules.titanium.ui.widget.TiUIEditText.java

/**
 * Initializes this view's settings and member variables.
 * This method is only expected to be called once from this class' constructor.
 *///from  w  ww. ja va  2 s .c o m
private void initializeView() {
    // Fetch the system's min touch move distance until it's considered to be a drag event.
    // Note: This is the same setting Android's ScrollViews use.
    ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
    if (viewConfiguration != null) {
        this.minDragStartDistance = viewConfiguration.getScaledTouchSlop();
    }

    // Set up this view for nested scrolling.
    this.nestedScrollingHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}

From source file:com.brandon.mailbox.RecyclerSwipeListener.java

/**
 * Constructs a new swipe touch listener for the given {@link android.support.v7.widget.RecyclerView}
 *
 * @param recyclerView The recycler view whose items should be dismissable by swiping.
 * @param listener     The listener for the swipe events.
 *//*from   w  w w .  j a  va 2  s.  c  o  m*/
public RecyclerSwipeListener(RecyclerView recyclerView, SwipeListener listener) {
    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;
    mSwipeListener = listener;
    /**
     * This will ensure that this SwipeableRecyclerViewTouchListener is paused during list view scrolling.
     * If a scroll listener is already assigned, the caller should still pass scroll changes through
     * to this listener.
     */
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            setEnabled(newState != RecyclerView.SCROLL_STATE_DRAGGING);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        }
    });
}

From source file:com.douban.rexxar.view.NestedWebView.java

public NestedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);//from   w  ww  . j a v a  2s  .co  m
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    WebSettings webSettings = getSettings();
    webSettings.setJavaScriptEnabled(true);
    // 
    addJavascriptInterface(new NestScrollHelper(), "Android_NestScrollHelper");
    // ?
    setOverScrollMode(OVER_SCROLL_NEVER);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mScroller = new OverScroller(getContext());
}

From source file:br.com.devmix.baseapp.listener.OnSwipeableRecyclerViewTouchListener.java

/**
 * Constructs a new swipe touch listener for the given {@link android.support.v7.widget.RecyclerView}
 *
 * @param recyclerView The recycler view whose items should be dismissable by swiping.
 * @param listener     The listener for the swipe events.
 *///from   w ww.  j a  v  a  2 s .  c  o m
public OnSwipeableRecyclerViewTouchListener(RecyclerView recyclerView, SwipeListener listener) {
    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;
    mSwipeListener = listener;

    /**
     * This will ensure that this SwipeableRecyclerViewTouchListener is paused during list view scrolling.
     * If a scroll listener is already assigned, the caller should still pass scroll changes through
     * to this listener.
     */
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            setEnabled(newState != RecyclerView.SCROLL_STATE_DRAGGING);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
        }
    });
}

From source file:com.itude.mobile.mobbl.blueprint.app.view.listeners.SwipeDismissRecyclerViewTouchListener.java

public SwipeDismissRecyclerViewTouchListener(Builder builder) {
    ViewConfiguration vc = ViewConfiguration.get(builder.mRecyclerView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = builder.mRecyclerView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    mRecyclerView = builder.mRecyclerView;
    mCallbacks = builder.mCallbacks;/*from   w  w w  . j  av  a 2s .  c  o  m*/
    mIsVertical = builder.mIsVertical;
    mItemTouchCallback = builder.mItemTouchCallback;
}

From source file:br.com.halph.agendafeliz.util.SwipeableRecyclerViewTouchListener.java

/**
 * Constructs a new swipe touch listener for the given {@link android.support.v7.widget.RecyclerView}
 *
 * @param recyclerView The recycler view whose items should be dismissable by swiping.
 * @param listener     The listener for the swipe events.
 *///from   w  w  w .j av  a  2  s  .  c  om
public SwipeableRecyclerViewTouchListener(RecyclerView recyclerView, SwipeListener listener) {
    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;
    mSwipeListener = listener;

    /**
     * This will ensure that this SwipeableRecyclerViewTouchListener is paused during list view scrolling.
     * If a scroll listener is already assigned, the caller should still pass scroll changes through
     * to this listener.
     */
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            setEnabled(newState != RecyclerView.SCROLL_STATE_DRAGGING);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        }
    });
}

From source file:org.creativecommons.thelist.swipedismiss.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.
 *//* w  w  w  .  jav a 2 s  .  c o  m*/
public SwipeDismissRecyclerViewTouchListener(RecyclerView recyclerView, final SwipeRefreshLayout layout,
        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;
    mRefreshLayout = layout;
    mCallbacks = callbacks;
}