Esempio n. 1
0
            public RecycleViewAdapter(HorizontalListView element, RecyclerView parentView, Context context)
            {
                _element        = element;
                _weakParentView = new WeakReference <RecyclerView>(parentView);
                _context        = context;

                _elementItemsSource = element.ItemsSource;

                _dataSource = _elementItemsSource?.Cast <object>().ToList() ?? new List <object>();

                _formsViews = new List <WeakReference <ViewCell> >();

                if (!(_element.ItemTemplate is DataTemplateSelector))
                {
                    // Cache only support single DataTemplate
                    _viewHolderQueue = new ViewHolderQueue(element.ViewCacheSize, () => CreateViewHolder());
                    _viewHolderQueue.Build();
                }

                _notifyCollectionChanged = _elementItemsSource as INotifyCollectionChanged;
                if (_notifyCollectionChanged != null)
                {
                    _notifyCollectionChanged.CollectionChanged += OnCollectionChanged;
                }
            }
            public RecycleViewAdapter(HorizontalListView element, Context context)
            {
                _element = element;
                _context = context;

                _elementItemsSource = element.ItemsSource;

                _dataSource = _elementItemsSource?.Cast <object>().ToList() ?? new List <object>();

                _formsViews      = new List <WeakReference <ViewCell> >();
                _viewHolderQueue = new ViewHolderQueue(element.ViewCacheSize, CreateViewHolder);
                _viewHolderQueue.Build();

                _notifyCollectionChanged = _elementItemsSource as INotifyCollectionChanged;
                if (_notifyCollectionChanged != null)
                {
                    _notifyCollectionChanged.CollectionChanged += OnCollectionChanged;
                }
            }