Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
[IceCreamBuilder] Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
olegoid committed Jul 22, 2016
1 parent f00d864 commit 0e94bfc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
10 changes: 1 addition & 9 deletions ios10/IceCreamBuilder/MessagesExtension/Model/IceCream.cs
Expand Up @@ -149,15 +149,7 @@ public UIImage RenderParts ()
{
// Determine which parts to draw.
IceCreamPart[] allParts = { Topping, Scoops, Base };
var partImages = new List<UIImage> ();

foreach (var part in allParts) {
if (part != null && part.Image != null)
partImages.Add (part.StickerImage);
}

if (partImages == null)
return null;
var partImages = allParts.Where (p => p != null && p.Image != null).Select (p => p.StickerImage);

// Calculate the size of the composited ice cream parts image.
var outputImageSize = CGSize.Empty;
Expand Down
9 changes: 3 additions & 6 deletions ios10/IceCreamBuilder/MessagesExtension/Model/IceCreamPart.cs
Expand Up @@ -19,14 +19,11 @@ public class IceCreamPart : IQueryItemRepresentable {
}
}

UIImage stickerImage;
public UIImage StickerImage {
get {
var image = new UIImage ($"{RawValue}_sticker");

if (image == null)
throw new Exception ($"Unable to find sticker image");

return image;
stickerImage = stickerImage ?? new UIImage ($"{RawValue}_sticker");
return stickerImage;
}
}

Expand Down
Expand Up @@ -53,7 +53,7 @@ public void GetSticker (IceCream iceCream, Action<MSSticker> completion)
throw new Exception ("Stickers can only be created for completed ice creams");

// Determine the URL for the sticker.
var fileName = string.Format ($"{iceCream.Base.RawValue}{iceCream.Scoops.RawValue}{iceCream.Topping.RawValue}.png");
var fileName = $"{iceCream.Base.RawValue}{iceCream.Scoops.RawValue}{iceCream.Topping.RawValue}.png";
var url = Path.Combine (cacheURL, fileName);

// Check if the sticker already exists at the URL
Expand Down

0 comments on commit 0e94bfc

Please sign in to comment.