Skip to content

Instantly share code, notes, and snippets.

@brendanzagaeski
Created March 5, 2014 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brendanzagaeski/9376167 to your computer and use it in GitHub Desktop.
Save brendanzagaeski/9376167 to your computer and use it in GitHub Desktop.
Patch to prevent NullReferenceException in AndHUD
diff --git a/AndHUD/AndHUD.cs b/AndHUD/AndHUD.cs
index 2022fcb..6d57870 100644
--- a/AndHUD/AndHUD.cs
+++ b/AndHUD/AndHUD.cs
@@ -222,10 +222,12 @@ namespace AndroidHUD
}
else
{
- Application.SynchronizationContext.Post(state => {
- progressWheel.SetProgress (progress);
- statusText.Text = status ?? "";
- }, null);
+ if (progressWheel != null) {
+ Application.SynchronizationContext.Post(state => {
+ progressWheel.SetProgress (progress);
+ statusText.Text = status ?? "";
+ }, null);
+ }
}
}
}
@@ -283,10 +285,12 @@ namespace AndroidHUD
}
else
{
- Application.SynchronizationContext.Post(state => {
- imageView.SetImageDrawable(image);
- statusText.Text = status ?? "";
- }, null);
+ if (imageView != null) {
+ Application.SynchronizationContext.Post(state => {
+ imageView.SetImageDrawable(image);
+ statusText.Text = status ?? "";
+ }, null);
+ }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment