Beispiel #1
0
        private void toggle(View contentParent)
        {
            if (mListViewWrapper == null)
            {
                throw new Java.Lang.IllegalStateException("No ListView set!");
            }


            bool isVisible           = contentParent.Visibility == ViewStates.Visible;
            bool shouldCollapseOther = !isVisible && mLimit > 0 && mExpandedIds.Count >= mLimit;

            if (shouldCollapseOther)
            {
                long firstId = mExpandedIds[0];

                int  firstPosition = findPositionForId(firstId);
                View firstEV       = getContentParent(firstPosition);
                if (firstEV != null)
                {
                    ExpandCollapseHelper.animateCollapsing(firstEV);
                }
                mExpandedIds.Remove(firstId);

                if (mExpandCollapseListener != null)
                {
                    mExpandCollapseListener.onItemCollapsed(firstPosition);
                }
            }

            long id       = (long)contentParent.Tag;
            int  position = findPositionForId(id);

            if (isVisible)
            {
                ExpandCollapseHelper.animateCollapsing(contentParent);
                mExpandedIds.Remove(id);

                if (mExpandCollapseListener != null)
                {
                    mExpandCollapseListener.onItemCollapsed(position);
                }
            }
            else
            {
                ExpandCollapseHelper.animateExpanding(contentParent, mListViewWrapper);
                mExpandedIds.Add(id);

                if (mExpandCollapseListener != null)
                {
                    mExpandCollapseListener.onItemExpanded(position);
                }
            }
        }