List of usage examples for android.widget Scroller Scroller
public Scroller(Context context)
From source file:com.tr.ui.widgets.HorizontalListView.java
private synchronized void initView() { mLeftViewIndex = -1;/* w ww. j ava2s .c o m*/ mRightViewIndex = 0; mDisplayOffset = 0; mCurrentX = 0; mNextX = 0; mFirstPosition = 0; mSpecificPosition = 0; mSpecificLeft = 0; mMaxX = Integer.MAX_VALUE; mMinX = Integer.MIN_VALUE; mScroller = new Scroller(getContext()); if (!isInEditMode()) { mGesture = new GestureDetector(getContext(), mOnGesture); } }
From source file:com.mcxiaoke.minicat.ui.widget.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_drawSelectorOnTop, false); } else {/* w w w .j a v a 2 s . co m*/ mColCount = 2; mDrawSelectorOnTop = false; } 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); setClipToPadding(false); this.setFocusableInTouchMode(false); if (mSelector == null) { useDefaultSelector(); } }
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);//from w ww . j a va 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:de.andacaydin.bidirectionalviewpagerlibrary.BiDirectionalViewPager.java
void initViewPager() { setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setFocusable(true);/*from w w w. ja va 2 s . com*/ final Context context = getContext(); 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); ViewCompat.setAccessibilityDelegate(this, getAccessibilityDelegateCompat()); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } setWillNotDraw(false); mScroller = new Scroller(getContext()); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.taobao.weex.ui.view.listview.BaseBounceView.java
private void init(Context context) { ViewConfiguration config = ViewConfiguration.get(getContext()); mTouchSlop = config.getScaledTouchSlop(); mScroller = new Scroller(context); mView = createBounceView(context);/* w w w .ja v a2s . c o m*/ addView(mView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mRefreshLayout = createBounceHeaderView(context); if (mRefreshLayout != null) { addView(mRefreshLayout.getView(), LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } mLoadMoreLayout = createBounceFooterView(context); if (mLoadMoreLayout != null) { addView(mLoadMoreLayout.getView(), LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } }
From source file:com.wanikani.androidnotifier.graph.HistogramPlot.java
/** * Constructor/*from w w w . ja va 2 s. c o m*/ * @param ctxt the context * @param attrs the attributes */ public HistogramPlot(Context ctxt, AttributeSet attrs) { super(ctxt, attrs); scroller = new Scroller(ctxt); glist = new GestureListener(); gdect = new GestureDetector(ctxt, glist); loadAttributes(ctxt, attrs); }
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./* w w w . j a va 2s .c om*/ * * @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.qurater.pivotal.ui.TwoWayView.java
public TwoWayView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mNeedSync = false;/*from w w w.j a va 2s . co m*/ mVelocityTracker = null; mLayoutMode = LAYOUT_NORMAL; mTouchMode = TOUCH_MODE_REST; mLastTouchMode = TOUCH_MODE_UNKNOWN; mIsAttached = false; mContextMenuInfo = null; mOnScrollListener = null; mLastScrollState = OnScrollListener.SCROLL_STATE_IDLE; final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mFlingVelocity = vc.getScaledMinimumFlingVelocity(); mOverscrollDistance = getScaledOverscrollDistance(vc); mOverScroll = 0; mScroller = new Scroller(context); mIsVertical = true; mItemsCanFocus = false; mTempRect = new Rect(); mArrowScrollFocusResult = new ArrowScrollFocusResult(); mSelectorPosition = INVALID_POSITION; mSelectorRect = new Rect(); mSelectedStart = 0; mResurrectToPosition = INVALID_POSITION; mSelectedStart = 0; mNextSelectedPosition = INVALID_POSITION; mNextSelectedRowId = INVALID_ROW_ID; mSelectedPosition = INVALID_POSITION; mSelectedRowId = INVALID_ROW_ID; mOldSelectedPosition = INVALID_POSITION; mOldSelectedRowId = INVALID_ROW_ID; mChoiceMode = ChoiceMode.NONE; mCheckedItemCount = 0; mCheckedIdStates = null; mCheckStates = null; mRecycler = new RecycleBin(); mDataSetObserver = null; mAreAllItemsSelectable = true; mStartEdge = null; mEndEdge = null; setClickable(true); setFocusableInTouchMode(true); setWillNotDraw(false); setAlwaysDrawnWithCacheEnabled(false); setWillNotDraw(false); setClipToPadding(false); ViewCompat.setOverScrollMode(this, ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwoWayView, defStyle, 0); mDrawSelectorOnTop = a.getBoolean(R.styleable.TwoWayView_android_drawSelectorOnTop, false); Drawable d = a.getDrawable(R.styleable.TwoWayView_android_listSelector); if (d != null) { setSelector(d); } int orientation = a.getInt(R.styleable.TwoWayView_android_orientation, -1); if (orientation >= 0) { setOrientation(Orientation.values()[orientation]); } int choiceMode = a.getInt(R.styleable.TwoWayView_android_choiceMode, -1); if (choiceMode >= 0) { setChoiceMode(ChoiceMode.values()[choiceMode]); } a.recycle(); }
From source file:com.propkaro.util.TwoWayView.java
public TwoWayView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mNeedSync = false;/*ww w. j a va 2 s. c o m*/ mVelocityTracker = null; mLayoutMode = LAYOUT_NORMAL; mTouchMode = TOUCH_MODE_REST; mLastTouchMode = TOUCH_MODE_UNKNOWN; mIsAttached = false; mContextMenuInfo = null; mOnScrollListener = null; mLastScrollState = OnScrollListener.SCROLL_STATE_IDLE; final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mFlingVelocity = vc.getScaledMinimumFlingVelocity(); mOverscrollDistance = getScaledOverscrollDistance(vc); mOverScroll = 0; mScroller = new Scroller(context); mIsVertical = true; mItemsCanFocus = false; mTempRect = new Rect(); mArrowScrollFocusResult = new ArrowScrollFocusResult(); mSelectorPosition = INVALID_POSITION; mSelectorRect = new Rect(); mSelectedStart = 0; mResurrectToPosition = INVALID_POSITION; mSelectedStart = 0; mNextSelectedPosition = INVALID_POSITION; mNextSelectedRowId = INVALID_ROW_ID; mSelectedPosition = INVALID_POSITION; mSelectedRowId = INVALID_ROW_ID; mOldSelectedPosition = INVALID_POSITION; mOldSelectedRowId = INVALID_ROW_ID; mChoiceMode = ChoiceMode.NONE; mCheckedItemCount = 0; mCheckedIdStates = null; mCheckStates = null; mRecycler = new RecycleBin(); mDataSetObserver = null; mAreAllItemsSelectable = true; mStartEdge = null; mEndEdge = null; setClickable(true); setFocusableInTouchMode(true); setWillNotDraw(false); setAlwaysDrawnWithCacheEnabled(false); setWillNotDraw(false); setClipToPadding(false); ViewCompat.setOverScrollMode(this, ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwoWayView, defStyle, 0); // initializeScrollbars(a); mDrawSelectorOnTop = a.getBoolean(R.styleable.TwoWayView_android_drawSelectorOnTop, false); Drawable d = a.getDrawable(R.styleable.TwoWayView_android_listSelector); if (d != null) { setSelector(d); } int orientation = a.getInt(R.styleable.TwoWayView_android_orientation, -1); if (orientation >= 0) { setOrientation(Orientation.values()[orientation]); } int choiceMode = a.getInt(R.styleable.TwoWayView_android_choiceMode, -1); if (choiceMode >= 0) { setChoiceMode(ChoiceMode.values()[choiceMode]); } a.recycle(); updateScrollbarsDirection(); }
From source file:com.mist.sciryl.app.views.TwoWayView.java
public TwoWayView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mNeedSync = false;//from w ww . j a v a 2 s. com mVelocityTracker = null; mLayoutMode = LAYOUT_NORMAL; mTouchMode = TOUCH_MODE_REST; mLastTouchMode = TOUCH_MODE_UNKNOWN; mIsAttached = false; mContextMenuInfo = null; mOnScrollListener = null; mLastScrollState = OnScrollListener.SCROLL_STATE_IDLE; final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mFlingVelocity = vc.getScaledMinimumFlingVelocity(); mOverscrollDistance = getScaledOverscrollDistance(vc); mOverScroll = 0; mScroller = new Scroller(context); mIsVertical = true; mItemsCanFocus = false; mTempRect = new Rect(); mArrowScrollFocusResult = new ArrowScrollFocusResult(); mSelectorPosition = INVALID_POSITION; mSelectorRect = new Rect(); mSelectedStart = 0; mResurrectToPosition = INVALID_POSITION; mSelectedStart = 0; mNextSelectedPosition = INVALID_POSITION; mNextSelectedRowId = INVALID_ROW_ID; mSelectedPosition = INVALID_POSITION; mSelectedRowId = INVALID_ROW_ID; mOldSelectedPosition = INVALID_POSITION; mOldSelectedRowId = INVALID_ROW_ID; mChoiceMode = ChoiceMode.NONE; mCheckedItemCount = 0; mCheckedIdStates = null; mCheckStates = null; mRecycler = new RecycleBin(); mDataSetObserver = null; mAreAllItemsSelectable = true; mStartEdge = null; mEndEdge = null; setClickable(true); setFocusableInTouchMode(true); setWillNotDraw(false); setAlwaysDrawnWithCacheEnabled(false); setWillNotDraw(false); setClipToPadding(false); ViewCompat.setOverScrollMode(this, ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwoWayView, defStyle, 0); mDrawSelectorOnTop = a.getBoolean(R.styleable.TwoWayView_android_drawSelectorOnTop, false); Drawable d = a.getDrawable(R.styleable.TwoWayView_android_listSelector); if (d != null) { setSelector(d); } int orientation = a.getInt(R.styleable.TwoWayView_android_orientation, -1); if (orientation >= 0) { setOrientation(Orientation.values()[orientation]); } int choiceMode = a.getInt(R.styleable.TwoWayView_android_choiceMode, -1); if (choiceMode >= 0) { setChoiceMode(ChoiceMode.values()[choiceMode]); } a.recycle(); updateScrollbarsDirection(); }