List of usage examples for android.view ViewConfiguration getScaledMaximumFlingVelocity
public int getScaledMaximumFlingVelocity()
From source file:com.app.afteryou.ui.staggered.StaggeredGridView.java
public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mFlingVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = new Scroller(context); mTopEdge = new EdgeEffectCompat(context); mBottomEdge = new EdgeEffectCompat(context); setWillNotDraw(false);//www .jav a 2 s . c om setClipToPadding(false); if (attrs != null) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CostomStaggeredGridView); mColCountSetting = a.getInteger(R.styleable.CostomStaggeredGridView_columnNumber, 2); mDrawSelectorOnTop = a.getBoolean(R.styleable.CostomStaggeredGridView_drawSelectorOnTop, false); if (mColCountSetting != -1) { mColCount = mColCountSetting; } mMinColWidth = a.getDimensionPixelSize(R.styleable.CostomStaggeredGridView_minColumnWidth, 0); a.recycle(); } this.setFocusableInTouchMode(false); if (mSelector == null) { useDefaultSelector(); } }
From source file:org.bangbang.support.v4.widget.VerticalViewPager.java
void initViewPager() { setWillNotDraw(false);/*from w w w .j a v 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); 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); mCloseEnough = (int) (CLOSE_ENOUGH * density); mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density); android.support.v4.view.ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate()); if (android.support.v4.view.ViewCompat.getImportantForAccessibility( this) == android.support.v4.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { android.support.v4.view.ViewCompat.setImportantForAccessibility(this, android.support.v4.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } }
From source file:com.gome.ecmall.custom.VerticalViewPager.java
void initViewPager() { setWillNotDraw(false);//from w w w .j ava 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); 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:com.example.fengxiaozheng.mynews.widget.splash.ViewPager.java
void initViewPager() { setWillNotDraw(false);//from ww w .jav a 2s . c o 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); mCloseEnough = (int) (CLOSE_ENOUGH * density); mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } }
From source file:com.brantapps.viewpagerindicator.vertical.VerticalViewPager.java
void initViewPager() { setWillNotDraw(false);/*from www .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); 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); // } }
From source file:cc.flydev.launcher.Page.java
private PointF isFlingingToDelete() { ViewConfiguration config = ViewConfiguration.get(getContext()); mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity()); if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) { // Do a quick dot product test to ensure that we are flinging upwards PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity()); PointF upVec = new PointF(0f, -1f); float theta = (float) Math .acos(((vel.x * upVec.x) + (vel.y * upVec.y)) / (vel.length() * upVec.length())); if (theta <= Math.toRadians(FLING_TO_DELETE_MAX_FLING_DEGREES)) { return vel; }//from w w w . j av a 2 s .co m } return null; }
From source file:com.jackie.sample.custom_view.CustomViewPagerInternal.java
void initViewPager() { setWillNotDraw(false);/* w w w . j av 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(); mLeftEdge = new EdgeEffectCompat(context); mRightEdge = new EdgeEffectCompat(context); final float density = context.getResources().getDisplayMetrics().density; // mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density) * 4; mFlingDistance = (int) (60 * 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:caesar.feng.framework.widget.StaggeredGrid.ExtendableListView.java
public ExtendableListView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); // setting up to be a scrollable view group setWillNotDraw(false);/*from w ww . ja va 2 s.c o m*/ setClipToPadding(false); setFocusableInTouchMode(false); final ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mTouchSlop = viewConfiguration.getScaledTouchSlop(); mMaximumVelocity = viewConfiguration.getScaledMaximumFlingVelocity(); mFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); mRecycleBin = new RecycleBin(); mObserver = new AdapterDataSetObserver(); mHeaderViewInfos = new ArrayList<FixedViewInfo>(); mFooterViewInfos = new ArrayList<FixedViewInfo>(); // start our layout mode drawing from the top mLayoutMode = LAYOUT_NORMAL; }
From source file:com.n2hsu.launcher.Page.java
private PointF isFlingingToDelete() { ViewConfiguration config = ViewConfiguration.get(getContext()); mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity()); if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) { // Do a quick dot product test to ensure that we are flinging // upwards PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity()); PointF upVec = new PointF(0f, -1f); float theta = (float) Math .acos(((vel.x * upVec.x) + (vel.y * upVec.y)) / (vel.length() * upVec.length())); if (theta <= Math.toRadians(FLING_TO_DELETE_MAX_FLING_DEGREES)) { return vel; }// w ww . ja v a 2 s . c om } return null; }
From source file:mrfu.blurstaggered.lib.view.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_numColumns, 2); mDrawSelectorOnTop = a.getBoolean(R.styleable.StaggeredGridView_drawSelectorOnTop1, false); } else {// ww w . j a v a 2 s . com 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(); } }