mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-20 08:39:55 +08:00
Make bottom navigation item pool non-static
This also fixes a flaky test where items acquired from the pool were still attached to their old parent. Bug: 35422793 Bug: 35395583 Change-Id: I303d49bb4a287856baf997bd85d42fd53131c32b PiperOrigin-RevId: 150129729
This commit is contained in:
parent
ddcda55a30
commit
3bd7fdf7c1
@ -44,8 +44,7 @@ public class BottomNavigationMenuView extends ViewGroup implements MenuView {
|
||||
private final int mItemHeight;
|
||||
private final OnClickListener mOnClickListener;
|
||||
private final BottomNavigationAnimationHelperBase mAnimationHelper;
|
||||
private static final Pools.Pool<BottomNavigationItemView> sItemPool =
|
||||
new Pools.SynchronizedPool<>(5);
|
||||
private final Pools.Pool<BottomNavigationItemView> mItemPool = new Pools.SynchronizedPool<>(5);
|
||||
|
||||
private boolean mShiftingMode = true;
|
||||
|
||||
@ -249,12 +248,12 @@ public class BottomNavigationMenuView extends ViewGroup implements MenuView {
|
||||
}
|
||||
|
||||
public void buildMenuView() {
|
||||
removeAllViews();
|
||||
if (mButtons != null) {
|
||||
for (BottomNavigationItemView item : mButtons) {
|
||||
sItemPool.release(item);
|
||||
mItemPool.release(item);
|
||||
}
|
||||
}
|
||||
removeAllViews();
|
||||
if (mMenu.size() == 0) {
|
||||
mSelectedItemId = 0;
|
||||
mSelectedItemPosition = 0;
|
||||
@ -306,7 +305,7 @@ public class BottomNavigationMenuView extends ViewGroup implements MenuView {
|
||||
}
|
||||
|
||||
private BottomNavigationItemView getNewItem() {
|
||||
BottomNavigationItemView item = sItemPool.acquire();
|
||||
BottomNavigationItemView item = mItemPool.acquire();
|
||||
if (item == null) {
|
||||
item = new BottomNavigationItemView(getContext());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user