Example #1
0
        void CreateRecyclerView(Context context)
        {
            _recyclerView        = new ScrollRecyclerView(context);
            _recyclerView.Touch += _recyclerView_Touch;
            var scrollListener = new GridViewScrollListener(Element, _recyclerView);

            _recyclerView.AddOnScrollListener(scrollListener);

            _recyclerView.SetItemAnimator(null);
            _recyclerView.HorizontalScrollBarEnabled = false;
            _recyclerView.VerticalScrollBarEnabled   = true;

            _adapter = new GridViewAdapter(Element.ItemsSource, _recyclerView, Element, Resources.DisplayMetrics);
            _recyclerView.SetAdapter(_adapter);

            //Initialize the pull to refresh host.
            _pullToRefresh = new SwipeRefreshLayout(Android.App.Application.Context);

            //Add the recylcler to the refresh host.
            _pullToRefresh.AddView(_recyclerView);

            //Attach event handling for refresh.
            _pullToRefresh.Refresh += _pullToRefresh_Refresh;

            //Enable/Disable pull to refresh.
            _pullToRefresh.Enabled = Element.IsPullToRefreshEnabled;

            //Set the current refresh status.
            _pullToRefresh.Refreshing = Element.IsRefreshing;

            //Update the grid layout.
            UpdateGridLayout();
        }
Example #2
0
 public GridViewScrollListener(FormsGridView gridView, ScrollRecyclerView recyclerView)
 {
     _gridView     = gridView;
     _recyclerView = recyclerView;
 }