Example usage for android.view ViewConfiguration get

List of usage examples for android.view ViewConfiguration get

Introduction

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

Prototype

public static ViewConfiguration get(Context context) 

Source Link

Document

Returns a configuration for the specified context.

Usage

From source file:cn.bingoogolapple.refreshlayout.BGAStickyNavLayout.java

private void init(Context context) {
    setOrientation(VERTICAL);// w  w  w  .j  a v a2  s . c  om

    mOverScroller = new OverScroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
}

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   ww w .jav  a2s .co  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.github.shareme.gwsmaterialuikit.library.advancerv.touchguard.RecyclerViewTouchActionGuardManager.java

/**
 * Attaches {@link RecyclerView} instance.
 *
 * @param rv The {@link RecyclerView} instance
 *///from   ww  w.j  av 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");
    }

    mRecyclerView = rv;
    mRecyclerView.addOnItemTouchListener(mInternalUseOnItemTouchListener);

    mTouchSlop = ViewConfiguration.get(rv.getContext()).getScaledTouchSlop();
}

From source file:com.example.client.fragment.imported.ViewPagerTabFragmentParentFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_viewpagertabfragment_parent, container, false);

    AppCompatActivity parentActivity = (AppCompatActivity) getActivity();
    mPagerAdapter = new NavigationAdapter(getChildFragmentManager());
    mPager = (ViewPager) view.findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);/* www  .j  a va 2 s  .  c  o  m*/

    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);

    ViewConfiguration vc = ViewConfiguration.get(parentActivity);
    mSlop = vc.getScaledTouchSlop();
    mInterceptionLayout = (TouchInterceptionFrameLayout) view.findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);

    return view;
}

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();//www  . j  a v a 2s .  co m

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mScaledTouchSlop = configuration.getScaledTouchSlop();
    mScaledMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mScaledMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();

    mScroller = new OverScroller(getContext());
}

From source file:cc.solart.turbo.TurboRecyclerView.java

public TurboRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TurboRecyclerView);
    int max = ta.getInteger(R.styleable.TurboRecyclerView_maxDragDistance, DRAG_MAX_DISTANCE);
    mTotalDragDistance = convertDpToPixel(context, max);
    mLoadEnabled = ta.getBoolean(R.styleable.TurboRecyclerView_enableLoad, false);
    ta.recycle();//w ww. ja  v  a2s  . c  o m
}

From source file:io.mattcarroll.hover.defaulthovermenu.window.WindowHoverMenu.java

public WindowHoverMenu(@NonNull Context context, @NonNull WindowManager windowManager,
        @Nullable Navigator navigator, @Nullable String savedVisualState) {
    mWindowViewController = new WindowViewController(windowManager);

    InWindowDragger inWindowDragger = new InWindowDragger(context, mWindowViewController,
            ViewConfiguration.get(context).getScaledTouchSlop());

    PointF anchorState = new PointF(2, 0.5f); // Default to right side, half way down. See CollapsedMenuAnchor.
    if (null != savedVisualState) {
        try {/*from  ww  w  . j a va  2 s.  co  m*/
            VisualStateMemento visualStateMemento = VisualStateMemento.fromJsonString(savedVisualState);
            anchorState.set(visualStateMemento.getAnchorSide(), visualStateMemento.getNormalizedPositionY());
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    mHoverMenuView = new HoverMenuView(context, navigator, inWindowDragger, anchorState);
    mHoverMenuView.setHoverMenuExitRequestListener(mMenuExitRequestListener);
}

From source file:com.frostwire.android.gui.MainApplication.java

private void ignoreHardwareMenu() {
    try {//  ww w .j av a 2 s.  c  o m
        ViewConfiguration config = ViewConfiguration.get(this);
        @SuppressWarnings("JavaReflectionMemberAccess")
        Field f = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (f != null) {
            f.setAccessible(true);
            f.setBoolean(config, false);
        }
    } catch (Throwable e) {
        // ignore
    }
}

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();/*from w w  w. j  a v a 2  s.  c o m*/

    ViewConfiguration mViewConfig = ViewConfiguration.get(getContext());
    mScaledTouchSlop = mViewConfig.getScaledTouchSlop();
    mScroller = new OverScroller(getContext());
    mScaledMinimumFlingVelocity = mViewConfig.getScaledMinimumFlingVelocity();
    mScaledMaximumFlingVelocity = mViewConfig.getScaledMaximumFlingVelocity();
}

From source file:com.example.carlitos.swipeitemrecycler.view.animation.swipe_item.touchguard.RecyclerViewTouchActionGuardManager.java

/**
 * Attaches {@link android.support.v7.widget.RecyclerView} instance.
 *
 * @param rv The {@link android.support.v7.widget.RecyclerView} instance
 *//*ww w .jav  a 2 s.co  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");
    }

    mRecyclerView = rv;
    mRecyclerView.addOnItemTouchListener(mInternalUseOnItemTouchListener);

    mTouchSlop = ViewConfiguration.get(rv.getContext()).getScaledTouchSlop();
}