This is a migrated thread and some comments may be shown as answers.

Expose ScrollState event to list

1 Answer 150 Views
ListView - Xamarin.Android
This is a migrated thread and some comments may be shown as answers.
Elad
Top achievements
Rank 1
Elad asked on 11 Mar 2016, 06:20 PM

Hi,

in order to improve performance, I want to pause downloading of images when user is in fling scrolling mode.

_myListView.ScrollStateChanged += (object sender, ScrollStateChangedEventArgs scrollArgs) =>
{
  switch (scrollArgs.ScrollState)
  {
    case ScrollState.Fling:
      ImageService.SetPauseWork(true); // all image loading requests will be silently canceled
      break;
    case ScrollState.Idle:
      ImageService.SetPauseWork(false); // loading requests are allowed again
 
      // Here you should have your custom method that forces redrawing visible list items
      _myListView.ForcePdfThumbnailsRedraw();
      break;
  }
};

source: https://github.com/molinch/FFImageLoading/wiki/Advanced-Usage

ScrollStateChanged is came from Android.Widget.AbsListView, but RadListView isn't derived from this class.

any option to add this event ?

Thank you

1 Answer, 1 is accepted

Sort by
0
Accepted
Todor
Telerik team
answered on 12 Mar 2016, 03:43 PM
Hello Elad,

Thank you for your question.

RadListView for Xamarin.Android extends the Android's RecyclerView and this is why it doesn't have the mentioned event of AbsListView. However RecyclerView provides an alternative that you can use for your scenario: the method AddOnScollListener. Here's how you can create such listener:

public class MyScrollListener : RecyclerView.OnScrollListener {
    public override void OnScrollStateChanged (RecyclerView recyclerView, int newState)
    {
        base.OnScrollStateChanged (recyclerView, newState);
 
        switch (newState) {
        case RecyclerView.ScrollStateIdle:
            // Scrolling stopped.
                break;
        case RecyclerView.ScrollStateSettling:
            // Scrolling is about to stop.
                break;
        case RecyclerView.ScrollStateDragging:
            // Scrolling starts.
                break;
        }
    }
     
}

Then you can add one to your list view instance:

this.listView.AddOnScrollListener (new MyScrollListener ());

I hope this information helps.

Regards,
Todor
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView - Xamarin.Android
Asked by
Elad
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or