VLCLocalNetworkListCell.m 1.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
//
//  VLCLocalNetworkListCell.m
//  VLC for iOS
//
//  Created by Felix Paul Kühne on 10.08.13.
//  Copyright (c) 2013 VideoLAN. All rights reserved.
//
//  Refer to the COPYING file of the official project for license.
//

#import "VLCLocalNetworkListCell.h"

@implementation VLCLocalNetworkListCell

+ (VLCLocalNetworkListCell *)cellWithReuseIdentifier:(NSString *)ident
{
    NSArray *nibContentArray = [[NSBundle mainBundle] loadNibNamed:@"VLCLocalNetworkListCell" owner:nil options:nil];
    NSAssert([nibContentArray count] == 1, @"meh");
    NSAssert([[nibContentArray lastObject] isKindOfClass:[VLCLocalNetworkListCell class]], @"meh meh");
    VLCLocalNetworkListCell *cell = (VLCLocalNetworkListCell *)[nibContentArray lastObject];

    return cell;
}

25 26 27 28
- (void)awakeFromNib
{
    self.titleLabel.text = @"";
    self.subtitleLabel.text = @"";
29
    self.thumbnailView.contentMode = UIViewContentModeScaleAspectFit;
30
    self.downloadButton.hidden = YES;
31 32
}

33 34 35 36 37 38 39 40
- (void)setIsDirectory:(BOOL)isDirectory
{
    self.titleLabel.hidden = self.subtitleLabel.hidden = isDirectory;
    self.folderTitleLabel.hidden = !isDirectory;

    _isDirectory = isDirectory;
}

41 42 43
- (void)setTitle:(NSString *)title
{
    BOOL isDir = self.isDirectory;
44
    self.folderTitleLabel.text = self.titleLabel.text = title;
45 46 47

    self.titleLabel.hidden = self.subtitleLabel.hidden = isDir;
    self.folderTitleLabel.hidden = !isDir;
48 49

    _title = title;
50 51 52 53 54 55 56
}

- (void)setSubtitle:(NSString *)subtitle
{
    self.subtitleLabel.text = subtitle;
}

57 58 59 60 61
- (void)setIcon:(UIImage *)icon
{
    self.thumbnailView.image = icon;
}

62 63 64 65 66 67 68
- (void)setIsDownloadable:(BOOL)isDownloadable
{
    self.downloadButton.hidden = !isDownloadable;
}

- (void)triggerDownload:(id)sender
{
69 70
    if ([self.delegate respondsToSelector:@selector(triggerDownloadForCell:)])
        [self.delegate triggerDownloadForCell:self];
71 72
}

73 74 75 76 77
+ (CGFloat)heightOfCell
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
        return 80.;

78
    return 68.;
79 80 81
}

@end