Commit 7a9ca495 authored by Felix Paul Kühne's avatar Felix Paul Kühne

upnp: improve folder listing and scrolling a lot on slower networks by...

upnp: improve folder listing and scrolling a lot on slower networks by fetching thumbnails off the main thread...
parent 475098b1
......@@ -29,6 +29,7 @@
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *subtitle;
@property (nonatomic, retain) UIImage *icon;
@property (nonatomic, retain) NSURL *iconURL;
@property (nonatomic, readwrite) BOOL isDownloadable;
@property (nonatomic, retain) NSURL *downloadURL;
......
......@@ -62,6 +62,19 @@
self.thumbnailView.image = icon;
}
- (void)setIconURL:(NSURL *)iconURL
{
_iconURL = iconURL;
[self performSelectorInBackground:@selector(_updateIconFromURL) withObject:@""];
}
- (void)_updateIconFromURL
{
NSData* imageData = [[NSData alloc]initWithContentsOfURL:self.iconURL];
UIImage* image = [[UIImage alloc] initWithData:imageData];
[self setIcon:image];
}
- (void)setIsDownloadable:(BOOL)isDownloadable
{
self.downloadButton.hidden = !isDownloadable;
......
......@@ -217,13 +217,9 @@
[cell setSubtitle: [NSString stringWithFormat:@"%@ (%@)", [NSByteCountFormatter stringFromByteCount:mediaSize countStyle:NSByteCountFormatterCountStyleFile], [VLCTime timeWithInt:durationInSeconds * 1000].stringValue]];
[cell setIsDirectory:NO];
cell.isDownloadable = YES;
if (![mediaItem.albumArt isEqualToString:NULL]) {
NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mediaItem.albumArt]];
UIImage* image = [[UIImage alloc] initWithData:imageData];
[cell setIcon:image];
}
else
[cell setIcon:[UIImage imageNamed:@"blank"]];
if (![mediaItem.albumArt isEqualToString:NULL])
[cell setIconURL:[NSURL URLWithString:mediaItem.albumArt]];
[cell setIcon:[UIImage imageNamed:@"blank"]];
cell.delegate = self;
} else {
[cell setIsDirectory:YES];
......
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