Пример #1
0
        private void OnChildClick(object sender, ExpandableListView.ChildClickEventArgs childClickEventArgs)
        {
            var listView = ListView;

            if (listView == null)
            {
                return;
            }

            var newValue =
                ((MvxExpandableListAdapter)listView.ExpandableListAdapter).GetRawItem(
                    childClickEventArgs.GroupPosition, childClickEventArgs.ChildPosition);

            if (!newValue.Equals(_currentValue))
            {
                var pos = listView.GetFlatListPosition(
                    ExpandableListView.GetPackedPositionForChild(
                        childClickEventArgs.GroupPosition,
                        childClickEventArgs.ChildPosition));
                listView.SetItemChecked(pos, true);

                _currentValue = newValue;
                FireValueChanged(newValue);
            }
        }
        /// <summary>
        /// An intermediary that will extract a root view from the given positions
        /// and then toggle the content of the view.
        /// </summary>
        /// <param name="groupPosition"></param>
        /// <param name="childPosition"></param>
        private void Toggle(int groupPosition, int childPosition)
        {
            if (!list.IsGroupExpanded(groupPosition))
            {
                return; // We can't toggle; there is nothing to toggle.
            }

            bool isExpanded = IsExpanded(groupPosition, childPosition);

            int flatPosition = list.GetFlatListPosition(ExpandableListView.GetPackedPositionForChild(groupPosition, childPosition));
            int first        = list.FirstVisiblePosition;

            RootView view = (RootView)list.GetChildAt(flatPosition - first);

            if (view != null)
            {
                Toggle(view);
            }

            if (view == null && isExpanded)
            {
                __expandedChildren.Remove(this[groupPosition, childPosition]);
            }
            else
            {
                __expandedChildren.AddLast(this[groupPosition, childPosition]);
            }
        }
Пример #3
0
        protected override void SetValueImpl(object target, object value)
        {
            var listView = (MvxExpandableListView)target;

            if (value == null)
            {
                _currentValue = null;
                listView.ClearChoices();
                return;
            }
            var positions = ((MvxExpandableListAdapter)listView.ExpandableListAdapter).GetPositions(value);

            if (positions == null)
            {
                MvxBindingTrace.Trace(MvxTraceLevel.Warning, "Value not found for spinner {0}", value.ToString());
                return;
            }

            _currentValue = value;
            listView.SetSelectedChild(positions.Item1, positions.Item2, true);

            var pos =
                listView.GetFlatListPosition(ExpandableListView.GetPackedPositionForChild(positions.Item1,
                                                                                          positions.Item2));

            listView.SetItemChecked(pos, true);
        }
 /// <summary>
 /// Updates the child row view.
 /// </summary>
 /// <param name="groupPosition"></param>
 /// <param name="childPosition"></param>
 private void UpdateChild(int groupPosition, int childPosition)
 {
     if ((groupPosition >= 0 && groupPosition < GroupCount) &&
         (childPosition >= 0 && childPosition < GetChildrenCount(groupPosition)))
     {
         int  flatPosition = list.GetFlatListPosition(ExpandableListView.GetPackedPositionForChild(groupPosition, childPosition));
         int  first        = list.FirstVisiblePosition;
         View convert      = list.GetChildAt(flatPosition - first);
         GetChildView(groupPosition, childPosition, list.IsGroupExpanded(childPosition), convert, list);
     }
 }
 /// <summary>
 /// Queries the flat position of the child at the given position.
 /// </summary>
 /// <param name="groupPosition"></param>
 /// <param name="childPosition"></param>
 /// <returns></returns>
 public int GetFlatPositionFor(int groupPosition, int childPosition)
 {
     return(list.GetFlatListPosition(ExpandableListView.GetPackedPositionForChild(groupPosition, childPosition)));
 }
 /// <summary>
 /// Queries the packed position of the given child.
 /// </summary>
 /// <param name="group"></param>
 /// <param name="child"></param>
 /// <returns></returns>
 public long GetPackedPositionFor(Group group, Child child)
 {
     return(ExpandableListView.GetPackedPositionForChild(IndexOf(group), IndexOf(group, child)));
 }
Пример #7
0
 public override long GetGroupId(int groupPosition)
 {
     return(ExpandableListView.GetPackedPositionForChild(groupPosition, 0));
 }
Пример #8
0
 public override long GetChildId(int groupPosition, int childPosition)
 {
     return(ExpandableListView.GetPackedPositionForChild(groupPosition, childPosition + 1));
 }