From 8d92a3bbc05596f3a6731e4b9cf4321f2d8b172b Mon Sep 17 00:00:00 2001 From: nixzhu Date: Tue, 19 May 2015 09:57:47 +0800 Subject: [PATCH] activityIndicator for DribbbleShotCell --- .../SocialWorkDribbbleViewController.swift | 2 +- Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift | 13 +++++++++++++ Yep/Views/Cells/DribbbleShot/DribbbleShotCell.xib | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Yep/ViewControllers/SocialWorks/SocialWorkDribbbleViewController.swift b/Yep/ViewControllers/SocialWorks/SocialWorkDribbbleViewController.swift index c22723a4..6c4fec98 100644 --- a/Yep/ViewControllers/SocialWorks/SocialWorkDribbbleViewController.swift +++ b/Yep/ViewControllers/SocialWorks/SocialWorkDribbbleViewController.swift @@ -122,7 +122,7 @@ extension SocialWorkDribbbleViewController: UICollectionViewDataSource, UICollec let shot = dribbbleShots[indexPath.item] - cell.imageView.kf_setImageWithURL(NSURL(string: shot.images.normal)!) + cell.configureWithDribbbleShot(shot) return cell } diff --git a/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift b/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift index 228e62ab..33671d6d 100644 --- a/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift +++ b/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift @@ -7,15 +7,28 @@ // import UIKit +import Kingfisher class DribbbleShotCell: UICollectionViewCell { @IBOutlet weak var imageView: UIImageView! + @IBOutlet weak var activityIndicator: UIActivityIndicatorView! + override func awakeFromNib() { super.awakeFromNib() // Initialization code } + func configureWithDribbbleShot(shot: DribbbleWork.Shot) { + imageView.kf_setImageWithURL(NSURL(string: shot.images.normal)!, placeholderImage: nil, optionsInfo: [.TargetCache: KingfisherOptions.CacheMemoryOnly], progressBlock: { receivedSize, totalSize in + if receivedSize < totalSize { + self.activityIndicator.startAnimating() + } + }, completionHandler: { image, error, cacheType, imageURL in + self.activityIndicator.stopAnimating() + }) + } + } diff --git a/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.xib b/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.xib index 48eb253c..3c73ef90 100644 --- a/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.xib +++ b/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.xib @@ -15,17 +15,23 @@ + + + +