I wanted to add CachedImage using FFImageLoading with my ListView control. I have added the three packages and the control on the XAML but the listview is still display slow is there anything else I need to do for FFImageLoading Cached to work with a ListView control? i Tried to follow this sample but i am not sure if it’s working
is there a way to know for sure that the images are being cached?
MainActivity.cs
CachedImageRenderer.Init(true);
AppDelegate.cs
CachedImageRenderer.Init();
XAML
<converters:FastTemplateCell AutomationId="DownloadListItemTemplateCell">
<converters:FastTemplateCell.View>
<Grid Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="15"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15" />
</Grid.ColumnDefinitions>
<forms:CachedImage Grid.Row="0" Grid.Column="0" IsVisible="{Binding IsSelected, Converter={StaticResource InvertedBooleanConverter}}" AutomationId="GuidelineDownloadIcon" Source="arrow_start.png"/>
<forms:CachedImage Grid.Row="0" Grid.Column="0" IsVisible="{Binding IsGuidelineDownloaded}" AutomationId="GuidelineDownloadSuccessIcon" Source="circle_done.png"/>
<forms:CachedImage Grid.Row="0" Grid.Column="0" IsVisible="{Binding IsGuidelineDownloadFailed}" AutomationId="GuidelineDownloadFailIcon" Source="failed.png" />
</Grid>
<Label LineBreakMode="WordWrap" Grid.Column="1" Text="{Binding GuidelineChildName}" AutomationId="DownloadGuidelineType" TextColor="#337ab7">
<Label.FontSize>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="iOS" Value="16" />
<On Platform="Android" Value="15" />
</OnPlatform>
</Label.FontSize>
<Label.VerticalOptions>
<OnPlatform x:TypeArguments="LayoutOptions">
<On Platform="iOS" Value="CenterAndExpand" />
<On Platform="Android" Value="Start" />
</OnPlatform>
</Label.VerticalOptions>
</Label>
</Grid>
</Grid>
</converters:FastTemplateCell.View>
</converters:FastTemplateCell>
.cs
public class FastTemplateCell : ListViewTemplateCell
{
private FFImageLoading.Forms.CachedImage imageDownloadIcon;
private FFImageLoading.Forms.CachedImage imageDownloadSuccessIcon;
private FFImageLoading.Forms.CachedImage imageDownloadFailIcon;
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
this.EnsureCachedElements();
if (dataimageDownloadIcon != null)
{
this.imageDownloadIcon.Source = "arrow_start.png";
}
if (dataimageDownloadSuccessIcon != null)
{
this.imageDownloadSuccessIcon.Source = "circle_done.png";
}
if (dataimageDownloadFailIcon != null)
{
this.imageDownloadFailIcon.Source = "failed.png";
}
}
private void EnsureCachedElements()
{
if (this.imageDownloadIcon == null)
{
this.imageDownloadIcon = this.View.FindByName<CachedImage>("imageDownloadIcon");
}
if (this.imageDownloadSuccessIcon == null)
{
this.imageDownloadSuccessIcon = this.View.FindByName<CachedImage>("imageDownloadSuccessIcon");
}
if (this.imageDownloadFailIcon == null)
{
this.imageDownloadFailIcon = this.View.FindByName<CachedImage>("imageDownloadFailIcon");
}
}
}