List of usage examples for android.view ViewConfiguration getScaledTouchSlop
public int getScaledTouchSlop()
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/* w w w . j ava2 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.haarman.listviewanimations.itemmanipulation.SwipeDismissListViewTouchListener.java
/** * Constructs a new swipe-to-dismiss touch listener for the given list view. * * @param listView//from w ww . j a v a2s . c om * 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. */ public SwipeDismissListViewTouchListener(AbsListView listView, OnDismissCallback callback, SwipeOnScrollListener onScroll) { ViewConfiguration vc = ViewConfiguration.get(listView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); mListView = listView; mCallback = callback; onScroll.setTouchListener(this); mListView.setOnScrollListener(onScroll); }
From source file:cn.bingoogolapple.refreshlayout.BGAStickyNavLayout.java
private void init(Context context) { setOrientation(VERTICAL);/*w w w. ja v a2s .c o m*/ mOverScroller = new OverScroller(context); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); }
From source file:com.example.administrator.myapplication.recycler_swipe.swpie.SwipeMenuLayout.java
public SwipeMenuLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout); mLeftViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_leftViewId, mLeftViewId); mContentViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_contentViewId, mContentViewId); mRightViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_rightViewId, mRightViewId); typedArray.recycle();//from ww w.ja v a 2 s . co m ViewConfiguration configuration = ViewConfiguration.get(getContext()); mScaledTouchSlop = configuration.getScaledTouchSlop(); mScaledMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mScaledMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity(); mScroller = new OverScroller(getContext()); }
From source file:com.personal.taskmanager2.utilities.RecyclerViewTouchListener.java
public RecyclerViewTouchListener(RecyclerView recyclerView, SwipeRefreshLayout refreshLayout, DismissCallbacks callbacks) {//from w ww .j av a2s . c o m ViewConfiguration vc = ViewConfiguration.get(recyclerView.getContext()); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = recyclerView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); mSlop = vc.getScaledTouchSlop(); mRecyclerView = recyclerView; mRefreshLayout = refreshLayout; mCallbacks = callbacks; }
From source file:com.android2.calculator3.view.CalculatorPadView.java
private void setup() { ViewConfiguration vc = ViewConfiguration.get(getContext()); mMinimumFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = vc.getScaledMaximumFlingVelocity(); mTouchSlop = vc.getScaledTouchSlop(); mOffset = getResources().getDimensionPixelSize(R.dimen.pad_page_margin); mOverlayMargin = getResources().getDimensionPixelSize(R.dimen.shadow_margin); getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override//from w w w .j ava2 s . c om public void onGlobalLayout() { if (android.os.Build.VERSION.SDK_INT >= 16) { getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { getViewTreeObserver().removeGlobalOnLayoutListener(this); } initializeLayout(getState()); } }); }
From source file:com.iangclifton.auid.horizontaliconview.HorizontalIconView.java
/** * Perform one-time initialization/*w ww . jav a2s .c om*/ * * @param context Context to load Resources and ViewConfiguration data */ private void init(Context context) { final Resources res = context.getResources(); mIconSize = res.getDimensionPixelSize(R.dimen.icon_size); mIconSpacing = res.getDimensionPixelSize(R.dimen.icon_spacing); // Cache ViewConfiguration values final ViewConfiguration config = ViewConfiguration.get(context); mTouchSlop = config.getScaledTouchSlop(); mMinimumVelocity = config.getScaledMinimumFlingVelocity(); mMaximumVelocity = config.getScaledMaximumFlingVelocity(); mOverflingDistance = config.getScaledOverflingDistance(); mOverscrollDistance = config.getScaledOverscrollDistance(); // Verify this View will be drawn setWillNotDraw(false); // Other setup mEdgeEffectLeft = new EdgeEffectCompat(context); mEdgeEffectRight = new EdgeEffectCompat(context); mScroller = new OverScroller(context); setFocusable(true); }
From source file:com.tr4android.recyclerviewslideitem.SwipeItem.java
public SwipeItem(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // scroll threshold ViewConfiguration vc = ViewConfiguration.get(this.getContext()); mTouchSlop = vc.getScaledTouchSlop(); mDragHelper = ViewDragHelper.create(this, new DragHelperCallback()); }
From source file:com.taobao.weex.ui.view.listview.BaseBounceView.java
private void init(Context context) { ViewConfiguration config = ViewConfiguration.get(getContext()); mTouchSlop = config.getScaledTouchSlop(); mScroller = new Scroller(context); mView = createBounceView(context);/*from w ww .ja va 2 s .c om*/ addView(mView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mRefreshLayout = createBounceHeaderView(context); if (mRefreshLayout != null) { addView(mRefreshLayout.getView(), LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } mLoadMoreLayout = createBounceFooterView(context); if (mLoadMoreLayout != null) { addView(mLoadMoreLayout.getView(), LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } }
From source file:com.andview.refreshview.swipe.SwipeMenuLayout.java
public SwipeMenuLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout); mLeftViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_leftViewId, mLeftViewId); mContentViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_contentViewId, mContentViewId); mRightViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_rightViewId, mRightViewId); typedArray.recycle();// w w w . jav a 2s.c om ViewConfiguration mViewConfig = ViewConfiguration.get(getContext()); mScaledTouchSlop = mViewConfig.getScaledTouchSlop(); mScroller = new OverScroller(getContext()); mScaledMinimumFlingVelocity = mViewConfig.getScaledMinimumFlingVelocity(); mScaledMaximumFlingVelocity = mViewConfig.getScaledMaximumFlingVelocity(); }