summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-11-10 16:57:05 -0800
committerAdam Powell <adamp@google.com>2010-11-10 17:07:35 -0800
commit0785279dad89d90564f42beb2c4620bf387a966e (patch)
tree817e3c7ef7889a5e3b03eba0ddd1a4509599ed4d
parentcf7ae94bce227e86aa5534ec36691a2611572ef9 (diff)
downloadframeworks_base-0785279dad89d90564f42beb2c4620bf387a966e.zip
frameworks_base-0785279dad89d90564f42beb2c4620bf387a966e.tar.gz
frameworks_base-0785279dad89d90564f42beb2c4620bf387a966e.tar.bz2
Refine AbsListView transcript mode behavior.
Make transcript mode only scroll to the bottom if the last item is already scrolled fully to the bottom when the change occurs Before this, transcript mode would cause a list to scroll to the bottom as long as the last item in the adapter was visible at all. Long items would make this behave unexpectedly. Change-Id: Ia6a52c969ea6d50653cf2b8cd4dc30ba517cf803
-rw-r--r--core/java/android/widget/AbsListView.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index d0ed23f..ab5ff3d 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -3856,12 +3856,23 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
// Update this first, since setNextSelectedPositionInt inspects it
mNeedSync = false;
- if (mTranscriptMode == TRANSCRIPT_MODE_ALWAYS_SCROLL ||
- (mTranscriptMode == TRANSCRIPT_MODE_NORMAL &&
- mFirstPosition + getChildCount() >= mOldItemCount)) {
+ if (mTranscriptMode == TRANSCRIPT_MODE_ALWAYS_SCROLL) {
mLayoutMode = LAYOUT_FORCE_BOTTOM;
return;
}
+ if (mTranscriptMode == TRANSCRIPT_MODE_NORMAL) {
+ final int childCount = getChildCount();
+ final int listBottom = getBottom() - getPaddingBottom();
+ final View lastChild = getChildAt(childCount - 1);
+ final int lastBottom = lastChild != null ? lastChild.getBottom() : listBottom;
+ if (mFirstPosition + childCount >= mOldItemCount && lastBottom <= listBottom) {
+ mLayoutMode = LAYOUT_FORCE_BOTTOM;
+ return;
+ }
+ // Something new came in and we didn't scroll; give the user a clue that
+ // there's something new.
+ awakenScrollBars();
+ }
switch (mSyncMode) {
case SYNC_SELECTED_POSITION: