am 77f9e5dc: am d5b18387: Merge "Ensure partially-detached AbsListView children are removed" into mnc-dev
* commit '77f9e5dcbbb02957a39d62971aa0a44acea2d7c0': Ensure partially-detached AbsListView children are removed
This commit is contained in:
@@ -6605,6 +6605,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
void addScrapView(View scrap, int position) {
|
void addScrapView(View scrap, int position) {
|
||||||
final AbsListView.LayoutParams lp = (AbsListView.LayoutParams) scrap.getLayoutParams();
|
final AbsListView.LayoutParams lp = (AbsListView.LayoutParams) scrap.getLayoutParams();
|
||||||
if (lp == null) {
|
if (lp == null) {
|
||||||
|
// Can't recycle, skip the scrap heap.
|
||||||
|
getSkippedScrap().add(scrap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6614,6 +6616,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
// should otherwise not be recycled.
|
// should otherwise not be recycled.
|
||||||
final int viewType = lp.viewType;
|
final int viewType = lp.viewType;
|
||||||
if (!shouldRecycleViewType(viewType)) {
|
if (!shouldRecycleViewType(viewType)) {
|
||||||
|
// Can't recycle, skip the scrap heap.
|
||||||
|
getSkippedScrap().add(scrap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6633,22 +6637,19 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
// If the adapter has stable IDs, we can reuse the view for
|
// If the adapter has stable IDs, we can reuse the view for
|
||||||
// the same data.
|
// the same data.
|
||||||
if (mTransientStateViewsById == null) {
|
if (mTransientStateViewsById == null) {
|
||||||
mTransientStateViewsById = new LongSparseArray<View>();
|
mTransientStateViewsById = new LongSparseArray<>();
|
||||||
}
|
}
|
||||||
mTransientStateViewsById.put(lp.itemId, scrap);
|
mTransientStateViewsById.put(lp.itemId, scrap);
|
||||||
} else if (!mDataChanged) {
|
} else if (!mDataChanged) {
|
||||||
// If the data hasn't changed, we can reuse the views at
|
// If the data hasn't changed, we can reuse the views at
|
||||||
// their old positions.
|
// their old positions.
|
||||||
if (mTransientStateViews == null) {
|
if (mTransientStateViews == null) {
|
||||||
mTransientStateViews = new SparseArray<View>();
|
mTransientStateViews = new SparseArray<>();
|
||||||
}
|
}
|
||||||
mTransientStateViews.put(position, scrap);
|
mTransientStateViews.put(position, scrap);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, we'll have to remove the view and start over.
|
// Otherwise, we'll have to remove the view and start over.
|
||||||
if (mSkippedScrap == null) {
|
getSkippedScrap().add(scrap);
|
||||||
mSkippedScrap = new ArrayList<View>();
|
|
||||||
}
|
|
||||||
mSkippedScrap.add(scrap);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mViewTypeCount == 1) {
|
if (mViewTypeCount == 1) {
|
||||||
@@ -6663,6 +6664,13 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ArrayList<View> getSkippedScrap() {
|
||||||
|
if (mSkippedScrap == null) {
|
||||||
|
mSkippedScrap = new ArrayList<>();
|
||||||
|
}
|
||||||
|
return mSkippedScrap;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finish the removal of any views that skipped the scrap heap.
|
* Finish the removal of any views that skipped the scrap heap.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user