List of usage examples for android.support.v4.util LongSparseArray removeAt
public void removeAt(int i)
From source file:com.facebook.litho.MountState.java
private void unmountItem(ComponentContext context, int index, LongSparseArray<ComponentHost> hostsByMarker) { final MountItem item = getItemAt(index); // The root host item should never be unmounted as it's a reference // to the top-level LithoView. if (item == null || mLayoutOutputsIds[index] == ROOT_HOST_ID) { return;/* w w w. ja v a 2s .co m*/ } final Object content = item.getContent(); // Recursively unmount mounted children items. // This is the case when mountDiffing is enabled and unmountOrMoveOldItems() has a matching // sub tree. However, traversing the tree bottom-up, it needs to unmount a node holding that // sub tree, that will still have mounted items. (Different sequence number on LayoutOutput id) if ((content instanceof ComponentHost) && !(content instanceof LithoView)) { final ComponentHost host = (ComponentHost) content; // Concurrently remove items therefore traverse backwards. for (int i = host.getMountItemCount() - 1; i >= 0; i--) { final MountItem mountItem = host.getMountItemAt(i); final long layoutOutputId = mIndexToItemMap.keyAt(mIndexToItemMap.indexOfValue(mountItem)); for (int mountIndex = mLayoutOutputsIds.length - 1; mountIndex >= 0; mountIndex--) { if (mLayoutOutputsIds[mountIndex] == layoutOutputId) { unmountItem(context, mountIndex, hostsByMarker); break; } } } if (host.getMountItemCount() > 0) { throw new IllegalStateException("Recursively unmounting items from a ComponentHost, left" + " some items behind maybe because not tracked by its MountState"); } } final ComponentHost host = item.getHost(); host.unmount(index, item); unsetViewAttributes(item); final Component<?> component = item.getComponent(); if (isHostSpec(component)) { final ComponentHost componentHost = (ComponentHost) content; hostsByMarker.removeAt(hostsByMarker.indexOfValue(componentHost)); removeDisappearingMountContentFromComponentHost(componentHost); } unbindAndUnmountLifecycle(context, item); mIndexToItemMap.remove(mLayoutOutputsIds[index]); final String transitionKey = maybeDecrementTransitionKeyMountCount(item); if (transitionKey != null && mTransitionManager != null) { mTransitionManager.onContentUnmounted(transitionKey); } if (component.getLifecycle().canMountIncrementally()) { mCanMountIncrementallyMountItems.delete(mLayoutOutputsIds[index]); } ComponentsPools.release(context, item); mMountStats.unmountedCount++; }