_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
;
}
};
I add native renderer in droid project as below. If i use xamarin forms listview, OnElementChanged is hit but using sflistview doesnt. is sflistview not inherited from xf listview?
I cant find any OnElementChanged event in sflistview also. please let me know how can this be achieved
using Android.Widget;
using FFImageLoading;
using myapp.Droid.Rendrers;
//using ScrollList.Droid.Adapters;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
//using AndroidListView = Android.Widget.ListView;
[assembly: ExportRenderer(typeof(Xamarin.Forms.ListView), typeof(NativeListViewRenderer))]
namespace myapp.Droid.Rendrers
{
public class NativeListViewRenderer : ListViewRenderer
{
public NativeListViewRenderer()
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
{
base.OnElementChanged(e);
if (Control == null)
return;
var listView = Control as global::Android.Widget.ListView;
listView.ScrollStateChanged += (object sender, AbsListView.ScrollStateChangedEventArgs scrollArgs) => {
switch (scrollArgs.ScrollState)
{
case ScrollState.Fling:
ImageService.Instance.SetPauseWork(true); // all image loading requests will be silently canceled
break;
case ScrollState.Idle:
ImageService.Instance.SetPauseWork(false); // loading requests are allowed again
// Here you should have your custom method that forces redrawing visible list items
//_myListView.ForcePdfThumbnailsRedraw();
break;
}
};
}
}
}