本文整理匯總了Java中android.support.v4.widget.EdgeEffectCompat.onAbsorb方法的典型用法代碼示例。如果您正苦於以下問題:Java EdgeEffectCompat.onAbsorb方法的具體用法?Java EdgeEffectCompat.onAbsorb怎麽用?Java EdgeEffectCompat.onAbsorb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.widget.EdgeEffectCompat
的用法示例。
在下文中一共展示了EdgeEffectCompat.onAbsorb方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
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;
}
}
}
示例2: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
public void computeScroll() {
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()) {
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;
}
}
}
示例3: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
if (mScroller.computeScrollOffset()) {
final int x = mScroller.getCurrX();
final int dx = (int) (x - mLastTouchX);
mLastTouchX = x;
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;
}
}
}
示例4: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
public void computeScroll() {
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;
}
}
}
示例5: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
public void computeScroll()
{
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;
}
}
}
示例6: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
if (!mScroller.computeScrollOffset()) {
return;
}
final int pos;
if (mIsVertical) {
pos = mScroller.getCurrY();
} else {
pos = mScroller.getCurrX();
}
final int diff = (int) (pos - mLastTouchPos);
mLastTouchPos = pos;
final boolean stopped = scrollListItemsBy(diff);
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 =
(diff > 0 ? mStartEdge : mEndEdge);
boolean needsInvalidate =
edge.onAbsorb(Math.abs((int) getCurrVelocity()));
if (needsInvalidate) {
ViewCompat.postInvalidateOnAnimation(this);
}
}
finishSmoothScrolling();
}
mTouchMode = TOUCH_MODE_REST;
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
}
}
示例7: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll()
{
if ( !mScroller.computeScrollOffset() )
{
return;
}
final int pos;
if ( mIsVertical )
{
pos = mScroller.getCurrY();
}
else
{
pos = mScroller.getCurrX();
}
final int diff = ( int ) ( pos - mLastTouchPos );
mLastTouchPos = pos;
final boolean stopped = scrollListItemsBy( diff );
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 =
( diff > 0 ? mStartEdge : mEndEdge );
boolean needsInvalidate =
edge.onAbsorb( Math.abs( ( int ) getCurrVelocity() ) );
if ( needsInvalidate )
{
ViewCompat.postInvalidateOnAnimation( this );
}
}
mScroller.abortAnimation();
}
mTouchMode = TOUCH_MODE_REST;
reportScrollStateChange( OnScrollListener.SCROLL_STATE_IDLE );
}
}
示例8: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
if (!mScroller.computeScrollOffset()) {
return;
}
final int pos;
if (mIsVertical) {
pos = mScroller.getCurrY();
} else {
pos = mScroller.getCurrX();
}
final int diff = (int) (pos - mLastTouchPos);
mLastTouchPos = pos;
final boolean stopped = scrollListItemsBy(diff);
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 =
(diff > 0 ? mStartEdge : mEndEdge);
boolean needsInvalidate =
edge.onAbsorb(Math.abs((int) getCurrVelocity()));
if (needsInvalidate) {
ViewCompat.postInvalidateOnAnimation(this);
}
}
mScroller.abortAnimation();
}
mTouchMode = TOUCH_MODE_REST;
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
}
}
示例9: computeScroll
import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
if (mTouchMode == TOUCH_MODE_OVERFLING) {
handleOverfling();
} 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;
}
}
}