From d8d5ba02878b4978ce589d60592fb1be3bc4cb10 Mon Sep 17 00:00:00 2001 From: Martijn van Dijk Date: Tue, 27 Oct 2020 10:33:50 +0100 Subject: [PATCH] Do some null checks --- Lottie.Forms/Lottie.Forms.csproj | 6 +++--- .../Platforms/Ios/AnimationViewExtensions.cs | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Lottie.Forms/Lottie.Forms.csproj b/Lottie.Forms/Lottie.Forms.csproj index d1b9c87..c82d89c 100644 --- a/Lottie.Forms/Lottie.Forms.csproj +++ b/Lottie.Forms/Lottie.Forms.csproj @@ -9,7 +9,7 @@ Lottie.Forms Render After Effects animations natively on Android, iOS, MacOS, TVOs and UWP Com.Airbnb.Xamarin.Forms.Lottie - 4.0.4 + 4.0.5 true @@ -31,14 +31,14 @@ - + - + diff --git a/Lottie.Forms/Platforms/Ios/AnimationViewExtensions.cs b/Lottie.Forms/Platforms/Ios/AnimationViewExtensions.cs index 069398f..287457b 100644 --- a/Lottie.Forms/Platforms/Ios/AnimationViewExtensions.cs +++ b/Lottie.Forms/Platforms/Ios/AnimationViewExtensions.cs @@ -21,7 +21,11 @@ public static LOTComposition GetAnimation(this AnimationView animationView) if (animation is string bundleAnimation) { if (!string.IsNullOrEmpty(animationView.ImageAssetsFolder)) - composition = LOTComposition.AnimationNamed(bundleAnimation, NSBundle.FromPath(animationView.ImageAssetsFolder)); + { + var bundle = NSBundle.FromPath(animationView.ImageAssetsFolder); + if (bundle != null) + composition = LOTComposition.AnimationNamed(bundleAnimation, bundle); + } else composition = LOTComposition.AnimationNamed(bundleAnimation); } @@ -35,7 +39,8 @@ public static LOTComposition GetAnimation(this AnimationView animationView) { NSData objectData = NSData.FromString(jsonAnimation); NSDictionary jsonData = (NSDictionary)NSJsonSerialization.Deserialize(objectData, NSJsonReadingOptions.MutableContainers, out _); - composition = LOTComposition.AnimationFromJSON(jsonData); + if (jsonData != null) + composition = LOTComposition.AnimationFromJSON(jsonData); } else if (animation is NSDictionary dictAnimation) composition = LOTComposition.AnimationFromJSON(dictAnimation); @@ -75,7 +80,8 @@ public static LOTComposition GetAnimation(this AnimationView animationView, obje string json = reader.ReadToEnd(); NSData objectData = NSData.FromString(json); NSDictionary jsonData = (NSDictionary)NSJsonSerialization.Deserialize(objectData, NSJsonReadingOptions.MutableContainers, out _); - composition = LOTComposition.AnimationFromJSON(jsonData); + if (jsonData != null) + composition = LOTComposition.AnimationFromJSON(jsonData); } break; case null: