Example #1
0
 internal DecoratedView(
     PhysicalLayoutManager layout,
     AndroidView view)
 {
     _layout = layout;
     _view   = view;
 }
Example #2
0
        void Initialize()
        {
            // cache hit? Check if the view page is already created
            RecyclerView recyclerView = Control;

            if (recyclerView != null)
            {
                return;
            }

            // cache miss
            recyclerView = new RecyclerView(Context);
            SetNativeControl(recyclerView);

            // layoutManager
            recyclerView.SetLayoutManager(
                layout: _physicalLayout = new PhysicalLayoutManager(
                    context: Context,
                    virtualLayout: new VirtualLayoutManager()
                    )
                );

            // swiping
            recyclerView.AddOnScrollListener(
                new OnScrollListener(
                    onDragStart: () => { },
                    onDragEnd: () => {
                var velocity = _physicalLayout.Velocity;

                var target = velocity.X > 0 ?
                             _physicalLayout.VisiblePositions().Max() :
                             _physicalLayout.VisiblePositions().Min();
                _physicalLayout.ScrollToPosition(target);
            },
                    onScrollSettled: () => {
                var visiblePositions = _physicalLayout.VisiblePositions().ToArray();
                _position            = visiblePositions.Single();

                OnPositionChanged();
                OnItemChanged();
            },
                    visibleViewCount: () => _physicalLayout.VisiblePositions().Count()
                    )
                );

            // adapter
            InitializeAdapter();
        }