@@ -372,7 +372,8 @@ public boolean areAllItemsEnabled() {
372372
373373 @ Override
374374 public boolean isEnabled (int flatListPos ) {
375- final ExpandableListPosition pos = getUnflattenedPos (flatListPos ).position ;
375+ final PositionMetadata metadata = getUnflattenedPos (flatListPos );
376+ final ExpandableListPosition pos = metadata .position ;
376377
377378 boolean retValue ;
378379 if (pos .type == ExpandableListPosition .CHILD ) {
@@ -382,7 +383,7 @@ public boolean isEnabled(int flatListPos) {
382383 retValue = true ;
383384 }
384385
385- pos .recycle ();
386+ metadata .recycle ();
386387
387388 return retValue ;
388389 }
@@ -461,7 +462,8 @@ public View getView(int flatListPos, View convertView, ViewGroup parent) {
461462
462463 @ Override
463464 public int getItemViewType (int flatListPos ) {
464- final ExpandableListPosition pos = getUnflattenedPos (flatListPos ).position ;
465+ final PositionMetadata metadata = getUnflattenedPos (flatListPos );
466+ final ExpandableListPosition pos = metadata .position ;
465467
466468 int retValue ;
467469 if (mExpandableListAdapter instanceof HeterogeneousExpandableList ) {
@@ -481,7 +483,7 @@ public int getItemViewType(int flatListPos) {
481483 }
482484 }
483485
484- pos .recycle ();
486+ metadata .recycle ();
485487
486488 return retValue ;
487489 }
@@ -590,8 +592,10 @@ private void refreshExpGroupMetadataList(boolean forceChildrenCountRefresh,
590592 * @param groupPos position of the group to collapse
591593 */
592594 boolean collapseGroup (int groupPos ) {
593- PositionMetadata pm = getFlattenedPos (ExpandableListPosition .obtain (
594- ExpandableListPosition .GROUP , groupPos , -1 , -1 ));
595+ ExpandableListPosition elGroupPos = ExpandableListPosition .obtain (
596+ ExpandableListPosition .GROUP , groupPos , -1 , -1 );
597+ PositionMetadata pm = getFlattenedPos (elGroupPos );
598+ elGroupPos .recycle ();
595599 if (pm == null ) return false ;
596600
597601 boolean retValue = collapseGroup (pm );
@@ -631,8 +635,10 @@ boolean collapseGroup(PositionMetadata posMetadata) {
631635 * @param groupPos the group to be expanded
632636 */
633637 boolean expandGroup (int groupPos ) {
634- PositionMetadata pm = getFlattenedPos (ExpandableListPosition .obtain (
635- ExpandableListPosition .GROUP , groupPos , -1 , -1 ));
638+ ExpandableListPosition elGroupPos = ExpandableListPosition .obtain (
639+ ExpandableListPosition .GROUP , groupPos , -1 , -1 );
640+ PositionMetadata pm = getFlattenedPos (elGroupPos );
641+ elGroupPos .recycle ();
636642 boolean retValue = expandGroup (pm );
637643 pm .recycle ();
638644 return retValue ;
@@ -971,7 +977,10 @@ static public class PositionMetadata {
971977 public int groupInsertIndex ;
972978
973979 private void resetState () {
974- position = null ;
980+ if (position != null ) {
981+ position .recycle ();
982+ position = null ;
983+ }
975984 groupMetadata = null ;
976985 groupInsertIndex = 0 ;
977986 }
@@ -1005,6 +1014,7 @@ private static PositionMetadata getRecycledOrCreate() {
10051014 }
10061015
10071016 public void recycle () {
1017+ resetState ();
10081018 synchronized (sPool ) {
10091019 if (sPool .size () < MAX_POOL_SIZE ) {
10101020 sPool .add (this );
0 commit comments