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:com.android.hcframe.DraggableGridViewPager.java

private void initDraggableGridViewPager() {
    mDividerPaint = new Paint();
    mDividerPaint.setAntiAlias(true);/*from  w w w. j a  v  a 2s .c o  m*/
    mDividerPaint.setColor(mDividerColor);
    mDividerPaint.setStyle(Style.STROKE);
    mDividerPaint.setStrokeWidth(mDividerWidth);
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    setChildrenDrawingOrderEnabled(true);

    final Context context = getContext();
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mGridGap = (int) (DEFAULT_GRID_GAP * density);

    // internal paddings
    mPaddingLeft = getPaddingLeft();
    mPaddingTop = getPaddingTop();
    mPaddingRight = getPaddingRight();
    mPaddingButtom = getPaddingBottom();
    super.setPadding(0, 0, 0, 0);

    mScroller = new Scroller(context, sInterpolator);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
}

From source file:com.android.support.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/* w  w w.java  2s.c  o m*/
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}

From source file:android.improving.utils.views.cardsview.OrientedViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*from w w  w  .  j  a v  a  2 s . c  om*/
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mTopLeftEdge = new EdgeEffectCompat(context);
    mRightBottomEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}

From source file:com.bcgtgjyb.huanwen.meizi.view.widget.MySwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context//from  w w  w.j av a2s .  c  o  m
 * @param attrs
 */
public MySwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}

From source file:cn.edu.bit.bookstore.bookstore_android.widget.PullToRefreshLayout.java

/**
 * Constructor that is called when inflating PullToRefreshLayout from XML.
 *
 * @param context//from  w  ww  .  j  a  v a2s.c om
 * @param attrs
 */
public PullToRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}

From source file:com.chenglong.muscle.ui.LazyViewPager.java

void initViewPager() {
    setWillNotDraw(false);//from   w w  w.  j av  a  2  s.c om
    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();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
}

From source file:com.digreamon.android.widget.SlidingPaneLayout.java

public SlidingPaneLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mScroller = new Scroller(context, sInterpolator);
    mGutterSize = (int) dp2px(DEFAULT_GUTTER_SIZE);
    mOverhangSize = (int) dp2px(DEFAULT_OVERHANG_SIZE);

    final ViewConfiguration viewConfig = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(viewConfig);
    mMaxVelocity = viewConfig.getScaledMaximumFlingVelocity();

    setWillNotDraw(false);/* ww  w. ja  v  a  2 s.c  om*/
}

From source file:com.gome.ecmall.custom.VerticalViewPager.java

void initViewPager() {
    setWillNotDraw(false);//from   w  w w. ja  v a 2s  . 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();
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);

    final float density = MobileDeviceUtil.getInstance(context.getApplicationContext()).getScreenDensity();
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}

From source file:beichen.douban.ui.view.LazyViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*www  . j  a va2  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();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
}

From source file:com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager.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
 * @param scrollEventDistributor The distributor for {@link android.support.v7.widget.RecyclerView.OnScrollListener} event
 *//*from  w  w  w . j  a  v  a  2s  . c o  m*/
@Deprecated
public void attachRecyclerView(@NonNull RecyclerView rv,
        @Nullable @SuppressWarnings("deprecation") RecyclerViewOnScrollEventDistributor scrollEventDistributor) {
    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 || getDraggableItemWrapperAdapter(rv) != mAdapter) {
        throw new IllegalStateException("adapter is not set properly");
    }

    if (scrollEventDistributor != null) {
        final RecyclerView rv2 = scrollEventDistributor.getRecyclerView();

        if (rv2 != null && rv2 != rv) {
            throw new IllegalArgumentException(
                    "The scroll event distributor attached to different RecyclerView instance");
        }
    }

    mRecyclerView = rv;

    if (scrollEventDistributor != null) {
        scrollEventDistributor.add(mInternalUseOnScrollListener);
        mScrollEventRegisteredToDistributor = true;
    } else {
        mRecyclerView.addOnScrollListener(mInternalUseOnScrollListener);
        mScrollEventRegisteredToDistributor = false;
    }

    mRecyclerView.addOnItemTouchListener(mInternalUseOnItemTouchListener);

    mDisplayDensity = mRecyclerView.getResources().getDisplayMetrics().density;
    mTouchSlop = ViewConfiguration.get(mRecyclerView.getContext()).getScaledTouchSlop();
    mScrollTouchSlop = (int) (mTouchSlop * SCROLL_TOUCH_SLOP_MULTIPLY + 0.5f);
    mHandler = new InternalHandler(this);

    if (supportsEdgeEffect()) {
        // edge effect is available on ICS or later
        switch (CustomRecyclerViewUtils.getOrientation(mRecyclerView)) {
        case CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL:
            mEdgeEffectDecorator = new LeftRightEdgeEffectDecorator(mRecyclerView);
            break;
        case CustomRecyclerViewUtils.ORIENTATION_VERTICAL:
            mEdgeEffectDecorator = new TopBottomEdgeEffectDecorator(mRecyclerView);
            break;
        }
        if (mEdgeEffectDecorator != null) {
            mEdgeEffectDecorator.start();
        }
    }
}