Skip to content

Commit

Permalink
Do some null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Oct 27, 2020
1 parent 3dcf795 commit d8d5ba0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Lottie.Forms/Lottie.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RootNamespace>Lottie.Forms</RootNamespace>
<Description>Render After Effects animations natively on Android, iOS, MacOS, TVOs and UWP</Description>
<PackageId>Com.Airbnb.Xamarin.Forms.Lottie</PackageId>
<Version>4.0.4</Version>
<Version>4.0.5</Version>
<UseWPF Condition=" '$(OS)' == 'Windows_NT' ">true</UseWPF>
</PropertyGroup>

Expand All @@ -31,14 +31,14 @@
<Compile Include="Platforms\Net\**\*.cs" />
<Compile Include="Platforms\Wpf\**\*.cs" />
<Compile Include="Platforms\Console\**\*.cs" />
<PackageReference Include="LottieSharp" Version="1.1.1" />
<PackageReference Include="LottieSharp" Version="1.1.2" />
<PackageReference Include="Xamarin.Forms.Platform.WPF" Version="4.5.0.657" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('netcoreapp')) And '$(OS)' == 'Windows_NT' ">
<Compile Include="Platforms\Net\**\*.cs" />
<Compile Include="Platforms\Console\**\*.cs" />
<PackageReference Include="LottieSharp" Version="1.1.1" />
<PackageReference Include="LottieSharp" Version="1.1.2" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('uap')) ">
Expand Down
12 changes: 9 additions & 3 deletions Lottie.Forms/Platforms/Ios/AnimationViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d8d5ba0

Please sign in to comment.