Example usage for android.view ViewConfiguration getScaledMaximumFlingVelocity

List of usage examples for android.view ViewConfiguration getScaledMaximumFlingVelocity

Introduction

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

Prototype

public int getScaledMaximumFlingVelocity() 

Source Link

Usage

From source file:com.slidinglayer.SlidingPanel.java

private void init() {
    setWillNotDraw(false);//from  w  ww.  j av  a2 s. com
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sMenuInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    setOffsetWidth((int) (DEFAULT_OFFSET * density + 0.5f));
}

From source file:com.gu.swiperefresh.SwipeRefreshPlush.java

public SwipeRefreshPlush(Context context, AttributeSet attrs) {
    super(context, attrs);
    mLoadViewController = new LoadViewController(context, this);
    mRefreshController = new RefreshViewController(context, this);
    //   mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
    mScroller = ScrollerCompat.create(getContext());
    createProgressView();/*  w w w.  ja  va2  s.c o m*/
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
}

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   w ww .j  a v  a2s.  com
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  v  a 2  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:android.support.design.widget.SheetBehavior.java

/**
 * Default constructor for inflating BottomSheetBehaviors from layout.
 *
 * @param context The {@link Context}./*from  ww w  . j av  a  2 s .  co  m*/
 * @param attrs   The {@link AttributeSet}.
 */
public SheetBehavior(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SheetBehavior);
    setPeekHeight(a.getDimensionPixelSize(R.styleable.SheetBehavior_peekHeight, 0));
    setHideable(a.getBoolean(R.styleable.SheetBehavior_hiddenEnable, false));
    mSlideModel = a.getInt(R.styleable.SheetBehavior_slideMode, BOTTOM_SHEET);
    a.recycle();
    ViewConfiguration configuration = ViewConfiguration.get(context);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:com.hynet.mergepay.components.widget.panellayout.ViewDragHelper.java

private ViewDragHelper(Context context, ViewGroup forParent, Interpolator interpolator, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }/*  w w w.j  a  v  a 2 s.co  m*/
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, interpolator != null ? interpolator : sInterpolator);
}

From source file:SwipeListViewTouchListener.java

/**
 * Constructor//from w w  w  . j a  v a  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) {
    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.aoeng.degu.views.swipe.SwipeListSingleViewTouchListener.java

/**
 * Constructor/*w  ww.  j a  v  a2s  . com*/
 * 
 * @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:com.viettel.image.zoom.ZoomViewPaper.java

void initViewPager() {

    setWillNotDraw(false);/*from   w  w w.  ja va 2 s  .c om*/
    mScroller = new Scroller(getContext());
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:gaobq.android.easyslidingmenu.CustomViewAbove.java

void initCustomViewAbove() {
    setWillNotDraw(false);/*from  w  w w . j  a  v  a2 s. com*/
    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);
}