Skip to content

Instantly share code, notes, and snippets.

@mrlacey
Last active December 15, 2015 05:29
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 mrlacey/5209344 to your computer and use it in GitHub Desktop.
Save mrlacey/5209344 to your computer and use it in GitHub Desktop.
On low spec WP8 devices we had an issue where the UI option to create a secondary tile wasn't always being enabled properly. After identifying the most likely cause as the `CanPin()` method I had to refactor it to make it debuggable and in doing so made the binding/timing issue go away (solved it).
internal bool CanPin()
{
if (this.IsPinned())
{
Debug.WriteLine("Cannot pin as already pinned");
return false;
}
if (this.UnderlyingModel == null)
{
Debug.WriteLine("Cannot pin as don't have the underlying model (needed when generating the image and deep link path)");
return false;
}
if (this.IsRunningInKidsCorner())
{
Debug.WriteLine("Cannot pin as running in kids corner");
return false;
}
if (this.UnderlyingModel.IsSpecial)
{
Debug.WriteLine("CAN pin as is special (will use special artwork)");
return true;
}
if (string.IsNullOrWhiteSpace(this.UnderlyingModel.ArtUrl))
{
Debug.WriteLine("CAN pin as has no artwork (default/fallback will be used)");
return true;
}
if (this.imageCacher.IsCached(this.UnderlyingModel.ArtUrl))
{
Debug.WriteLine("CAN pin as artwork has been cached");
return true;
}
Debug.WriteLine("Cannot pin as all tests failed");
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment