Пример #1
0
        void UpdateNativeSelection()
        {
            var mode = ItemsView.SelectionMode;

            ItemsViewAdapter.ClearNativeSelection();

            switch (mode)
            {
            case SelectionMode.None:
                return;

            case SelectionMode.Single:
                var selectedItem = ItemsView.SelectedItem;
                ItemsViewAdapter.MarkNativeSelection(selectedItem);
                return;

            case SelectionMode.Multiple:
                var selectedItems = ItemsView.SelectedItems;

                foreach (var item in selectedItems)
                {
                    ItemsViewAdapter.MarkNativeSelection(item);
                }
                return;
            }
        }
Пример #2
0
 void UnsubscribeCollectionItemsSourceChanged(ItemsViewAdapter <ItemsView, IItemsViewSource> oldItemViewAdapter)
 {
     if (oldItemViewAdapter?.ItemsSource is ObservableItemsSource oldObservableItemsSource)
     {
         oldObservableItemsSource.CollectionItemsSourceChanged -= CollectionItemsSourceChanged;
     }
 }
Пример #3
0
            int GetIndexFromTemplatedCell(global::Android.Views.View view)
            {
                int itemIndex = -1;

                if (view is ItemContentView templatedCell)
                {
                    var bContext = templatedCell?.Element?.BindingContext;
                    itemIndex = ItemsViewAdapter.GetPositionForItem(bContext);
                }

                return(itemIndex);
            }
Пример #4
0
        int GetCarouselViewCurrentIndex(int index)
        {
            var centeredView = this.GetCenteredView();

            if (centeredView is ItemContentView templatedCell)
            {
                var bContext = templatedCell?.Element?.BindingContext;
                index = ItemsViewAdapter.GetPositionForItem(bContext);
            }
            else
            {
                return(-1);
            }

            return(index);
        }
Пример #5
0
        protected override int DetermineTargetPosition(ScrollToRequestEventArgs args)
        {
            if (args.Mode == ScrollToMode.Element)
            {
                return(ItemsViewAdapter.GetPositionForItem(args.Item));
            }

            if (!Carousel.Loop)
            {
                return(args.Index);
            }

            if (_carouselViewLoopManager == null)
            {
                return(-1);
            }

            var carouselPosition = GetCarouselViewCurrentIndex(Carousel.Position);
            var getGoIndex       = _carouselViewLoopManager.GetGoToIndex(this, carouselPosition, args.Index);

            return(getGoIndex);
        }
Пример #6
0
 public CarouselViewOnScrollListener(ItemsView itemsView, ItemsViewAdapter <ItemsView, IItemsViewSource> itemsViewAdapter, CarouselViewLoopManager carouselViewLoopManager) : base(itemsView, itemsViewAdapter, true)
 {
     _carouselView            = itemsView as FormsCarouselView;
     _carouselViewLoopManager = carouselViewLoopManager;
 }