Use newest scrap view in ListView

When a ListView's contents change, it first measures, using a view at
position 0. It then scraps that view, and then scraps all of its
other views. Two scrap views thus exist for position 0. Since we were
retrieving the oldest scrap view, we would toggle between two
different views at position 0. This toggling confuses accessibility.

This change takes the newest view from the scap heap, so the view
that was recycled last (which is the one shown on the screen) is
re-used for the screen. The view used for measuring sticks around
and is available for measure again.

Bug: 33788047
Test: I verified that the switch state is announced correctly for
the cases found in the bug.

Change-Id: I936e5ad09c3594e33e80dc39236025bf8bc877b8
1 file changed