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

Commit ee78b173 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 5048082 - Conversation doesn't scroll after you send a message

Fix TRANSCRIPT_MODE_NORMAL to work properly when multiple data set change
events happen before a relayout.

Change-Id: If866f7c649c1119d088020f1231b916047402b8c
parent e91e7452
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -636,6 +636,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     */
    private boolean mIsAttached;

    /**
     * Track the item count from the last time we handled a data change.
     */
    private int mLastHandledItemCount;

    /**
     * Interface definition for a callback to be invoked when the list or grid
     * has been scrolled.
@@ -1829,10 +1834,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        // Check if our previous measured size was at a point where we should scroll later.
        if (mTranscriptMode == TRANSCRIPT_MODE_NORMAL) {
            final int childCount = getChildCount();
            final int listBottom = getBottom() - getPaddingBottom();
            final int listBottom = getHeight() - getPaddingBottom();
            final View lastChild = getChildAt(childCount - 1);
            final int lastBottom = lastChild != null ? lastChild.getBottom() : listBottom;
            mForceTranscriptScroll = mFirstPosition + childCount >= mOldItemCount &&
            mForceTranscriptScroll = mFirstPosition + childCount >= mLastHandledItemCount &&
                    lastBottom <= listBottom;
        }
    }
@@ -4744,6 +4749,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    @Override
    protected void handleDataChanged() {
        int count = mItemCount;
        int lastHandledItemCount = mLastHandledItemCount;
        mLastHandledItemCount = mItemCount;
        if (count > 0) {

            int newPos;
@@ -4765,10 +4772,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                        return;
                    }
                    final int childCount = getChildCount();
                    final int listBottom = getBottom() - getPaddingBottom();
                    final int listBottom = getHeight() - getPaddingBottom();
                    final View lastChild = getChildAt(childCount - 1);
                    final int lastBottom = lastChild != null ? lastChild.getBottom() : listBottom;
                    if (mFirstPosition + childCount >= mOldItemCount && lastBottom <= listBottom) {
                    if (mFirstPosition + childCount >= lastHandledItemCount &&
                            lastBottom <= listBottom) {
                        mLayoutMode = LAYOUT_FORCE_BOTTOM;
                        return;
                    }