List of usage examples for android.view ViewConfiguration getScaledMinimumFlingVelocity
public int getScaledMinimumFlingVelocity()
From source file:com.example.carlitos.swipeitemrecycler.view.animation.swipe_item.swipeable.RecyclerViewSwipeManager.java
/** * <p>Attaches {@link android.support.v7.widget.RecyclerView} instance.</p> * <p>Before calling this method, the target {@link android.support.v7.widget.RecyclerView} must set * the wrapped adapter instance which is returned by the * {@link #createWrappedAdapter(android.support.v7.widget.RecyclerView.Adapter)} method.</p> * * @param rv The {@link android.support.v7.widget.RecyclerView} instance *//*from ww w . ja v a2 s . c o m*/ public void attachRecyclerView(@NonNull RecyclerView rv) { if (rv == null) { throw new IllegalArgumentException("RecyclerView cannot be null"); } if (isReleased()) { throw new IllegalStateException("Accessing released object"); } if (mRecyclerView != null) { throw new IllegalStateException("RecyclerView instance has already been set"); } if (mAdapter == null || getSwipeableItemWrapperAdapter(rv) != mAdapter) { throw new IllegalStateException("adapter is not set properly"); } final int layoutOrientation = CustomRecyclerViewUtils.getOrientation(rv); if (layoutOrientation == CustomRecyclerViewUtils.ORIENTATION_UNKNOWN) { throw new IllegalStateException("failed to determine layout orientation"); } mRecyclerView = rv; mRecyclerView.addOnItemTouchListener(mInternalUseOnItemTouchListener); final ViewConfiguration vc = ViewConfiguration.get(rv.getContext()); mTouchSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mItemSlideAnimator = new ItemSlidingAnimator(mAdapter); mItemSlideAnimator .setImmediatelySetTranslationThreshold((int) (rv.getResources().getDisplayMetrics().density * SLIDE_ITEM_IMMEDIATELY_SET_TRANSLATION_THRESHOLD_DP + 0.5f)); mSwipeHorizontal = (layoutOrientation == CustomRecyclerViewUtils.ORIENTATION_VERTICAL); mHandler = new InternalHandler(this); }
From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.swipeable.RecyclerViewSwipeManager.java
/** * <p>Attaches {@link RecyclerView} instance.</p> * <p>Before calling this method, the target {@link RecyclerView} must set * the wrapped adapter instance which is returned by the * {@link #createWrappedAdapter(RecyclerView.Adapter)} method.</p> * * @param rv The {@link RecyclerView} instance *///from w w w . j a va2 s . c o m public void attachRecyclerView(@NonNull RecyclerView rv) { if (isReleased()) { throw new IllegalStateException("Accessing released object"); } if (mRecyclerView != null) { throw new IllegalStateException("RecyclerView instance has already been set"); } if (mAdapter == null || getSwipeableItemWrapperAdapter(rv) != mAdapter) { throw new IllegalStateException("adapter is not set properly"); } final int layoutOrientation = CustomRecyclerViewUtils.getOrientation(rv); if (layoutOrientation == CustomRecyclerViewUtils.ORIENTATION_UNKNOWN) { throw new IllegalStateException("failed to determine layout orientation"); } mRecyclerView = rv; mRecyclerView.addOnItemTouchListener(mInternalUseOnItemTouchListener); final ViewConfiguration vc = ViewConfiguration.get(rv.getContext()); mTouchSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mItemSlideAnimator = new ItemSlidingAnimator(mAdapter); mItemSlideAnimator .setImmediatelySetTranslationThreshold((int) (rv.getResources().getDisplayMetrics().density * SLIDE_ITEM_IMMEDIATELY_SET_TRANSLATION_THRESHOLD_DP + 0.5f)); mSwipeHorizontal = (layoutOrientation == CustomRecyclerViewUtils.ORIENTATION_VERTICAL); mHandler = new InternalHandler(this); }
From source file:SwipeListViewTouchListener.java
/** * Constructor/* w w w . ja v a 2 s. c o m*/ * * @param swipeListView SwipeListView * @param swipeFrontView front view Identifier * @param swipeBackView back view Identifier */ public SwipeListViewTouchListener(SwipeListView swipeListView, int swipeFrontView, int swipeBackView) { this.swipeFrontView = swipeFrontView; this.swipeBackView = swipeBackView; ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext()); slop = vc.getScaledTouchSlop(); minFlingVelocity = vc.getScaledMinimumFlingVelocity(); maxFlingVelocity = vc.getScaledMaximumFlingVelocity(); configShortAnimationTime = swipeListView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); animationTime = configShortAnimationTime; this.swipeListView = swipeListView; }
From source file:com.trafi.anchorbottomsheetbehavior.AnchorBottomSheetBehavior.java
/** * Default constructor for inflating AnchorBottomSheetBehaviors from layout. * * @param context The {@link Context}.//from w w w . j ava 2s . c o m * @param attrs The {@link AttributeSet}. */ public AnchorBottomSheetBehavior(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, android.support.design.R.styleable.BottomSheetBehavior_Layout); TypedValue value = a .peekValue(android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight); if (value != null && value.data == PEEK_HEIGHT_AUTO) { setPeekHeight(value.data); } else { setPeekHeight(a.getDimensionPixelSize( android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight, PEEK_HEIGHT_AUTO)); } setHideable(a.getBoolean(android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_hideable, false)); setSkipCollapsed(a.getBoolean( android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed, false)); a.recycle(); a = context.obtainStyledAttributes(attrs, R.styleable.AnchorBottomSheetBehavior_Layout); mAnchorOffset = (int) a.getDimension(R.styleable.AnchorBottomSheetBehavior_Layout_behavior_anchorOffset, 0); //noinspection WrongConstant mState = a.getInt(R.styleable.AnchorBottomSheetBehavior_Layout_behavior_defaultState, mState); mShouldAnchoredBeforeExpand = a.getBoolean( R.styleable.AnchorBottomSheetBehavior_Layout_behavior_shouldAnchoredBeforeExpand, false); mShouldAnchoredBeforeCollapse = a.getBoolean( R.styleable.AnchorBottomSheetBehavior_Layout_behavior_shouldAnchoredBeforeCollapse, false); mExpandable = a.getBoolean(R.styleable.AnchorBottomSheetBehavior_Layout_behavior_expandable, true); a.recycle(); ViewConfiguration configuration = ViewConfiguration.get(context); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); }
From source file:lewa.support.v7.widget.SwitchCompat.java
/** * Construct a new Switch with a default style determined by the given theme attribute, * overriding specific style attributes as requested. * * @param context The Context that will determine this widget's theming. * @param attrs Specification of attributes that should deviate from the default styling. * @param defStyleAttr An attribute in the current theme that contains a * reference to a style resource that supplies default values for * the view. Can be 0 to not look for defaults. *//*w ww. j a v a 2s. c o m*/ public SwitchCompat(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); final Resources res = getResources(); mTextPaint.density = res.getDisplayMetrics().density; final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.SwitchCompat, defStyleAttr, 0); mThumbDrawable = a.getDrawable(R.styleable.SwitchCompat_android_thumb); mTrackDrawable = a.getDrawable(R.styleable.SwitchCompat_track); mTextOn = a.getText(R.styleable.SwitchCompat_android_textOn); mTextOff = a.getText(R.styleable.SwitchCompat_android_textOff); mShowText = a.getBoolean(R.styleable.SwitchCompat_showText, true); mThumbTextPadding = a.getDimensionPixelSize(R.styleable.SwitchCompat_thumbTextPadding, 0); mSwitchMinWidth = a.getDimensionPixelSize(R.styleable.SwitchCompat_switchMinWidth, 0); mSwitchPadding = a.getDimensionPixelSize(R.styleable.SwitchCompat_switchPadding, 0); mSplitTrack = a.getBoolean(R.styleable.SwitchCompat_splitTrack, false); final int appearance = a.getResourceId(R.styleable.SwitchCompat_switchTextAppearance, 0); if (appearance != 0) { setSwitchTextAppearance(context, appearance); } mTintManager = a.getTintManager(); a.recycle(); final ViewConfiguration config = ViewConfiguration.get(context); mTouchSlop = config.getScaledTouchSlop(); mMinFlingVelocity = config.getScaledMinimumFlingVelocity(); // Refresh display with current params refreshDrawableState(); setChecked(isChecked()); }
From source file:com.viettel.image.zoom.ZoomViewPaper.java
void initViewPager() { setWillNotDraw(false);// ww w. jav a 2s . c o m mScroller = new Scroller(getContext()); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.aoeng.degu.views.swipe.SwipeListSingleViewTouchListener.java
/** * Constructor//from w w w . j a va 2 s.c o m * * @param swipeListView * SwipeListView * @param swipeFrontView * front view Identifier * @param swipeBackView * back view Identifier */ public SwipeListSingleViewTouchListener(SwipeListSingleView swipeListView, int swipeFrontView, int swipeBackView) { this.swipeFrontView = swipeFrontView; this.swipeBackView = swipeBackView; ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext()); slop = vc.getScaledTouchSlop(); minFlingVelocity = vc.getScaledMinimumFlingVelocity(); maxFlingVelocity = vc.getScaledMaximumFlingVelocity(); configShortAnimationTime = swipeListView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); animationTime = configShortAnimationTime; this.swipeListView = swipeListView; }
From source file:gaobq.android.easyslidingmenu.CustomViewAbove.java
void initCustomViewAbove() { setWillNotDraw(false);//from w ww. j a v a2 s . co m setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setFocusable(true); final Context context = getContext(); mScroller = new Scroller(context, sInterpolator); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); setInternalPageChangeListener(new SimpleOnPageChangeListener() { public void onPageSelected(int position) { if (mViewBehind != null) { switch (position) { case 0: case 2: mViewBehind.setChildrenEnabled(true); break; case 1: mViewBehind.setChildrenEnabled(false); break; } } } }); final float density = context.getResources().getDisplayMetrics().density; mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density); }
From source file:com.young.icontacts.view.SwipeListViewTouchListenerTwo.java
/** * Constructor//from w ww.j a v a2 s.com * * @param swipeListView SwipeListView * @param swipeFrontView front view Identifier * @param swipeBackView back view Identifier */ public SwipeListViewTouchListenerTwo(SwipeListView swipeListView, int swipeFrontView, int swipeBackView) { this.swipeFrontView = swipeFrontView; this.swipeBackView = swipeBackView; ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext()); slop = vc.getScaledTouchSlop(); minFlingVelocity = vc.getScaledMinimumFlingVelocity(); maxFlingVelocity = vc.getScaledMaximumFlingVelocity(); configShortAnimationTime = swipeListView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); animationTime = configShortAnimationTime; this.swipeListView = swipeListView; }
From source file:com.intuit.lego.widget.swipeLibrary.SwipeListViewTouchListener.java
/** * Constructor//from w ww . j a va 2 s . c o m * * @param swipeListView SwipeListView * @param swipeFrontView front view Identifier * @param swipeBackView back view Identifier */ public SwipeListViewTouchListener(SwipeListView swipeListView, int swipeFrontView, int swipeBackView) { this.swipeFrontView = swipeFrontView; this.swipeBackView = swipeBackView; ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext()); slop = vc.getScaledTouchSlop(); minFlingVelocity = vc.getScaledMinimumFlingVelocity() * 40; // kbhalla: Increasing the minimum limit for velocity to stablize the intended actions of swipe. maxFlingVelocity = vc.getScaledMaximumFlingVelocity(); configShortAnimationTime = swipeListView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); animationTime = configShortAnimationTime; this.swipeListView = swipeListView; }