summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs37
1 files changed, 15 insertions, 22 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
index a50c1814..fe91d588 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
@@ -68,10 +68,6 @@ namespace Xamarin.Forms.Platform.Android
if (Device.IsInvokeRequired)
throw new InvalidOperationException("Image Bitmap must not be updated from background thread");
- Bitmap bitmap = null;
-
- ImageSource source = Element.Source;
-
if (previous != null && Equals(previous.Source, Element.Source))
return;
@@ -82,27 +78,22 @@ namespace Xamarin.Forms.Platform.Android
Control.SetImageResource(global::Android.Resource.Color.Transparent);
- if (source != null)
+ ImageSource source = Element.Source;
+ Bitmap bitmap = null;
+ IImageSourceHandler handler;
+
+ if (source != null && (handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
{
- IImageSourceHandler handler;
- if ((handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
+ try
{
- try
- {
- bitmap = await handler.LoadImageAsync(source, Context);
- }
- catch (TaskCanceledException)
- {
- }
- catch (IOException ex)
- {
- Log.Warning("Xamarin.Forms.Platform.Android.ImageRenderer", "Error updating bitmap: {0}", ex);
- }
+ bitmap = await handler.LoadImageAsync(source, Context);
}
-
- if (bitmap == null && source is FileImageSource)
+ catch (TaskCanceledException)
{
- Control.SetImageResource(ResourceManager.GetDrawableByName(((FileImageSource)Element.Source).File));
+ }
+ catch (IOException ex)
+ {
+ Log.Warning("Xamarin.Forms.Platform.Android.ImageRenderer", "Error updating bitmap: {0}", ex);
}
}
@@ -114,7 +105,9 @@ namespace Xamarin.Forms.Platform.Android
if (!_isDisposed)
{
- if (bitmap != null)
+ if (bitmap == null && source is FileImageSource)
+ Control.SetImageResource(ResourceManager.GetDrawableByName(((FileImageSource)source).File));
+ else
Control.SetImageBitmap(bitmap);
bitmap?.Dispose();