Merge "Reattach header view after DPAD scroll."
This commit is contained in:
@@ -2919,11 +2919,9 @@ public class ListView extends AbsListView {
|
|||||||
while (first.getBottom() < listTop) {
|
while (first.getBottom() < listTop) {
|
||||||
AbsListView.LayoutParams layoutParams = (LayoutParams) first.getLayoutParams();
|
AbsListView.LayoutParams layoutParams = (LayoutParams) first.getLayoutParams();
|
||||||
if (recycleBin.shouldRecycleViewType(layoutParams.viewType)) {
|
if (recycleBin.shouldRecycleViewType(layoutParams.viewType)) {
|
||||||
detachViewFromParent(first);
|
|
||||||
recycleBin.addScrapView(first, mFirstPosition);
|
recycleBin.addScrapView(first, mFirstPosition);
|
||||||
} else {
|
|
||||||
removeViewInLayout(first);
|
|
||||||
}
|
}
|
||||||
|
detachViewFromParent(first);
|
||||||
first = getChildAt(0);
|
first = getChildAt(0);
|
||||||
mFirstPosition++;
|
mFirstPosition++;
|
||||||
}
|
}
|
||||||
@@ -2950,11 +2948,9 @@ public class ListView extends AbsListView {
|
|||||||
while (last.getTop() > listBottom) {
|
while (last.getTop() > listBottom) {
|
||||||
AbsListView.LayoutParams layoutParams = (LayoutParams) last.getLayoutParams();
|
AbsListView.LayoutParams layoutParams = (LayoutParams) last.getLayoutParams();
|
||||||
if (recycleBin.shouldRecycleViewType(layoutParams.viewType)) {
|
if (recycleBin.shouldRecycleViewType(layoutParams.viewType)) {
|
||||||
detachViewFromParent(last);
|
|
||||||
recycleBin.addScrapView(last, mFirstPosition+lastIndex);
|
recycleBin.addScrapView(last, mFirstPosition+lastIndex);
|
||||||
} else {
|
|
||||||
removeViewInLayout(last);
|
|
||||||
}
|
}
|
||||||
|
detachViewFromParent(last);
|
||||||
last = getChildAt(--lastIndex);
|
last = getChildAt(--lastIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.test.TouchUtils;
|
|||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
import android.test.suitebuilder.annotation.MediumTest;
|
import android.test.suitebuilder.annotation.MediumTest;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.listview.ListWithEditTextHeader;
|
import android.widget.listview.ListWithEditTextHeader;
|
||||||
@@ -63,4 +64,22 @@ public class ListWithEditTextHeaderTest extends ActivityInstrumentationTestCase2
|
|||||||
assertTrue("header does not have focus", mListView.getChildAt(0).isFocused());
|
assertTrue("header does not have focus", mListView.getChildAt(0).isFocused());
|
||||||
assertEquals("something is selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
|
assertEquals("something is selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
public void testScrollingDoesNotDetachHeaderViewFromWindow() {
|
||||||
|
View header = mListView.getChildAt(0);
|
||||||
|
assertNotNull("header is not attached to a window (?!)", header.getWindowToken());
|
||||||
|
|
||||||
|
// Scroll header off the screen and back onto the screen
|
||||||
|
int numItemsOnScreen = mListView.getChildCount();
|
||||||
|
for (int i = 0; i < numItemsOnScreen; i++) {
|
||||||
|
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < numItemsOnScreen; i++) {
|
||||||
|
sendKeys(KeyEvent.KEYCODE_DPAD_UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the header was not accidentally left detached from its window
|
||||||
|
assertNotNull("header has lost its window", header.getWindowToken());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user