Exemple #1
0
        void EmptyCollectionViewReloadWorkaround()
        {
            var enumerator = _itemsView.ItemsSource.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                // The source we're updating to is empty, so we can just update as normal; it won't crash
                UpdateItemsSourceAndReload();
            }
            else
            {
                // Grab the first item from the new ItemsSource and create a usable source for the UICollectionView
                // from that
                var firstItem = new List <object> {
                    enumerator.Current
                };
                _itemsSource = ItemsSourceFactory.Create(firstItem, CollectionView);

                // Insert that item into the UICollectionView
                // TODO ezhart When we implement grouping, this will need to be the index of the first actual item
                // Which might not be zero,zero if we have empty groups
                var indexesToInsert = new NSIndexPath[1] {
                    NSIndexPath.Create(0, 0)
                };

                UIView.PerformWithoutAnimation(() =>
                {
                    CollectionView.InsertItems(indexesToInsert);
                });

                // Okay, from now on we can just call ReloadData and things will work fine
                _safeForReload = true;
                UpdateItemsSource();
            }
        }
Exemple #2
0
        public ItemsViewController(ItemsView itemsView, ItemsViewLayout layout) : base(layout)
        {
            _itemsView   = itemsView;
            _itemsSource = ItemsSourceFactory.Create(_itemsView.ItemsSource, CollectionView);

            UpdateLayout(layout);
        }
        protected override IItemsViewSource CreateItemsViewSource()
        {
            var itemsSource = ItemsSourceFactory.CreateForCarouselView(Carousel.ItemsSource, this, Carousel.Loop);

            _carouselViewLoopManager?.SetItemsSource(itemsSource);
            SubscribeCollectionItemsSourceChanged(itemsSource);
            return(itemsSource);
        }
        public CollectionViewController(ItemsView itemsView, ItemsViewLayout layout) : base(layout)
        {
            _itemsView   = itemsView;
            _itemsSource = ItemsSourceFactory.Create(_itemsView.ItemsSource, CollectionView);
            _layout      = layout;

            _layout.GetPrototype = GetPrototype;
            _layout.UniformSize  = false;            // todo hartez Link this to ItemsView.ItemSizingStrategy hint
        }
Exemple #5
0
        protected override IItemsViewSource CreateItemsViewSource()
        {
            // Use the BindableProperty here (instead of _isGroupingEnabled) because the cached value might not be set yet
            if (ItemsView.IsGrouped)
            {
                return(ItemsSourceFactory.CreateGrouped(ItemsView.ItemsSource, this));
            }

            return(base.CreateItemsViewSource());
        }
Exemple #6
0
        public ItemsViewController(ItemsView itemsView, ItemsViewLayout layout) : base(layout)
        {
            _itemsView   = itemsView;
            _itemsSource = ItemsSourceFactory.Create(_itemsView.ItemsSource, CollectionView);

            // If we already have data, the UICollectionView will have items and we'll be safe to call
            // ReloadData if the ItemsSource changes in the future (see UpdateItemsSource for more).
            _safeForReload = _itemsSource?.Count > 0;

            UpdateLayout(layout);
        }
Exemple #7
0
 protected virtual IItemsViewSource CreateItemsViewSource()
 {
     return(ItemsSourceFactory.Create(ItemsView.ItemsSource, this));
 }
 protected virtual IItemsViewSource CreateItemsViewSource()
 {
     return(ItemsSourceFactory.Create(ItemsView.ItemsSource, CollectionView));
 }
Exemple #9
0
 void UpdateItemsSourceAndReload()
 {
     _itemsSource = ItemsSourceFactory.Create(_itemsView.ItemsSource, CollectionView);
     CollectionView.ReloadData();
     CollectionView.CollectionViewLayout.InvalidateLayout();
 }