List of usage examples for android.support.v4.view ViewCompat OVER_SCROLL_ALWAYS
int OVER_SCROLL_ALWAYS
To view the source code for android.support.v4.view ViewCompat OVER_SCROLL_ALWAYS.
Click Source Link
From source file:com.blestep.sportsbracelet.view.TimelineChartView.java
private void onOverScroll() { final boolean needOverScroll; synchronized (mLock) { needOverScroll = mData.size() >= Math.floor(mMaxBarItemsInScreen / 2); }//from ww w .j av a 2 s .co m final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && needOverScroll)) { boolean needsInvalidate = false; if (mCurrentOffset > mMaxOffset) { needsInvalidate = true; } if (mCurrentOffset < 0) { needsInvalidate = true; } if (needsInvalidate) { ViewCompat.postInvalidateOnAnimation(this); } } }
From source file:com.irontec.jaigiro.widgets.StaggeredGridView.java
/** * //from w ww. j ava 2s . co m * @param deltaY * Pixels that content should move by * @return true if the movement completed, false if it was stopped * prematurely. */ private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) { final boolean contentFits = contentFits(); final int allowOverhang = Math.abs(deltaY); final int overScrolledBy; final int movedBy; if (!contentFits) { final int overhang; final boolean up; mPopulating = true; if (deltaY > 0) { overhang = fillUp(mFirstPosition - 1, allowOverhang); up = true; } else { overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin; up = false; } movedBy = Math.min(overhang, allowOverhang); offsetChildren(up ? movedBy : -movedBy); recycleOffscreenViews(); mPopulating = false; overScrolledBy = allowOverhang - overhang; } else { overScrolledBy = allowOverhang; movedBy = 0; } if (allowOverScroll) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) { if (overScrolledBy > 0) { EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge; edge.onPull((float) Math.abs(deltaY) / getHeight()); ViewCompat.postInvalidateOnAnimation(this); } } } invokeOnItemScrollListener(); return deltaY == 0 || movedBy != 0; }
From source file:com.blestep.sportsbracelet.view.TimelineChartView.java
/** * {@inheritDoc}/* w w w . j av a2s . c o m*/ */ @Override public void computeScroll() { super.computeScroll(); // Determine whether we still scrolling and needs a viewport refresh final boolean scrolling = mScroller.computeScrollOffset(); if (scrolling) { float x = mScroller.getCurrX(); if (x > mMaxOffset || x < 0) { return; } mCurrentOffset = x; ViewCompat.postInvalidateOnAnimation(this); } else if (mState > STATE_MOVING) { boolean needsInvalidate = false; final boolean needOverScroll; synchronized (mLock) { needOverScroll = mData.size() >= Math.floor(mMaxBarItemsInScreen / 2); } final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (needOverScroll && overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS)) { float x = mScroller.getCurrX(); if (x >= mMaxOffset) { needsInvalidate = true; } if (x < 0) { needsInvalidate = true; } } if (!needsInvalidate) { // Reset state mState = STATE_IDLE; mLastPosition = -1; } else { ViewCompat.postInvalidateOnAnimation(this); } } int position = computeNearestPositionFromOffset(mCurrentOffset); // If we are not centered in a item, perform an scroll if (mState == STATE_IDLE) { smoothScrollTo(position); } if (mCurrentPosition != position) { // Don't perform selection operations while we are just scrolling if (mState != STATE_SCROLLING) { mCurrentPosition = position; // Notify any valid item, but only notify invalid items if // we are not panning/scrolling if (mCurrentPosition >= 0 || !scrolling) { Message.obtain(mUiHandler, MSG_ON_SELECTION_ITEM_CHANGED).sendToTarget(); } } } }
From source file:com.mcxiaoke.minicat.ui.widget.StaggeredGridView.java
/** * @param deltaY Pixels that content should move by * @return true if the movement completed, false if it was stopped prematurely. *///w w w. j a v a 2 s . co m private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) { final boolean contentFits = contentFits(); final int allowOverhang = Math.abs(deltaY); final int overScrolledBy; final int movedBy; if (!contentFits) { final int overhang; final boolean up; mPopulating = true; if (deltaY > 0) { overhang = fillUp(mFirstPosition - 1, allowOverhang); up = true; } else { overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin; up = false; } movedBy = Math.min(overhang, allowOverhang); offsetChildren(up ? movedBy : -movedBy); recycleOffscreenViews(); mPopulating = false; overScrolledBy = allowOverhang - overhang; } else { overScrolledBy = allowOverhang; movedBy = 0; } if (allowOverScroll) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) { if (overScrolledBy > 0) { EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge; edge.onPull((float) Math.abs(deltaY) / getHeight()); invalidate(); } } } if (mSelectorPosition != INVALID_POSITION) { final int childIndex = mSelectorPosition - mFirstPosition; if (childIndex >= 0 && childIndex < getChildCount()) { positionSelector(INVALID_POSITION, getChildAt(childIndex)); } } else { mSelectorRect.setEmpty(); } return deltaY == 0 || movedBy != 0; }
From source file:tanglie.mystaggeredgridview.StaggeredGridView.java
/** * * @param deltaY Pixels that content should move by * @return true if the movement completed, false if it was stopped prematurely. *//*from w w w . jav a 2s .c om*/ private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) { final boolean contentFits = contentFits(); final int allowOverhang = Math.abs(deltaY); final int overScrolledBy; final int movedBy; if (!contentFits) { final int overhang; final boolean up; mPopulating = true; if (deltaY > 0) { overhang = fillUp(mFirstPosition - 1, allowOverhang) + mItemMargin; up = true; } else { // overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin; overhang = 0; up = false; } movedBy = Math.min(overhang, allowOverhang); offsetChildren(up ? movedBy : -movedBy); recycleOffscreenViews(); mPopulating = false; overScrolledBy = allowOverhang - overhang; } else { overScrolledBy = allowOverhang; movedBy = 0; } if (allowOverScroll) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) { if (overScrolledBy > 0) { EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge; edge.onPull((float) Math.abs(deltaY) / getHeight()); invalidate(); } } } if (mSelectorPosition != INVALID_POSITION) { final int childIndex = mSelectorPosition - mFirstPosition; if (childIndex >= 0 && childIndex < getChildCount()) { positionSelector(INVALID_POSITION, getChildAt(childIndex)); } } else { mSelectorRect.setEmpty(); } return deltaY == 0 || movedBy != 0; }
From source file:com.rajul.staggeredgridview.StaggeredGridView.java
/** * @param deltaY Pixels that content should move by * @return true if the movement completed, false if it was stopped * prematurely.//from w ww. j a v a 2 s . co m */ private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) { final boolean contentFits = contentFits(); final int allowOverhang = Math.abs(deltaY); final int overScrolledBy; final int movedBy; if (!contentFits) { final int overhang; final boolean up; mPopulating = true; if (deltaY > 0) { overhang = fillUp(mFirstPosition - 1, allowOverhang); up = true; } else { overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin; up = false; } movedBy = Math.min(overhang, allowOverhang); offsetChildren(up ? movedBy : -movedBy); recycleOffscreenViews(); mPopulating = false; overScrolledBy = allowOverhang - overhang; } else { overScrolledBy = allowOverhang; movedBy = 0; } if (allowOverScroll) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) { if (overScrolledBy > 0) { EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge; edge.onPull((float) Math.abs(deltaY) / getHeight()); ViewCompat.postInvalidateOnAnimation(this); } } } invokeOnItemScrollListener(); // TODO if (mSelectorPosition != INVALID_POSITION) { final int childIndex = mSelectorPosition - mFirstPosition; if (childIndex >= 0 && childIndex < getChildCount()) { positionSelector(INVALID_POSITION, getChildAt(childIndex)); } } else { mSelectorRect.setEmpty(); } return deltaY == 0 || movedBy != 0; }
From source file:cn.iterlog.myapplication.widget.overscroll.StaggeredGridView.java
/** * * @param deltaY Pixels that content should move by * @return true if the movement completed, false if it was stopped prematurely. *//*from w w w . j a v a 2 s . c om*/ private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) { final boolean contentFits = contentFits(); final int allowOverhang = Math.abs(deltaY); final int overScrolledBy; final int movedBy; if (!contentFits) { final int overhang; final boolean up; mPopulating = true; if (deltaY > 0) { overhang = fillUp(mFirstPosition - 1, allowOverhang) + mItemMargin; up = true; } else { overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin; up = false; } movedBy = Math.min(overhang, allowOverhang); offsetChildren(up ? movedBy : -movedBy); recycleOffscreenViews(); mPopulating = false; overScrolledBy = allowOverhang - overhang; } else { overScrolledBy = allowOverhang; movedBy = 0; } if (allowOverScroll) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) { if (overScrolledBy > 0) { EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge; edge.onPull((float) Math.abs(deltaY) / getHeight()); invalidate(); } } } if (mSelectorPosition != INVALID_POSITION) { final int childIndex = mSelectorPosition - mFirstPosition; if (childIndex >= 0 && childIndex < getChildCount()) { positionSelector(INVALID_POSITION, getChildAt(childIndex)); } } else { mSelectorRect.setEmpty(); } return deltaY == 0 || movedBy != 0; }
From source file:chan.android.app.bitwise.util.StaggeredGridView.java
/** * @param deltaY Pixels that content should move by * @return true if the movement completed, false if it was stopped prematurely. *//* ww w . ja va2s . c o m*/ private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) { final boolean contentFits = contentFits(); final int allowOverhang = Math.abs(deltaY); final int overScrolledBy; int movedBy; if (!contentFits) { final int overhang; final boolean up; mPopulating = true; if (deltaY > 0) { overhang = fillUp(mFirstPosition - 1, allowOverhang) + mItemMargin; up = true; } else { overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin; up = false; } movedBy = Math.min(overhang, allowOverhang); if (movedBy < 0) { movedBy = 0; } if (movedBy == 0) { if (up) { mGetToTop = true; lazyload = false; } else { mGetToTop = false; lazyload = true; if (!loadlock) { mLoadListener.onLoadmore(); loadlock = true; } } } else { mGetToTop = false; lazyload = true; } offsetChildren(up ? movedBy : -movedBy); if (getChildCount() > MAX_CHILD_COUNT) { recycleOffscreenViews(); } mPopulating = false; overScrolledBy = allowOverhang - overhang; } else { overScrolledBy = allowOverhang; movedBy = 0; } if (allowOverScroll) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) { if (overScrolledBy > 0) { EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge; edge.onPull((float) Math.abs(deltaY) / getHeight()); invalidate(); } } } if (mSelectorPosition != INVALID_POSITION) { final int childIndex = mSelectorPosition - mFirstPosition; if (childIndex >= 0 && childIndex < getChildCount()) { positionSelector(INVALID_POSITION, getChildAt(childIndex)); } } else { mSelectorRect.setEmpty(); } return deltaY == 0 || movedBy != 0; }
From source file:com.acbelter.scheduleview.ScheduleView.java
private void drawEdgeEffects(Canvas canvas) { boolean needsInvalidate = false; final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS) { if (!mTopEdgeEffect.isFinished()) { int saveCount = canvas.save(); int width = mViewWidth - getPaddingLeft() - getPaddingRight(); int height = mViewHeight - getPaddingTop() - getPaddingBottom(); canvas.translate(0, getPaddingTop()); mTopEdgeEffect.setSize(width, height); needsInvalidate |= mTopEdgeEffect.draw(canvas); canvas.restoreToCount(saveCount); }/* w ww . jav a2 s . co m*/ if (!mBottomEdgeEffect.isFinished()) { int saveCount = canvas.save(); int width = mViewWidth - getPaddingLeft() - getPaddingRight(); int height = mViewHeight - getPaddingTop() - getPaddingBottom(); canvas.translate(mViewWidth, mViewHeight - getPaddingBottom()); canvas.rotate(180); mBottomEdgeEffect.setSize(width, height); needsInvalidate |= mBottomEdgeEffect.draw(canvas); canvas.restoreToCount(saveCount); } } else { mTopEdgeEffect.finish(); mBottomEdgeEffect.finish(); } if (needsInvalidate) { ViewCompat.postInvalidateOnAnimation(this); } }
From source file:com.example.GoIceland.grids.StaggeredGridView.java
/** * @param deltaY Pixels that content should move by * @return true if the movement completed, false if it was stopped prematurely. *//* w w w.j av a2s . c o m*/ private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) { final boolean contentFits = contentFits(); final int allowOverhang = Math.abs(deltaY); final int overScrolledBy; int movedBy; if (!contentFits) { final int overhang; final boolean up; mPopulating = true; if (deltaY > 0) { overhang = fillUp(mFirstPosition - 1, allowOverhang) + mItemMargin; up = true; } else { overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin; up = false; } movedBy = Math.min(overhang, allowOverhang); if (movedBy < 0) { movedBy = 0; } if (movedBy == 0) { if (up) { mGetToTop = true; lazyload = false; } else { mGetToTop = false; lazyload = true; if (!loadlock) { //mLoadListener.onLoadmore(); loadlock = true; } } } else { mGetToTop = false; lazyload = true; } offsetChildren(up ? movedBy : -movedBy); if (getChildCount() > MAX_CHILD_COUNT) { recycleOffscreenViews(); } mPopulating = false; overScrolledBy = allowOverhang - overhang; } else { overScrolledBy = allowOverhang; movedBy = 0; } if (allowOverScroll) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) { if (overScrolledBy > 0) { EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge; edge.onPull((float) Math.abs(deltaY) / getHeight()); invalidate(); } } } if (mSelectorPosition != INVALID_POSITION) { final int childIndex = mSelectorPosition - mFirstPosition; if (childIndex >= 0 && childIndex < getChildCount()) { positionSelector(INVALID_POSITION, getChildAt(childIndex)); } } else { mSelectorRect.setEmpty(); } return deltaY == 0 || movedBy != 0; }