List of usage examples for android.view ViewConfiguration getScaledTouchSlop
public int getScaledTouchSlop()
From source file:io.realm.realmtasks.list.TouchHelper.java
public void attachToRecyclerView(RecyclerView recyclerView) { if (this.recyclerView == recyclerView) { return;/*from w ww. ja v a 2 s .c o m*/ } if (this.recyclerView != null) { destroyCallbacks(); } this.recyclerView = recyclerView; if (recyclerView == null) { return; } onItemTouchListener = new TasksOnItemTouchListener(recyclerView.getContext()); itemDecoration = new TasksItemDecoration(); recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext())); recyclerView.addOnItemTouchListener(onItemTouchListener); recyclerView.addItemDecoration(itemDecoration); recyclerView.setAdapter(adapter); final Context context = this.recyclerView.getContext(); final ViewConfiguration viewConfiguration = ViewConfiguration.get(context); scaledTouchSlop = viewConfiguration.getScaledTouchSlop(); DisplayMetrics metrics = new DisplayMetrics(); final WindowManager systemService = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); systemService.getDefaultDisplay().getMetrics(metrics); logicalDensity = metrics.density; adapter.setOnFirstItemUpdateListener(new OnFirstItemUpdateListener()); }
From source file:com.conduit.plastic.widget.NestedWebView.java
private void init() { this.mChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true);/*ww w . j a v a 2 s . c o m*/ ViewConfiguration configuration = ViewConfiguration.get(getContext()); this.mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); this.mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); this.mTouchSlop = configuration.getScaledTouchSlop(); this.directionDetector = new DirectionDetector(); this.density = getScale(); setOverScrollMode(View.OVER_SCROLL_NEVER); this.settings = getSettings(); // addJavascriptInterface(new JSGetContentHeight(), "InjectedObject"); Log.i(TAG, "max -- min Velocity = " + this.mMaximumVelocity + " -- " + this.mMinimumVelocity + " touchSlop = " + this.mTouchSlop); }
From source file:io.nuclei.cyto.ui.view.BottomSheetView.java
private void init(Context context) { ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mMinFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); mTouchSlop = viewConfiguration.getScaledTouchSlop(); setClickable(true);//from w ww . jav a2 s . c om mBackground = new View(context); mBackground.setBackgroundColor(mBackgroundColor = DEFAULT_BACKGROUND_COLOR); mBackground.setLayoutParams( new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mBackground.setVisibility(GONE); mBackground.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if ((mState & STATE_MOVING) != STATE_MOVING) { if ((mState & STATE_LOCKED) == STATE_LOCKED) removeState(STATE_LOCKED); setState(STATE_CLOSED); } } }); addView(mBackground); FrameLayout content = new FrameLayout(context); content.setLayoutParams( new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); content.setMinimumHeight(1); content.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); content.setClickable(true); addView(content); mContent = content; mOffsetHelper = new ViewOffsetHelper(mContent); onPrepare(); }
From source file:com.antew.redditinpictures.library.widget.SwipeListView.java
private void initialize(AttributeSet attrs) { // If we are in an IDE Preview, don't initialize. if (isInEditMode()) { return;// ww w . java 2 s . c om } if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); mFrontViewId = styled.getResourceId(R.styleable.SwipeListView_frontViewId, 0); mBackViewId = styled.getResourceId(R.styleable.SwipeListView_backViewId, 0); mCloseAllWhenScrolling = styled.getBoolean(R.styleable.SwipeListView_closeAllWhenScrolling, true); mOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_openOnLongPress, true); setSwipeDirection(styled.getInt(R.styleable.SwipeListView_swipeDirection, SWIPE_DIRECTION_BOTH)); } if (mFrontViewId == 0 || mBackViewId == 0) { throw new RuntimeException("You must specify a Front View and Back View"); } ViewConfiguration viewConfig = ViewConfiguration.get(getContext()); mTouchSlop = viewConfig.getScaledTouchSlop(); mMinFlingVelocity = viewConfig.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = viewConfig.getScaledMaximumFlingVelocity(); mAnimationTime = getResources().getInteger(android.R.integer.config_shortAnimTime); super.setOnScrollListener(mInternalOnScrollListener); super.setOnItemLongClickListener(mInternalOnItemLongClickListener); }
From source file:org.telegram.ui.Components.Switch.java
public Switch(Context context) { super(context); mThumbDrawable = context.getResources().getDrawable(R.drawable.switch_thumb); if (mThumbDrawable != null) { mThumbDrawable.setCallback(this); mThumbDrawable.setTintList(AppCompatResources.getColorStateList(context, R.color.tint_switch_thumb)); }/*from ww w. j ava 2 s .c o m*/ mTrackDrawable = context.getResources().getDrawable(R.drawable.switch_track); if (mTrackDrawable != null) { mTrackDrawable.setCallback(this); mTrackDrawable.setTintList(AppCompatResources.getColorStateList(context, R.color.tint_switch_track)); } if (AndroidUtilities.density < 1) { mSwitchMinWidth = AndroidUtilities.dp(30); } else { mSwitchMinWidth = 0; } mSwitchPadding = 0; mSplitTrack = false; final ViewConfiguration config = ViewConfiguration.get(context); mTouchSlop = config.getScaledTouchSlop(); mMinFlingVelocity = config.getScaledMinimumFlingVelocity(); refreshDrawableState(); setChecked(isChecked()); }
From source file:com.gitstudy.rili.liarbry.CalendarLayout.java
public CalendarLayout(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LinearLayout.VERTICAL); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CalendarLayout); mContentViewId = array.getResourceId(R.styleable.CalendarLayout_calendar_content_view_id, 0); mDefaultStatus = array.getInt(R.styleable.CalendarLayout_default_status, STATUS_EXPAND); mCalendarShowMode = array.getInt(R.styleable.CalendarLayout_calendar_show_mode, CALENDAR_SHOW_MODE_BOTH_MONTH_WEEK_VIEW); mGestureMode = array.getInt(R.styleable.CalendarLayout_gesture_mode, GESTURE_MODE_DEFAULT); array.recycle();/*from w w w .j ava 2s. c o m*/ mVelocityTracker = VelocityTracker.obtain(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.jp.fristandroidapp.widget.adview.AdViewFlow.java
private void init() { mLoadedViews = new LinkedList<View>(); mScroller = new Scroller(getContext()); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:ch.tutti.android.bottomsheet.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);/* ww w .j a va 2s .c o m*/ 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(); 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(); }
From source file:com.fortysevendeg.android.swipelistview.SwipeListViewTouchListener.java
/** * Constructor//from w ww . j a va 2 s.c om * @param swipeListView SwipeListView * @param swipeFrontView front view Identifier * @param swipeBackView back view Identifier */ public SwipeListViewTouchListener(SwipeListView swipeListView, int swipeFrontView, int swipeBackView) { mSwipeFrontView = swipeFrontView; mSwipeBackView = swipeBackView; ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = swipeListView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); this.mSwipeListView = swipeListView; }
From source file:com.appsummary.luoxf.myappsummary.recyclerView.fastscroll.Views.FastScroller.java
/** * Handles the touch event and determines whether to show the fast scroller (or updates it if * it is already showing).//ww w. ja v a 2 s. c om */ public void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY) { ViewConfiguration config = ViewConfiguration.get(mRecyclerView.getContext()); int action = ev.getAction(); int y = (int) ev.getY(); switch (action) { case MotionEvent.ACTION_DOWN: if (isNearPoint(downX, downY)) { mTouchOffset = downY - mThumbPosition.y; } break; case MotionEvent.ACTION_MOVE: // Check if we should start scrolling if (!mIsDragging && isNearPoint(downX, downY) && Math.abs(y - downY) > config.getScaledTouchSlop()) { mRecyclerView.getParent().requestDisallowInterceptTouchEvent(true); mIsDragging = true; mTouchOffset += (lastY - downY); mPopup.animateVisibility(true); } if (mIsDragging) { // Update the fastscroller section name at this touch position int top = 0; int bottom = mRecyclerView.getHeight() - mThumbHeight; float boundedY = (float) Math.max(top, Math.min(bottom, y - mTouchOffset)); String sectionName = mRecyclerView.scrollToPositionAtProgress((boundedY - top) / (bottom - top)); mPopup.setSectionName(sectionName); mPopup.animateVisibility(!sectionName.isEmpty()); mRecyclerView.invalidate(mPopup.updateFastScrollerBounds(mRecyclerView, mThumbPosition.y)); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mTouchOffset = 0; if (mIsDragging) { mIsDragging = false; mPopup.animateVisibility(false); } break; } }