mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-11 00:40:25 +00:00
Improve handling of file URLs for ASNetworkImageNode.
Details discussed in https://github.com/facebook/AsyncDisplayKit/pull/1003. This PR supercedes that one.
This commit is contained in:
parent
e56315dba9
commit
b75b72c660
17
AsyncDisplayKit/ASNetworkImageNode.mm
Normal file → Executable file
17
AsyncDisplayKit/ASNetworkImageNode.mm
Normal file → Executable file
@ -188,14 +188,23 @@
|
||||
ASDN::MutexLocker l(_lock);
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
_imageLoaded = YES;
|
||||
|
||||
if (self.shouldCacheImage) {
|
||||
self.image = [UIImage imageNamed:_URL.path];
|
||||
self.image = [UIImage imageNamed:_URL.path.lastPathComponent];
|
||||
} else {
|
||||
// First try to load the path directly, for efficiency assuming a developer who
|
||||
// doesn't want caching is trying to be as minimal as possible.
|
||||
self.image = [UIImage imageWithContentsOfFile:_URL.path];
|
||||
if (!self.image) {
|
||||
// If we couldn't find it, execute an -imageNamed:-like search so we can find resources even if the
|
||||
// extension is not provided in the path. This allows the same path to work regardless of shouldCacheImage.
|
||||
NSString *filename = [[NSBundle mainBundle] pathForResource:_URL.path.lastPathComponent ofType:nil];
|
||||
if (filename) {
|
||||
self.image = [UIImage imageWithContentsOfFile:filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_imageLoaded = YES;
|
||||
[_delegate imageNode:self didLoadImage:self.image];
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user