public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { _pos = ((LinearLayoutManager)recyclerView.GetLayoutManager()).FindFirstVisibleItemPosition(); var lastPos = ((LinearLayoutManager)recyclerView.GetLayoutManager()).FindLastVisibleItemPosition(); ScrolledToPosition?.Invoke(lastPos); // TODO: temporary solution if (lastPos > _prevPos && lastPos != _prevPos) { if (lastPos >= _prevPos + packSize / 2) { ScrolledToBottom?.Invoke(); _prevPos = _prevPos + packSize; } } /*if (lastPos > _prevPos && lastPos != _prevPos) * { * if (lastPos == recyclerView.GetAdapter().ItemCount - 1) * { * if (lastPos < recyclerView.GetAdapter().ItemCount) * { * ScrolledToBottom?.Invoke(); * _prevPos = lastPos; * } * } * }*/ }
private void OnScrollChanged(object sender, ScrollChangedEventArgs e) { double offset = PackagesListView.ScrollViewer.VerticalOffset; if (offset >= PackagesListView.ScrollViewer.ScrollableHeight) { ScrolledToBottom?.Invoke(this, EventArgs.Empty); PackagesListView.ScrollViewer.ScrollToVerticalOffset(offset); } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { _pos = ((LinearLayoutManager)recyclerView.GetLayoutManager()).FindFirstVisibleItemPosition(); var lastPos = ((LinearLayoutManager)recyclerView.GetLayoutManager()).FindLastVisibleItemPosition(); if (lastPos > _prevPos && lastPos != _prevPos) { if (lastPos == recyclerView.GetAdapter().ItemCount - 1) { if (lastPos < recyclerView.GetAdapter().ItemCount) { ScrolledToBottom?.Invoke(); _prevPos = lastPos; } } } }
private void Scroll() { var point = GetCursorPoint(); if (point.Y < btnScrollUp.Height || point.Y > btnScrollDown.Y) { return; } if (point.Y <= buttonMinY) { ViewTop = 0; RefreshButtonY(); Scrolled?.Invoke(this, EventArgs.Empty); return; } if (point.Y >= buttonMaxY) { ViewTop = Length - DisplayedPixelCount; RefreshButtonY(); Scrolled?.Invoke(this, EventArgs.Empty); ScrolledToBottom?.Invoke(this, EventArgs.Empty); return; } double difference = buttonMaxY - buttonMinY; double location = point.Y - buttonMinY; int nonDisplayedLines = Length - DisplayedPixelCount; ViewTop = (int)(location / difference * nonDisplayedLines); RefreshButtonY(); Scrolled?.Invoke(this, EventArgs.Empty); }