Merge "Fix overscroll distance calculation for stack-from-bottom ListViews"
This commit is contained in:
@@ -381,12 +381,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
/**
|
||||
* Maximum distance to overscroll by
|
||||
*/
|
||||
private int mOverscrollMax;
|
||||
int mOverscrollMax;
|
||||
|
||||
/**
|
||||
* Content height divided by this is the overscroll limit.
|
||||
*/
|
||||
private static final int OVERSCROLL_LIMIT_DIVISOR = 3;
|
||||
static final int OVERSCROLL_LIMIT_DIVISOR = 3;
|
||||
|
||||
/**
|
||||
* Used to request a layout when we changed touch mode
|
||||
@@ -2390,7 +2390,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
awakenScrollBars();
|
||||
}
|
||||
|
||||
private int getOverscrollMax() {
|
||||
int getOverscrollMax() {
|
||||
final int childCount = getChildCount();
|
||||
if (childCount > 0) {
|
||||
return Math.min(mOverscrollMax,
|
||||
|
||||
@@ -1250,10 +1250,19 @@ public class ListView extends AbsListView {
|
||||
int findMotionRow(int y) {
|
||||
int childCount = getChildCount();
|
||||
if (childCount > 0) {
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View v = getChildAt(i);
|
||||
if (y <= v.getBottom()) {
|
||||
return mFirstPosition + i;
|
||||
if (!mStackFromBottom) {
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View v = getChildAt(i);
|
||||
if (y <= v.getBottom()) {
|
||||
return mFirstPosition + i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = childCount - 1; i >= 0; i--) {
|
||||
View v = getChildAt(i);
|
||||
if (y >= v.getTop()) {
|
||||
return mFirstPosition + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3682,6 +3691,20 @@ public class ListView extends AbsListView {
|
||||
mCheckedIdStates.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
int getOverscrollMax() {
|
||||
if (mStackFromBottom) {
|
||||
final int childCount = getChildCount();
|
||||
if (childCount > 0) {
|
||||
return Math.min(mOverscrollMax,
|
||||
(getHeight() - getChildAt(0).getTop()) / OVERSCROLL_LIMIT_DIVISOR);
|
||||
} else {
|
||||
return mOverscrollMax;
|
||||
}
|
||||
}
|
||||
return super.getOverscrollMax();
|
||||
}
|
||||
|
||||
static class SavedState extends BaseSavedState {
|
||||
SparseBooleanArray checkState;
|
||||
|
||||
Reference in New Issue
Block a user