List of usage examples for android.support.v4.widget EdgeEffectCompat onAbsorb
public boolean onAbsorb(int velocity)
From source file:com.android.photos.views.GalleryThumbnailView.java
@Override public void computeScroll() { if (mScroller.computeScrollOffset()) { final int x = mScroller.getCurrX(); final int dx = (int) (x - mLastTouchX); mLastTouchX = x;// w w w .j a v a 2s. co m final boolean stopped = !trackMotionScroll(dx, false); if (!stopped && !mScroller.isFinished()) { ViewCompat.postInvalidateOnAnimation(this); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dx > 0) { edge = mLeftEdge; } else { edge = mRightEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); ViewCompat.postInvalidateOnAnimation(this); } mScroller.abortAnimation(); } mTouchMode = TOUCH_MODE_IDLE; } } }
From source file:cn.ieclipse.af.view.StaggeredGridView.java
public void computeScroll() { if (mScroller.computeScrollOffset()) { final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); mLastTouchY = y;// ww w . j av a 2 s . c o m final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { ViewCompat.postInvalidateOnAnimation(this); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; } else { edge = mBottomEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); ViewCompat.postInvalidateOnAnimation(this); } mScroller.abortAnimation(); } mTouchMode = TOUCH_MODE_IDLE; } } }
From source file:com.irontec.jaigiro.widgets.StaggeredGridView.java
@Override public void computeScroll() { if (mScroller.computeScrollOffset()) { final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); mLastTouchY = y;// w w w . j a v a 2s.c om final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { invokeOnItemScrollListener(); ViewCompat.postInvalidateOnAnimation(this); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; } else { edge = mBottomEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); ViewCompat.postInvalidateOnAnimation(this); } mScroller.abortAnimation(); } setTouchMode(TOUCH_MODE_IDLE); } } }
From source file:cn.iterlog.myapplication.widget.overscroll.StaggeredGridView.java
public void computeScroll() { if (mScroller.computeScrollOffset()) { final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); mLastTouchY = y;/*from w ww.j ava2 s .co m*/ final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { postInvalidate(); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; } else { edge = mBottomEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); postInvalidate(); } mScroller.abortAnimation(); } mTouchMode = TOUCH_MODE_IDLE; } } }
From source file:com.app.afteryou.ui.staggered.StaggeredGridView.java
public void computeScroll() { if (mScroller.computeScrollOffset()) { final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); mLastTouchY = y;//from w w w . ja v a 2 s . c om final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { invokeOnItemScrollListener(); ViewCompat.postInvalidateOnAnimation(this); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; } else { edge = mBottomEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); ViewCompat.postInvalidateOnAnimation(this); } mScroller.abortAnimation(); } setTouchMode(TOUCH_MODE_IDLE); } } }
From source file:chan.android.app.bitwise.util.StaggeredGridView.java
@Override public void computeScroll() { if (mScroller.computeScrollOffset()) { final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); mLastTouchY = y;//from w ww. j av a2s .c o m final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { postInvalidate(); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; } else { edge = mBottomEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); postInvalidate(); } mScroller.abortAnimation(); } mTouchMode = TOUCH_MODE_IDLE; } } }
From source file:mrfu.blurstaggered.lib.view.StaggeredGridView.java
@Override public void computeScroll() { if (mScroller.computeScrollOffset()) { final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); mLastTouchY = y;/*from w ww .j ava2 s .c o m*/ final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { //TODO MrFu invokeOnItemScrollListener(); postInvalidate(); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; } else { edge = mBottomEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); postInvalidate(); } mScroller.abortAnimation(); } mTouchMode = TOUCH_MODE_IDLE; setTouchMode(TOUCH_MODE_IDLE); } } }
From source file:com.bolaa.medical.view.pulltorefreshgrid.StaggeredGridView.java
@Override public void computeScroll() { // Log.d("TAG", "----------------scroller-----------" + mScroller.computeScrollOffset()); // Log.d("qz", "----------------scroller-----------" + mScroller.computeScrollOffset()+",first="+getFirstVisiblePosition()+",last="+getLastPosition()); // LogUtil.d("TAG---------------onTouch finish-----------" + mScroller.isFinished()); int firstVisibleItem = getFirstVisiblePosition(); int lastVisibleItem = getLastPosition(); if (mScroller.isFinished()) { if (mFlingListener != null) { if (isOnTouch) return; if (mIsFling) { // LogUtil.d("---------------------" + getLastPosition()); if (mOnExposeChanged != null) { if (lastVisibleItem != -1) { mOnExposeChanged.exposeChanged(lastVisibleItem); }//from w w w . j ava2 s . c om } mIsFling = false; } mFlingListener.endFling(); } } else { if (mFlingListener != null) { mFlingListener.onFling(); } } //? if (mOnScrollListener != null) { mOnScrollListener.onScroll(firstVisibleItem, lastVisibleItem); } if (mScroller.computeScrollOffset()) { final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); mLastTouchY = y; final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { postInvalidate(); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; } else { edge = mBottomEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); postInvalidate(); } mScroller.abortAnimation(); } mTouchMode = TOUCH_MODE_IDLE; reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE, getFirstVisiblePosition(), getLastPosition()); // Log.d("TAG", "----------------scroller1111111-----------" + mScroller.computeScrollOffset()); } } }
From source file:com.android.backups.BackupStaggeredGridView.java
@Override public void computeScroll() { if (mScroller.computeScrollOffset()) { final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); mLastTouchY = y;//from ww w . jav a2 s . co m final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { invokeOnItemScrollListener(); postInvalidate(); } else { if (stopped) { final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) { final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; } else { edge = mBottomEdge; } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); postInvalidate(); } mScroller.abortAnimation(); } mTouchMode = TOUCH_MODE_IDLE; setTouchMode(mTouchMode); } } }
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
@Override public void computeScroll() { if (mTouchMode == TOUCH_MODE_OVERFLING) { handleOverfling();/*from w ww . j a v a 2 s . c o m*/ } else if (mScroller.computeScrollOffset()) { final int overScrollMode = ViewCompat.getOverScrollMode(this); final boolean supportsOverscroll = overScrollMode != ViewCompat.OVER_SCROLL_NEVER; final int y = mScroller.getCurrY(); final int dy = (int) (y - mLastTouchY); // TODO: Figure out why mLastTouchY is being updated here. Consider using a new class // variable since this value does not represent the last place on the screen where a // touch occurred. mLastTouchY = y; // Check if the top of the motion view is where it is // supposed to be final View motionView = supportsOverscroll && getChildCount() > 0 ? getChildAt(0) : null; final int motionViewPrevTop = motionView != null ? motionView.getTop() : 0; final boolean stopped = !trackMotionScroll(dy, false); if (!stopped && !mScroller.isFinished()) { mTouchMode = TOUCH_MODE_IDLE; ViewCompat.postInvalidateOnAnimation(this); } else if (stopped && dy != 0 && supportsOverscroll) { // Check to see if we have bumped into the scroll limit if (motionView != null) { final int motionViewRealTop = motionView.getTop(); // Apply overscroll final int overscroll = -dy - (motionViewRealTop - motionViewPrevTop); overScrollBy(0, overscroll, 0, getScrollY(), 0, 0, 0, mOverscrollDistance, true); } final EdgeEffectCompat edge; if (dy > 0) { edge = mTopEdge; mBottomEdge.finish(); } else { edge = mBottomEdge; mTopEdge.finish(); } edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity())); if (mScroller.computeScrollOffset()) { mScroller.notifyVerticalEdgeReached(getScrollY(), 0, mOverscrollDistance); } mTouchMode = TOUCH_MODE_OVERFLING; ViewCompat.postInvalidateOnAnimation(this); } else { mTouchMode = TOUCH_MODE_IDLE; } } }