Merge pull request #118 from orazz/master
If image downloaded then not show activityindicator
This commit is contained in:
commit
f9d117d5cf
|
|
@ -18,19 +18,19 @@ public class SKCache {
|
|||
}
|
||||
|
||||
public func imageForKey(key: String) -> UIImage? {
|
||||
return (self.imageCache as! SKImageCacheable).imageForKey(key)
|
||||
return (self.imageCache as? SKImageCacheable)!.imageForKey(key)
|
||||
}
|
||||
|
||||
public func setImage(image: UIImage, forKey key: String) {
|
||||
(self.imageCache as! SKImageCacheable).setImage(image, forKey: key)
|
||||
(self.imageCache as? SKImageCacheable)!.setImage(image, forKey: key)
|
||||
}
|
||||
|
||||
public func removeImageForKey(key: String) {
|
||||
(self.imageCache as! SKImageCacheable).removeImageForKey(key)
|
||||
(self.imageCache as? SKImageCacheable)!.removeImageForKey(key)
|
||||
}
|
||||
|
||||
public func imageForRequest(request: NSURLRequest) -> UIImage? {
|
||||
if let response = (self.imageCache as! SKRequestResponseCacheable).cachedResponseForRequest(request) {
|
||||
if let response = (self.imageCache as? SKRequestResponseCacheable)!.cachedResponseForRequest(request) {
|
||||
let data = response.data
|
||||
|
||||
return UIImage(data: data)
|
||||
|
|
@ -41,7 +41,7 @@ public class SKCache {
|
|||
|
||||
public func setImageData(data: NSData, response: NSURLResponse, request: NSURLRequest) {
|
||||
let cachedResponse = NSCachedURLResponse(response: response, data: data)
|
||||
(self.imageCache as! SKRequestResponseCacheable).storeCachedResponse(cachedResponse, forRequest: request)
|
||||
(self.imageCache as? SKRequestResponseCacheable)!.storeCachedResponse(cachedResponse, forRequest: request)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,9 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin
|
|||
contentSize = CGSize.zero
|
||||
|
||||
if !flag {
|
||||
indicatorView.startAnimating()
|
||||
if photo.underlyingImage == nil {
|
||||
indicatorView.startAnimating()
|
||||
}
|
||||
photo.loadUnderlyingImageAndNotify()
|
||||
} else {
|
||||
indicatorView.stopAnimating()
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class SKCacheTests: XCTestCase {
|
|||
|
||||
func testDefaultCacheImageForKey() {
|
||||
// given
|
||||
let cache = (self.cache.imageCache as! SKDefaultImageCache).cache
|
||||
let cache = (self.cache.imageCache as? SKDefaultImageCache)!.cache
|
||||
cache.setObject(self.image, forKey: self.key)
|
||||
|
||||
// when
|
||||
|
|
@ -50,14 +50,14 @@ class SKCacheTests: XCTestCase {
|
|||
self.cache.setImage(self.image, forKey: self.key)
|
||||
|
||||
// then
|
||||
let cache = (self.cache.imageCache as! SKDefaultImageCache).cache
|
||||
let cache = (self.cache.imageCache as? SKDefaultImageCache)!.cache
|
||||
let cachedImage = cache.objectForKey(self.key) as? UIImage
|
||||
XCTAssertNotNil(cachedImage)
|
||||
}
|
||||
|
||||
func testDefaultCacheRemoveImageForKey() {
|
||||
// given
|
||||
let cache = (self.cache.imageCache as! SKDefaultImageCache).cache
|
||||
let cache = (self.cache.imageCache as? SKDefaultImageCache)!.cache
|
||||
cache.setObject(self.image, forKey: self.key)
|
||||
|
||||
// when
|
||||
|
|
|
|||
Loading…
Reference in New Issue