(Android) LoadingImage not replaced when (image)Stream received from server on CachedImage
See original GitHub issueHi…,
I’ve a bug to be reported, in a specific situation. We build Xamarin.Forms Apps and we use MAM for this application and it is not allowed to use the default HttpClient by GOOD(GD).
GD have its own GDHttpClient we have to use to retrieve images and other date from within our own domain. We have created our own GDFFCachedImage based on the FFImageLoading.Forms.CachedImage like this:
public class GDFFCachedImage : FFImageLoading.Forms.CachedImage
{
public static readonly BindableProperty GDImageSourceProperty =
BindableProperty.Create<GDFFCachedImage, string>(p => p.GDImageSource, "");
//Gets or sets the source of the GD Image
public string GDImageSource
{
get { return (string)GetValue(GDImageSourceProperty); }
set { SetValue(GDImageSourceProperty, value); }
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
// When bound, stream in the Image via GenericHttpHandler
Source = new StreamImageSource()
{
Stream = async (token) => await Task.Run(() => ServiceLocator.Instance.Resolve<IGenericHttpHandler>().GetStreamAsync(this.GDImageSource))
};
}
}
In our Xaml View we bind the GDImageSource to our internal server URL. The OnBindingContextChanged event makes sure the GDHttpClient is used on Platform specific deployments.
The used ViewCell is created from class like this:
public class PersonViewCell : ViewCell
{
public PersonViewCell()
{
var image = new GDFFCachedImage()
{
WidthRequest = 40,
HeightRequest = 40,
DownsampleHeight = 40,
DownsampleUseDipUnits = true,
TransparencyEnabled = false,
Aspect = Aspect.AspectFill,
CacheDuration = TimeSpan.FromDays(1),
LoadingPlaceholder = "AvatarLoading.png",
Transformations = new List<ITransformation>() {
new CircleTransformation(5,"#000000"),
}
};
image.SetBinding<Person>(GDFFCachedImage.GDImageSourceProperty, v => v.AvatarURL);
var fullName = new Label()
{
LineBreakMode = LineBreakMode.CharacterWrap,
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.Start,
FontSize = 17
};
fullName.SetBinding<Person>(Label.TextProperty, v => v.FullName);
var organization = new Label()
{
LineBreakMode = LineBreakMode.CharacterWrap,
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.Start,
FontSize = 15
};
organization.SetBinding<Person>(Label.TextProperty, v => v.Organization);
var root = new AbsoluteLayout()
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Padding = 5,
};
root.Children.Add(image, new Rectangle(0f, 0f, 40f, 40f));
root.Children.Add(fullName, new Rectangle(45f, 0f, 200f, 20f));
root.Children.Add(organization, new Rectangle(45f, 20f, 200f, 20f));
View = root;
}
}
This implementation works flawless on iOS!!! But on Android the Loading image is not being refreshed/replaced when the image stream is received from our server. When not using GD and the default HttpClient. It does work…
Additional information: FFImageLoading : 2.1.7 Xamarin.Forms : 2.2.031 Build target Android : API 23 Min. Android Version : API 15 (upgrade to API 21 also does solve this issue)
Any help please… 😃
Jeffrey Klink Logeman
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
The newest alpha has some new configuration options, you can easily provide your own
IDownloadCache
implementation to replace whole download logic. It’s a very simpleinterface
with two methods to implement.@daniel-luberda Not yet… had no time to look into it because of Go-Live… Looking into it ASAP next sprint 😉