[Android] Add null checks to ActivityIndicator (#804)
authorSamantha Houts <samantha@teamredwall.com>
Wed, 8 Mar 2017 10:21:15 +0000 (02:21 -0800)
committerRui Marinho <me@ruimarinho.net>
Wed, 8 Mar 2017 10:22:37 +0000 (10:22 +0000)
Xamarin.Forms.Platform.Android/Renderers/ActivityIndicatorRenderer.cs

index f536b47..17b9cc8 100644 (file)
@@ -45,16 +45,22 @@ namespace Xamarin.Forms.Platform.Android
 
                void UpdateColor()
                {
+                       if (Element == null || Control == null)
+                               return;
+
                        Color color = Element.Color;
 
                        if (!color.IsDefault)
-                               Control.IndeterminateDrawable.SetColorFilter(color.ToAndroid(), PorterDuff.Mode.SrcIn);
+                               Control.IndeterminateDrawable?.SetColorFilter(color.ToAndroid(), PorterDuff.Mode.SrcIn);
                        else
-                               Control.IndeterminateDrawable.ClearColorFilter();
+                               Control.IndeterminateDrawable?.ClearColorFilter();
                }
 
                void UpdateVisibility()
                {
+                       if (Element == null || Control == null)
+                               return;
+
                        Control.Visibility = Element.IsRunning ? ViewStates.Visible : ViewStates.Invisible;
                }
        }