Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0785279d authored by Adam Powell's avatar Adam Powell
Browse files

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
parent cf7ae94b
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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: