summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authorAdrian Knight <adrianknight89@outlook.com>2016-11-26 17:56:10 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-02-22 11:30:19 (GMT)
commit9acf63de8a2ddf5c3d0f6385671d215660ec3c18 (patch)
tree2533ca6c0b95e92d1580560dee017b432ae6c85c /Xamarin.Forms.Platform.Android
parent217a59e5873b1a4850719c26b11b853270df70ce (diff)
downloadxamarin-forms-9acf63de8a2ddf5c3d0f6385671d215660ec3c18.zip
xamarin-forms-9acf63de8a2ddf5c3d0f6385671d215660ec3c18.tar.gz
xamarin-forms-9acf63de8a2ddf5c3d0f6385671d215660ec3c18.tar.bz2
image supports vectors
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs36
1 files changed, 24 insertions, 12 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
index e3c6829..a50c181 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
@@ -71,7 +71,6 @@ namespace Xamarin.Forms.Platform.Android
Bitmap bitmap = null;
ImageSource source = Element.Source;
- IImageSourceHandler handler;
if (previous != null && Equals(previous.Source, Element.Source))
return;
@@ -79,32 +78,45 @@ namespace Xamarin.Forms.Platform.Android
((IImageController)Element).SetIsLoading(true);
var formsImageView = Control as FormsImageView;
- if (formsImageView != null)
- formsImageView.SkipInvalidate();
+ formsImageView?.SkipInvalidate();
Control.SetImageResource(global::Android.Resource.Color.Transparent);
- if (source != null && (handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
+ if (source != null)
{
- try
+ IImageSourceHandler handler;
+ if ((handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
{
- bitmap = await handler.LoadImageAsync(source, Context);
+ try
+ {
+ bitmap = await handler.LoadImageAsync(source, Context);
+ }
+ catch (TaskCanceledException)
+ {
+ }
+ catch (IOException ex)
+ {
+ Log.Warning("Xamarin.Forms.Platform.Android.ImageRenderer", "Error updating bitmap: {0}", ex);
+ }
}
- catch (TaskCanceledException)
- {
- }
- catch (IOException ex)
+
+ if (bitmap == null && source is FileImageSource)
{
- Log.Warning("Xamarin.Forms.Platform.Android.ImageRenderer", "Error updating bitmap: {0}", ex);
+ Control.SetImageResource(ResourceManager.GetDrawableByName(((FileImageSource)Element.Source).File));
}
}
if (Element == null || !Equals(Element.Source, source))
+ {
+ bitmap?.Dispose();
return;
+ }
if (!_isDisposed)
{
- Control.SetImageBitmap(bitmap);
+ if (bitmap != null)
+ Control.SetImageBitmap(bitmap);
+
bitmap?.Dispose();
((IImageController)Element).SetIsLoading(false);