I am studying StackView and AdapterViewAnimator. And found that, in AdapterViewAnimator, it does NOT remove children directly, but put them into an array, and does remove at next phase.
Could someone please explain what is the reason of this design? Why can't I just remove them directly?
more information: I have also noticed that due to above design, StackView (which extends AdapterViewAnimator) will have some children linger on... And cause me wanna ask why.
more information: below is the code snippet that I mentioned above: (from AdapterViewAnimator.showOnly(int, boolean) )
// This section clears out any items that are in our active views list
// but are outside the effective bounds of our window (this is becomes an issue
// at the extremities of the list, eg. where newWindowStartUnbounded < 0 or
// newWindowEndUnbounded > adapterCount - 1
for (Integer index : mViewsMap.keySet()) {
boolean remove = false;
if (!wrap && (index < rangeStart || index > rangeEnd)) {
remove = true;
} else if (wrap && (index > rangeEnd && index < rangeStart)) {
remove = true;
}
if (remove) {
View previousView = mViewsMap.get(index).view;
int oldRelativeIndex = mViewsMap.get(index).relativeIndex;
mPreviousViews.add(index);
transformViewForTransition(oldRelativeIndex, -1, previousView, animate);
}
}
Thanks. BR, Henry