diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2017-04-25 12:16:25 -0600 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2017-04-25 19:16:25 +0100 |
commit | cdc405512844671bc3b2c8bd28f583036e5530a2 (patch) | |
tree | 881d68b4a26eecbbc77e76b86b3f322cd41b3e3d /Xamarin.Forms.Platform.Android/Renderers/ImageLoaderSourceHandler.cs | |
parent | 9631ec2d8bbac8b837955af238f322c1023af097 (diff) | |
download | xamarin-forms-cdc405512844671bc3b2c8bd28f583036e5530a2.tar.gz xamarin-forms-cdc405512844671bc3b2c8bd28f583036e5530a2.tar.bz2 xamarin-forms-cdc405512844671bc3b2c8bd28f583036e5530a2.zip |
Better error handling for image loading errors on iOS/Android (#849)
* First run at removing async void image update methods
Consistent error logging and IsLoading on Android,iOS,UWP
Move error logging into image handlers for better messages
Add demo of custom ImageRenderer error handling
Update docs
Make the test smaller so the results don't get pushed offscreen
Fix namespace error
* Update error handling for fast image renderer
* Update 37625 test to use image we control
* Add java disposed check to avoid ObjectDisposedException in async operations
* Add disposed checks to legacy renderer; null check element before SetIsLoading
* Check disposed on GetDesiredSize for fast renderer
Use local disposed member where possible for disposed check
* Check for disposal after async handlers in iOS
* Add disposal checks after async methods in Windows
* Reset linker settings on project; reduce redundant casts in ImageViewExtensions
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/ImageLoaderSourceHandler.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Android/Renderers/ImageLoaderSourceHandler.cs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ImageLoaderSourceHandler.cs b/Xamarin.Forms.Platform.Android/Renderers/ImageLoaderSourceHandler.cs index 8d0ae3d9..b22ca485 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/ImageLoaderSourceHandler.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/ImageLoaderSourceHandler.cs @@ -3,6 +3,7 @@ using System.Threading; using System.Threading.Tasks; using Android.Content; using Android.Graphics; +using Xamarin.Forms.Internals; namespace Xamarin.Forms.Platform.Android { @@ -11,12 +12,19 @@ namespace Xamarin.Forms.Platform.Android public async Task<Bitmap> LoadImageAsync(ImageSource imagesource, Context context, CancellationToken cancelationToken = default(CancellationToken)) { var imageLoader = imagesource as UriImageSource; - if (imageLoader != null && imageLoader.Uri != null) + Bitmap bitmap = null; + if (imageLoader?.Uri != null) { using (Stream imageStream = await imageLoader.GetStreamAsync(cancelationToken).ConfigureAwait(false)) - return await BitmapFactory.DecodeStreamAsync(imageStream).ConfigureAwait(false); + bitmap = await BitmapFactory.DecodeStreamAsync(imageStream).ConfigureAwait(false); } - return null; + + if (bitmap == null) + { + Log.Warning(nameof(ImageLoaderSourceHandler), "Could not retrieve image or image data was invalid: {0}", imageLoader); + } + + return bitmap; } } }
\ No newline at end of file |