0
votes

I am working in xamarin.forms. I have one list page where I want to load set of images. Images are load from web service not from local device. Some images are big in size so I am using ffImageLoading plugin for image compression.

My problem is some image paths are not loaded. When I scroll down the page images may load. I would also like to mention that same image paths are properly open in browser so it is confirm that there is no firewall restriction.

I have made sample project where I have filled list object manually instead of web service. Some images are not loaded. I can not figured out whether it is a path issue or plugin issue.

<ListView x:Name="listView" HasUnevenRows="True" Grid.Row="1">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Grid BackgroundColor="#eee">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <ffimageloading:CachedImage Source="{Binding image}" LoadingPlaceholder="placeholder.jpg" RetryCount="5" DownsampleToViewSize="True" Grid.Column="0" HeightRequest="120" WidthRequest="120"/>
                                <!--<Image Source="{Binding image}" Grid.Column="0" HeightRequest="120" WidthRequest="120"/>-->
                                <StackLayout Grid.Column="1">
                                    <Label Text="{Binding title}" TextColor="#f35e20" />
                                    <Label Text="{Binding subtitle}" TextColor="#503026" />
                                </StackLayout>
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

public partial class ImageLoading : ContentPage
    {
        List<ImageList> lstImages;
        public ImageLoading()
        {
            InitializeComponent();
            lstImages = new List<ImageList>();
            var service = DependencyService.Get<ICompressImage>();
            lstImages.Add(new ImageList { image = "https://www.cpsc.gov/s3fs-public/Model%20Year%202017%20800PRO-RMK%20155SC%20Indy%20Red.jpg", title = "Image1", subtitle = "Image1 Description" });
            lstImages.Add(new ImageList { image = "https://www.cpsc.gov/s3fs-public/2017%20Honda%20Pioneer%20700%20side-by-side%20%28Red.jpg", title = "Image2", subtitle = "Image2 Description" });
            lstImages.Add(new ImageList { image = "https://www.fda.gov/ucm/groups/fdagov-public/documents/image/UCM557581.png", title = "Image3", subtitle = "Image3 Description" });
            lstImages.Add(new ImageList { image = "http://www.nafpaktia.com/data/wallpapers/2/727787.jpg", title = "Image4", subtitle = "Image4 Description" });
            lstImages.Add(new ImageList { image = "https://www.fda.gov/ucm/groups/fdagov-public/documents/image/UCM557126.jpg", title = "Image5", subtitle = "Image5 Description" });
            lstImages.Add(new ImageList { image = "https://www.fda.gov/ucm/groups/fdagov-public/documents/image/UCM557109.png", title = "Image6", subtitle = "Image6 Description" });
            lstImages.Add(new ImageList { image = "https://www.cpsc.gov/s3fs-public/PT-OffBoardCharger.jpeg", title = "Image7", subtitle = "Image7 Description" });
            lstImages.Add(new ImageList { image = "https://www.fda.gov/ucm/groups/fdagov-public/documents/image/UCM556528.png", title = "Image8", subtitle = "Image8 Description" });
            lstImages.Add(new ImageList { image = "https://www.fda.gov/ucm/groups/fdagov-public/documents/image/UCM556528.png", title = "Image9", subtitle = "Image9 Description" });
            lstImages.Add(new ImageList { image = "https://www.cpsc.gov/s3fs-public/PT-OffBoardCharger.jpeg", title = "Image10", subtitle = "Image10 Description" });
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();
            listView.ItemsSource = lstImages;
        }
    }
    public class ImageList
    {
        public byte[] byteImage { get; set; }
        public string image { get; set; }
        public string title { get; set; }
        public string subtitle { get; set; }
    }

As you can see in above code I have loaded some set of images in list View.

https://www.fda.gov/ucm/groups/fdagov-public/documents/image/UCM557581.png

all the images who start with "https://www.fda.gov" base URL are not loaded.

Some images are comes with the same path. So it may be possible ffimageloading behave differently. I don't know the exact reason.

if I use simple image control then is there any way to compress the image for android?

1
Please give me some update.RMR

1 Answers

0
votes

Your backend uses TLS1.2+

The settings for selecting the HttpClient and TLS implementations are found by right-clicking the project, then Properties > Android Options > Advanced in Visual Studio on Windows, or Options > Build > Android Build > General in Xamarin Studio.

iOS and macOS are more simplified when it comes to Handlers and TLS support. All iOS applications from Xamarin.iOS 10.8 on use Apple’s native TLS implementation, which provides full TLS 1.2+ support for all applications. There are still several options that developers may choose when it comes to the HttpClient Implementation, which can be found by right-clicking the project and selecting Properties > iOS Build > Advanced in Visual Studio or Options > Build > iOS Build in Xamarin Studio.