Merge change 23381 into eclair
* changes: Prevent ListView from scrolling/flinging its content when the content fits on screen.
This commit is contained in:
@@ -46,7 +46,6 @@ import android.os.SystemClock;
|
|||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Config;
|
import android.util.Config;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.EventLog;
|
import android.util.EventLog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pool;
|
import android.util.Pool;
|
||||||
|
|||||||
@@ -1996,7 +1996,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
if (y != mLastY) {
|
if (y != mLastY) {
|
||||||
deltaY -= mMotionCorrection;
|
deltaY -= mMotionCorrection;
|
||||||
int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : deltaY;
|
int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : deltaY;
|
||||||
trackMotionScroll(deltaY, incrementalDeltaY);
|
// No need to do all this work if we're not going to move anyway
|
||||||
|
if (incrementalDeltaY != 0) {
|
||||||
|
trackMotionScroll(deltaY, incrementalDeltaY);
|
||||||
|
}
|
||||||
|
|
||||||
// Check to see if we have bumped into the scroll limit
|
// Check to see if we have bumped into the scroll limit
|
||||||
View motionView = this.getChildAt(mMotionPosition - mFirstPosition);
|
View motionView = this.getChildAt(mMotionPosition - mFirstPosition);
|
||||||
@@ -2063,7 +2066,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
if (mSelector != null) {
|
if (mSelector != null) {
|
||||||
Drawable d = mSelector.getCurrent();
|
Drawable d = mSelector.getCurrent();
|
||||||
if (d != null && d instanceof TransitionDrawable) {
|
if (d != null && d instanceof TransitionDrawable) {
|
||||||
((TransitionDrawable)d).resetTransition();
|
((TransitionDrawable) d).resetTransition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
postDelayed(new Runnable() {
|
postDelayed(new Runnable() {
|
||||||
@@ -2087,15 +2090,27 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
mTouchMode = TOUCH_MODE_REST;
|
mTouchMode = TOUCH_MODE_REST;
|
||||||
break;
|
break;
|
||||||
case TOUCH_MODE_SCROLL:
|
case TOUCH_MODE_SCROLL:
|
||||||
final VelocityTracker velocityTracker = mVelocityTracker;
|
final int childCount = getChildCount();
|
||||||
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
|
if (childCount > 0) {
|
||||||
final int initialVelocity = (int) velocityTracker.getYVelocity();
|
if (mFirstPosition == 0 && getChildAt(0).getTop() >= mListPadding.top &&
|
||||||
if (Math.abs(initialVelocity) > mMinimumVelocity && (getChildCount() > 0)) {
|
mFirstPosition + childCount < mItemCount &&
|
||||||
if (mFlingRunnable == null) {
|
getChildAt(childCount - 1).getBottom() <=
|
||||||
mFlingRunnable = new FlingRunnable();
|
getHeight() - mListPadding.bottom) {
|
||||||
|
mTouchMode = TOUCH_MODE_REST;
|
||||||
|
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
|
||||||
|
} else {
|
||||||
|
final VelocityTracker velocityTracker = mVelocityTracker;
|
||||||
|
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
|
||||||
|
final int initialVelocity = (int) velocityTracker.getYVelocity();
|
||||||
|
|
||||||
|
if (Math.abs(initialVelocity) > mMinimumVelocity) {
|
||||||
|
if (mFlingRunnable == null) {
|
||||||
|
mFlingRunnable = new FlingRunnable();
|
||||||
|
}
|
||||||
|
reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
|
||||||
|
mFlingRunnable.start(-initialVelocity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
|
|
||||||
mFlingRunnable.start(-initialVelocity);
|
|
||||||
} else {
|
} else {
|
||||||
mTouchMode = TOUCH_MODE_REST;
|
mTouchMode = TOUCH_MODE_REST;
|
||||||
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
|
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
|
||||||
|
|||||||
@@ -1328,19 +1328,23 @@ public class ListView extends AbsListView {
|
|||||||
|
|
||||||
// Make sure we are 1) Too low, and 2) Either there are more rows below the
|
// Make sure we are 1) Too low, and 2) Either there are more rows below the
|
||||||
// last row or the last row is scrolled off the bottom of the drawable area
|
// last row or the last row is scrolled off the bottom of the drawable area
|
||||||
if (topOffset > 0 && (lastPosition < mItemCount - 1 || lastBottom > end)) {
|
if (topOffset > 0) {
|
||||||
if (lastPosition == mItemCount - 1 ) {
|
if (lastPosition < mItemCount - 1 || lastBottom > end) {
|
||||||
// Don't pull the bottom too far up
|
if (lastPosition == mItemCount - 1) {
|
||||||
topOffset = Math.min(topOffset, lastBottom - end);
|
// Don't pull the bottom too far up
|
||||||
}
|
topOffset = Math.min(topOffset, lastBottom - end);
|
||||||
// Move everything up
|
}
|
||||||
offsetChildrenTopAndBottom(-topOffset);
|
// Move everything up
|
||||||
if (lastPosition < mItemCount - 1) {
|
offsetChildrenTopAndBottom(-topOffset);
|
||||||
// Fill the gap that was opened below the last position with more rows, if
|
if (lastPosition < mItemCount - 1) {
|
||||||
// possible
|
// Fill the gap that was opened below the last position with more rows, if
|
||||||
fillDown(lastPosition + 1, lastChild.getBottom() + mDividerHeight);
|
// possible
|
||||||
// Close up the remaining gap
|
fillDown(lastPosition + 1, lastChild.getBottom() + mDividerHeight);
|
||||||
adjustViewsUpOrDown();
|
// Close up the remaining gap
|
||||||
|
adjustViewsUpOrDown();
|
||||||
|
}
|
||||||
|
} else if (lastPosition == mItemCount - 1) {
|
||||||
|
adjustViewsUpOrDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user