make sure needReloadData after updateFeeds

This commit is contained in:
nixzhu
2015-12-07 16:16:43 +08:00
parent d12ccea3f9
commit 5d3fe3124d
2 changed files with 29 additions and 5 deletions
+1 -3
View File
@@ -40,7 +40,7 @@ class ImageCache {
let attachmentOriginKey = "attachment-0.0-0.0-\(attachmentURL.absoluteString)"
let attachmentSizeKey = "attachment-\(cacheSize.width)-\(cacheSize.height)-\(attachmentURL.absoluteString)"
let OptionsInfos: KingfisherManager.Options = (forceRefresh: false, lowPriority: false, cacheMemoryOnly: false, shouldDecode: false, queue: cacheAttachmentQueue, scale: UIScreen.mainScreen().scale)
// Size Cache
@@ -49,8 +49,6 @@ class ImageCache {
if let image = image?.decodedImage() {
dispatch_async(dispatch_get_main_queue()) {
completion(url: attachmentURL, image: image, cacheType: type)
Kingfisher.ImageCache.defaultCache.storeImage(image, forKey: attachmentSizeKey, toDisk: false, completionHandler: nil)
}
} else {
@@ -439,6 +439,12 @@ class FeedsViewController: BaseViewController {
if let strongSelf = self {
let newFeeds = feeds
var needReloadData = false
needReloadData = strongSelf.feeds.isEmpty
if isLoadMore {
strongSelf.feeds += feeds
@@ -446,10 +452,30 @@ class FeedsViewController: BaseViewController {
strongSelf.feeds = feeds
}
// reload
if !feeds.isEmpty {
if newFeeds.count == strongSelf.feeds.count {
var index = 0
while index < newFeeds.count {
let newFeed = newFeeds[index]
let oldFeed = strongSelf.feeds[index]
if newFeed.id != oldFeed.id {
needReloadData = true
break
}
index += 1
}
} else {
needReloadData = true
}
}
if needReloadData {
println("new feeds, reloadData")
strongSelf.feedsTableView.reloadData() //
strongSelf.feedsTableView.reloadData()
}
}
}