am de59baab: Merge "Ensure list scrolling API is in parity with view scrolling API" into klp-dev

* commit 'de59baab31271a186a2f32719abd19a8adbda1e3':
  Ensure list scrolling API is in parity with view scrolling API
This commit is contained in:
Alan Viverette
2013-09-03 16:35:56 -07:00
committed by Android Git Automerger
2 changed files with 32 additions and 5 deletions

View File

@@ -30397,6 +30397,7 @@ package android.widget {
ctor public AbsListView(android.content.Context, android.util.AttributeSet, int); ctor public AbsListView(android.content.Context, android.util.AttributeSet, int);
method public void afterTextChanged(android.text.Editable); method public void afterTextChanged(android.text.Editable);
method public void beforeTextChanged(java.lang.CharSequence, int, int, int); method public void beforeTextChanged(java.lang.CharSequence, int, int, int);
method public boolean canScrollList(int);
method public void clearChoices(); method public void clearChoices();
method public void clearTextFilter(); method public void clearTextFilter();
method public void deferNotifyDataSetChanged(); method public void deferNotifyDataSetChanged();
@@ -30438,7 +30439,7 @@ package android.widget {
method public int pointToPosition(int, int); method public int pointToPosition(int, int);
method public long pointToRowId(int, int); method public long pointToRowId(int, int);
method public void reclaimViews(java.util.List<android.view.View>); method public void reclaimViews(java.util.List<android.view.View>);
method public boolean scrollListBy(int); method public void scrollListBy(int);
method public void setAdapter(android.widget.ListAdapter); method public void setAdapter(android.widget.ListAdapter);
method public void setCacheColorHint(int); method public void setCacheColorHint(int);
method public void setChoiceMode(int); method public void setChoiceMode(int);

View File

@@ -4924,11 +4924,37 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* Scrolls the list items within the view by a specified number of pixels. * Scrolls the list items within the view by a specified number of pixels.
* *
* @param y the amount of pixels to scroll by vertically * @param y the amount of pixels to scroll by vertically
* @return true if the list is able to scroll, or false if the list is * @see #canScrollList(int)
* already at the beginning/end and unable to scroll any more.
*/ */
public boolean scrollListBy(int y) { public void scrollListBy(int y) {
return !trackMotionScroll(-y, -y); trackMotionScroll(-y, -y);
}
/**
* Check if the items in the list can be scrolled in a certain direction.
*
* @param direction Negative to check scrolling up, positive to check
* scrolling down.
* @return true if the list can be scrolled in the specified direction,
* false otherwise.
* @see #scrollListBy(int)
*/
public boolean canScrollList(int direction) {
final int childCount = getChildCount();
if (childCount == 0) {
return false;
}
final int firstPosition = mFirstPosition;
final Rect listPadding = mListPadding;
if (direction > 0) {
final int lastBottom = getChildAt(childCount - 1).getBottom();
final int lastPosition = firstPosition + childCount;
return lastPosition < mItemCount || lastBottom > getHeight() - listPadding.bottom;
} else {
final int firstTop = getChildAt(0).getTop();
return firstPosition > 0 || firstTop < listPadding.top;
}
} }
/** /**