Пример #1
0
 public EndlessRecyclerViewScrollListener(LinearLayoutManager layoutManager,
                                          FastGridView fastGridView, ScrollRecyclerView recyclerView)
 {
     _layoutManager = layoutManager;
     _fastGridView  = fastGridView;
     _recyclerView  = recyclerView;
     _density       = recyclerView.Resources.DisplayMetrics.Density;
 }
Пример #2
0
        void CreateRecyclerView()
        {
            _recyclerView = new ScrollRecyclerView(Application.Context);
            _recyclerView.SetClipToPadding(false);
            _adapter = new FastGridAdapter(Element.ItemsSource, _recyclerView, Element, Resources.DisplayMetrics,
                                           this);
            LinearLayoutManager layoutManager;

            if (Element.IsHorizontal)
            {
                layoutManager =
                    new LinearLayoutManager(Context, OrientationHelper.Horizontal,
                                            false); /*{AutoMeasureEnabled = true}*/
                _recyclerView.HasFixedSize = true;
            }
            else
            {
                _gridLayoutManager = new SmoothGridLayoutManager(Context, _columns > 0 ? _columns : 1,
                                                                 OrientationHelper.Vertical, false)
                {
                    RecyclerView = _recyclerView
                };
                _recyclerView.HasFixedSize = true;
                layoutManager = _gridLayoutManager;
                CalculateLayoutRects();
            }

            _recyclerView.SetLayoutManager(layoutManager);

            var scrollListener = new EndlessRecyclerViewScrollListener(layoutManager, Element, _recyclerView)
            {
                EnableLoadMore = Element.LoadMoreCommand != null
            };

            scrollListener.LoadMore += LoadMore;
            _recyclerView.AddOnScrollListener(scrollListener);
            _scrollListener = scrollListener;

            _recyclerView.HorizontalScrollBarEnabled = Element.IsHorizontal;
            _recyclerView.VerticalScrollBarEnabled   = !Element.IsHorizontal;

            _recyclerView.SetAdapter(_adapter);
        }