Beispiel #1
0
        protected override IShadow <TView> Create(XamFormsContext context, TElement initial)
        {
            // call down to the base to get the shadow
            var shadow = (Shadow <TView>)base.Create(context, initial);

            // create the connector to the list view
            var groupConnector = _connector(context, shadow);

            //// get the collection comparer, which the user may have overridden from the default one
            var comparer = initial.Attributes.GetAttributeOrDefault(Group.ComparerAttribute) ?? PrimitiveCollectionComparer.Default;

            //// create the update handler which connects the comparer with the connector
            var dataUpdateHandler = new BackingStoreUpdateHandler <XamFormsContext, TView, IPrimitive>(groupConnector, XamLayoutGroup.ChildrenAttribute, comparer);

            //// and finally set this as the adapter to be used
            this.SetChildrenAdapter(context, shadow, dataUpdateHandler);

            return(shadow);
        }
Beispiel #2
0
        protected override IShadow <RecyclerView> Create(AndroidContext context, AndroidViewGroup <RecyclerView> initial)
        {
            var shadow = (Shadow <RecyclerView>)base.Create(context, initial);

            // and now setup the data connection
            var rvac = new RecyclerViewAdapterConnector(context);
            var collectionComparer = initial.Attributes.GetAttributeOrDefault(Group.ComparerAttribute);

            var dataH = new BackingStoreUpdateHandler <AndroidContext, RecyclerView, IPrimitive>(rvac, Group.ChildrenAttribute, collectionComparer);

            this.SetChildrenAdapter(context, shadow, dataH);

            Transaction.Current.Add(() =>
            {
                // and set the adapter in the recycler view
                shadow.Item.SetAdapter(rvac.Adapter);
            });

            return(shadow);
        }
        protected override IShadow <TView> Create(XamFormsContext context, TElement initial)
        {
            // call down to the base to get the shadow
            var shadow = (Shadow <TView>)base.Create(context, initial);

            // create the connector to the list view
            var groupConnector = _connector(context, shadow);


            //// get the collection comparer, which the user may have overridden from the default one

            var comparer = _comparer ?? new MyerComparer <TGroupElement>();

            //// create the update handler which connects the comparer with the connector
            var dataUpdateHandler = new BackingStoreUpdateHandler <XamFormsContext, TView, TGroupElement>(groupConnector, _attribute, comparer);

            //// and finally set this as the adapter to be used
            this.SetChildrenAdapter(context, shadow, dataUpdateHandler);

            return(shadow);
        }