Commit 46a53698 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Library: fix thumbnail display if app is freshly installed

parent e6ff524d
......@@ -96,18 +96,23 @@
_thumbnailCacheIndex = [[NSMutableArray alloc] initWithCapacity:MAX_CACHE_SIZE];
NSManagedObjectID *objID = self.mediaObject.objectID;
UIImage *displayedImage;
if ([_thumbnailCacheIndex containsObject:objID]) {
[_thumbnailCacheIndex removeObject:objID];
[_thumbnailCacheIndex insertObject:objID atIndex:0];
displayedImage = [_thumbnailCache objectForKey:objID];
} else {
if (_thumbnailCacheIndex.count >= MAX_CACHE_SIZE) {
[_thumbnailCache removeObjectForKey:[_thumbnailCacheIndex lastObject]];
[_thumbnailCacheIndex removeLastObject];
}
[_thumbnailCache setObject:self.mediaObject.computedThumbnail forKey:objID];
[_thumbnailCacheIndex insertObject:objID atIndex:0];
displayedImage = self.mediaObject.computedThumbnail;
if (displayedImage) {
[_thumbnailCache setObject:self.mediaObject.computedThumbnail forKey:objID];
[_thumbnailCacheIndex insertObject:objID atIndex:0];
}
}
self.thumbnailView.image = [_thumbnailCache objectForKey:objID];
self.thumbnailView.image = displayedImage;
}
self.progressView.progress = self.mediaObject.lastPosition.floatValue;
......
......@@ -81,18 +81,23 @@
_thumbnailCacheIndex = [[NSMutableArray alloc] initWithCapacity:MAX_CACHE_SIZE];
NSManagedObjectID *objID = self.mediaObject.objectID;
UIImage *displayedImage;
if ([_thumbnailCacheIndex containsObject:objID]) {
[_thumbnailCacheIndex removeObject:objID];
[_thumbnailCacheIndex insertObject:objID atIndex:0];
displayedImage = [_thumbnailCache objectForKey:objID];
} else {
if (_thumbnailCacheIndex.count >= MAX_CACHE_SIZE) {
[_thumbnailCache removeObjectForKey:[_thumbnailCacheIndex lastObject]];
[_thumbnailCacheIndex removeLastObject];
}
[_thumbnailCache setObject:self.mediaObject.computedThumbnail forKey:objID];
[_thumbnailCacheIndex insertObject:objID atIndex:0];
displayedImage = self.mediaObject.computedThumbnail;
if (displayedImage) {
[_thumbnailCache setObject:self.mediaObject.computedThumbnail forKey:objID];
[_thumbnailCacheIndex insertObject:objID atIndex:0];
}
}
self.thumbnailView.image = [_thumbnailCache objectForKey:objID];
self.thumbnailView.image = displayedImage;
}
self.progressIndicator.progress = self.mediaObject.lastPosition.floatValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment