From 28b230bbb71b2fbd8dc4ea13a6a167d78f969299 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Tue, 25 Aug 2015 12:49:56 +0800 Subject: [PATCH] set images for ProfileSocialAccountImagesCell --- .../ProfileSocialAccountImagesCell.swift | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift b/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift index 4113d191..e6c6513b 100644 --- a/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift +++ b/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift @@ -18,52 +18,37 @@ class ProfileSocialAccountImagesCell: UICollectionViewCell { accessoryImageView.hidden = false switch work { + case .Dribbble(let dribbbleWork): + let shots = dribbbleWork.shots - if shots.count > 0 { - let shot = shots[0] + if let shot = shots[safe: 0] { imageView1.kf_setImageWithURL(NSURL(string: shot.images.teaser)!) - } else { - imageView1.image = nil } - if shots.count > 1 { - let shot = shots[1] + if let shot = shots[safe: 1] { imageView2.kf_setImageWithURL(NSURL(string: shot.images.teaser)!) - } else { - imageView2.image = nil } - if shots.count > 2 { - let shot = shots[2] + if let shot = shots[safe: 2] { imageView3.kf_setImageWithURL(NSURL(string: shot.images.teaser)!) - } else { - imageView3.image = nil } case .Instagram(let instagramWork): + let medias = instagramWork.medias - if medias.count > 0 { - let media = medias[0] + if let media = medias[safe: 0] { imageView1.kf_setImageWithURL(NSURL(string: media.images.thumbnail)!) - } else { - imageView1.image = nil } - if medias.count > 1 { - let media = medias[1] + if let media = medias[safe: 1] { imageView2.kf_setImageWithURL(NSURL(string: media.images.thumbnail)!) - } else { - imageView2.image = nil } - if medias.count > 2 { - let media = medias[2] + if let media = medias[safe: 2] { imageView3.kf_setImageWithURL(NSURL(string: media.images.thumbnail)!) - } else { - imageView3.image = nil } } } @@ -122,11 +107,11 @@ class ProfileSocialAccountImagesCell: UICollectionViewCell { } } - if !accountEnabled { - imageView1.image = nil - imageView2.image = nil - imageView3.image = nil + imageView1.image = nil + imageView2.image = nil + imageView3.image = nil + if !accountEnabled { accessoryImageView.hidden = true } else {