List of usage examples for android.view ViewConfiguration get
public static ViewConfiguration get(Context context)
From source file:cn.bmob.otaku.number_z.view.imagepager.PinchImageViewPager.java
void initViewPager() { setWillNotDraw(false);//from w w w .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); final float density = context.getResources().getDisplayMetrics().density; mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mLeftEdge = new EdgeEffectCompat(context); mRightEdge = 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.gbq.library.widget.swipeback.SwipeViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. This will * allow VDH to use internal compatibility implementations for different * platform versions./* w w w . jav a 2 s . c o m*/ * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private SwipeViewDragHelper(Context context, ViewGroup forParent, Callback cb) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } 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, sInterpolator); }
From source file:cn.xm.xmvideoplayer.widget.swipebacklayout.ViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. This will * allow VDH to use internal compatibility implementations for different * platform versions.//from w w w . j av a 2 s .co m * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } if (cb == null) { throw new IllegalArgumentException("Callback may not be null"); } mParentView = forParent; mCallback = cb; final ViewConfiguration vc = ViewConfiguration.get(context); 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, sInterpolator); }
From source file:com.android.dialer.widget.ViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. * This will allow VDH to use internal compatibility implementations for different * platform versions./* ww w . j a va 2 s. c o m*/ * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } 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 = new Scroller(context); }
From source file:com.example.administrator.demo.activity.sbackapp.SwipeBackViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. This will * allow VDH to use internal compatibility implementations for different * platform versions.//from w w w.j a v a2 s . c o m * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private SwipeBackViewDragHelper(Context context, ViewGroup forParent, Callback cb) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } 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, sInterpolator); }
From source file:com.example.myronlg.cardviewpagerdemo.CopyViewPager.java
void initViewPager() { setWillNotDraw(false);/*from ww w .ja 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); final float density = context.getResources().getDisplayMetrics().density; mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mLeftEdge = new EdgeEffectCompat(context); mRightEdge = 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); } prevPageVisibleWidth = context.getResources().getDisplayMetrics().widthPixels * 0.15F; }
From source file:cn.zmdx.kaka.locker.widget.ViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. This will * allow VDH to use internal compatibility implementations for different * platform versions.//from w ww . java 2 s . c o m * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private ViewDragHelper(Context context, ViewGroup forParent, Callback cb, Interpolator interpolator) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } 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(); if (interpolator != null) { mInterpolator = interpolator; } mScroller = ScrollerCompat.create(context, mInterpolator); }
From source file:com.example.eventtest.CustomViews.ViewPager.java
void initViewPager() { //view??view?ondrawfalse? setWillNotDraw(false);/*from w w w.j av a 2 s . c o m*/ 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(); mLeftEdge = new EdgeEffectCompat(context); mRightEdge = 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); } ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { private final Rect mTempRect = new Rect(); @Override public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat originalInsets) { // First let the ViewPager itself try and consume them... final WindowInsetsCompat applied = ViewCompat.onApplyWindowInsets(v, originalInsets); if (applied.isConsumed()) { // If the ViewPager consumed all insets, return now return applied; } // Now we'll manually dispatch the insets to our children. Since ViewPager // children are always full-height, we do not want to use the standard // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them, // the rest of the children will not receive any insets. To workaround this // we manually dispatch the applied insets, not allowing children to // consume them from each other. We do however keep track of any insets // which are consumed, returning the union of our children's consumption final Rect res = mTempRect; res.left = applied.getSystemWindowInsetLeft(); res.top = applied.getSystemWindowInsetTop(); res.right = applied.getSystemWindowInsetRight(); res.bottom = applied.getSystemWindowInsetBottom(); for (int i = 0, count = getChildCount(); i < count; i++) { final WindowInsetsCompat childInsets = ViewCompat.dispatchApplyWindowInsets(getChildAt(i), applied); // Now keep track of any consumed by tracking each dimension's min // value res.left = Math.min(childInsets.getSystemWindowInsetLeft(), res.left); res.top = Math.min(childInsets.getSystemWindowInsetTop(), res.top); res.right = Math.min(childInsets.getSystemWindowInsetRight(), res.right); res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(), res.bottom); } // Now return a new WindowInsets, using the consumed window insets return applied.replaceSystemWindowInsets(res.left, res.top, res.right, res.bottom); } }); }
From source file:com.android.launcher3.ViewPager.java
void initViewPager() { setWillNotDraw(false);//from ww w.ja va2 s.c o m setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setFocusable(true); final Context context = getContext(); mScroller = new FixedSpeedScroller(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(); mLeftEdge = new EdgeEffectCompat(context); mRightEdge = 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.example.leelay.galleyviewpager.GalleyViewPager.java
void initViewPager() { setWillNotDraw(false);// ww w . j a v a 2 s . co m 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(); mLeftEdge = new EdgeEffectCompat(context); mRightEdge = 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); } ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { private final Rect mTempRect = new Rect(); @Override public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat originalInsets) { // First let the ViewPager itself try and consume them... final WindowInsetsCompat applied = ViewCompat.onApplyWindowInsets(v, originalInsets); if (applied.isConsumed()) { // If the ViewPager consumed all insets, return now return applied; } // Now we'll manually dispatch the insets to our children. Since ViewPager // children are always full-height, we do not want to use the standard // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them, // the rest of the children will not receive any insets. To workaround this // we manually dispatch the applied insets, not allowing children to // consume them from each other. We do however keep track of any insets // which are consumed, returning the union of our children's consumption final Rect res = mTempRect; res.left = applied.getSystemWindowInsetLeft(); res.top = applied.getSystemWindowInsetTop(); res.right = applied.getSystemWindowInsetRight(); res.bottom = applied.getSystemWindowInsetBottom(); for (int i = 0, count = getChildCount(); i < count; i++) { final WindowInsetsCompat childInsets = ViewCompat.dispatchApplyWindowInsets(getChildAt(i), applied); // Now keep track of any consumed by tracking each dimension's min // value res.left = Math.min(childInsets.getSystemWindowInsetLeft(), res.left); res.top = Math.min(childInsets.getSystemWindowInsetTop(), res.top); res.right = Math.min(childInsets.getSystemWindowInsetRight(), res.right); res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(), res.bottom); } // Now return a new WindowInsets, using the consumed window insets return applied.replaceSystemWindowInsets(res.left, res.top, res.right, res.bottom); } }); }