List of usage examples for android.view ViewConfiguration get
public static ViewConfiguration get(Context context)
From source file:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java
private void initScrollView() { //mScroller = new ScrollerCompat(getContext(), null); mScroller = ScrollerCompat.create(getContext(), null); setFocusable(true);/*from w w w .j a v a 2s .c o m*/ setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.gruporaido.tasker_library.util.Helper.java
/** * Removes extra bottom margin in case there is a Software Navigation Bar * * @param view//from w ww .j a v a 2s . c om */ public void removeBottomMarginforSoftNavbar(View view) { if (!ViewConfiguration.get(mContext).hasPermanentMenuKey()) { ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); layoutParams.bottomMargin -= navigationBarSize(); view.forceLayout(); } }
From source file:com.cmbb.smartkids.widget.NestedScrollView.java
private void initScrollView() { mScroller = ScrollerCompat.create(getContext(), null); setFocusable(true);// w w w . j a va 2 s . c om setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:android.support.v7.widget.RecyclerView.java
public RecyclerView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final int version = Build.VERSION.SDK_INT; mPostUpdatesOnAnimation = version >= 16; final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); setWillNotDraw(ViewCompat.getOverScrollMode(this) == ViewCompat.OVER_SCROLL_NEVER); mItemAnimator.setListener(mItemAnimatorListener); }
From source file:com.gruporaido.tasker_library.util.Helper.java
/** * Adds an extra bottom padding in case there is a Software Navigation Bar * * @param view// w w w .j a va2s. c om */ public void addBottomPaddingforSoftNavbar(View view) { if (!ViewConfiguration.get(mContext).hasPermanentMenuKey()) { view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom() + navigationBarSize()); } }
From source file:com.android.backups.BackupStaggeredGridView.java
public BackupStaggeredGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (attrs != null) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.StaggeredGridView); mColCount = a.getInteger(R.styleable.StaggeredGridView_numColumns, 2); mDrawSelectorOnTop = a.getBoolean(R.styleable.StaggeredGridView_drawSelectorOnTop, false); } else {/*from w w w . jav a2s . c o m*/ mColCount = 2; mDrawSelectorOnTop = false; } final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mFlingVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = ScrollerCompat.from(context); mTopEdge = new EdgeEffectCompat(context); mBottomEdge = new EdgeEffectCompat(context); setWillNotDraw(false); setClipToPadding(false); this.setFocusableInTouchMode(false); if (mSelector == null) { useDefaultSelector(); } }
From source file:com.antew.redditinpictures.library.widget.SwipeListView.java
private void initialize(AttributeSet attrs) { // If we are in an IDE Preview, don't initialize. if (isInEditMode()) { return;// ww w . j av a 2 s . c om } if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); mFrontViewId = styled.getResourceId(R.styleable.SwipeListView_frontViewId, 0); mBackViewId = styled.getResourceId(R.styleable.SwipeListView_backViewId, 0); mCloseAllWhenScrolling = styled.getBoolean(R.styleable.SwipeListView_closeAllWhenScrolling, true); mOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_openOnLongPress, true); setSwipeDirection(styled.getInt(R.styleable.SwipeListView_swipeDirection, SWIPE_DIRECTION_BOTH)); } if (mFrontViewId == 0 || mBackViewId == 0) { throw new RuntimeException("You must specify a Front View and Back View"); } ViewConfiguration viewConfig = ViewConfiguration.get(getContext()); mTouchSlop = viewConfig.getScaledTouchSlop(); mMinFlingVelocity = viewConfig.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = viewConfig.getScaledMaximumFlingVelocity(); mAnimationTime = getResources().getInteger(android.R.integer.config_shortAnimTime); super.setOnScrollListener(mInternalOnScrollListener); super.setOnItemLongClickListener(mInternalOnItemLongClickListener); }
From source file:com.bolaa.medical.view.pulltorefreshgrid.StaggeredGridView.java
public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (attrs != null) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.StaggeredGridView); mColCount = a.getInteger(R.styleable.StaggeredGridView_numColumnsStag, 2); mDrawSelectorOnTop = a.getBoolean(R.styleable.StaggeredGridView_drawSelectorOnTopStag, false); } else {// w w w. j a v a 2s . c om mColCount = 2; mDrawSelectorOnTop = false; } final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mFlingVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = ScrollerCompat.from(context); mTopEdge = new EdgeEffectCompat(context); mBottomEdge = new EdgeEffectCompat(context); setWillNotDraw(false); setClipToPadding(false); this.setFocusableInTouchMode(false); if (mSelector == null) { useDefaultSelector(); } }
From source file:cn.bingoogolapple.swipebacklayout.BGASwipeBackLayout.java
public BGASwipeBackLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final float density = context.getResources().getDisplayMetrics().density; // ======================== START ======================== // mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f); mOverhangSize = 0;/* w ww .jav a 2s. c o m*/ // ======================== END ======================== final ViewConfiguration viewConfig = ViewConfiguration.get(context); setWillNotDraw(false); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback()); mDragHelper.setMinVelocity(MIN_FLING_VELOCITY * density); }
From source file:com.brantapps.viewpagerindicator.vertical.VerticalViewPager.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(); mTopEdge = new EdgeEffectCompat(context); mBottomEdge = new EdgeEffectCompat(context); final float density = context.getResources().getDisplayMetrics().density; mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density); mCloseEnough = (int) (CLOSE_ENOUGH * density); mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density); ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate()); // TODO: Could restore these lines after ActionBarSherlock is upgraded to support library v9 // if (ViewCompat.getImportantForAccessibility(this) // == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { // ViewCompat.setImportantForAccessibility(this, // ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); // } }