VLCPlaylistGridView.m 1.49 KB
Newer Older
1 2 3 4 5 6 7 8 9
//
//  VLCGridViewCell.m
//  AspenProject
//
//  Created by Felix Paul Kühne on 11.04.13.
//  Copyright (c) 2013 VideoLAN. All rights reserved.
//

#import "VLCPlaylistGridView.h"
10
#import "VLCAppDelegate.h"
11 12

@interface VLCPlaylistGridView (Hack)
13
@property (nonatomic, retain) NSString *reuseIdentifier;
14 15 16 17
@end

@implementation VLCPlaylistGridView

18 19 20 21 22 23 24 25 26 27 28 29 30 31
- (void)awakeFromNib {
    [super awakeFromNib];
    _contentView = self;
    self.backgroundColor = [UIColor blackColor];
    self.reuseIdentifier = @"AQPlaylistCell";
}

- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing:editing animated:animated];
    self.removeMediaButton.hidden = !editing;
}

- (void)prepareForReuse
32
{
33 34
    [super prepareForReuse];
    self.removeMediaButton.hidden = YES;
35 36
}

37
+ (CGSize)preferredSize
38
{
39
    return CGSizeMake(384, 240);
40 41
}

42
- (void)setMediaObject:(MLFile *)mediaObject
43
{
44
    [mediaObject willDisplay];
45

46 47 48 49
    self.titleLabel.text = mediaObject.title;
    self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %.2f MB", [VLCTime timeWithNumber:[mediaObject duration]], [mediaObject fileSizeInBytes] / 2e6];
    self.thumbnailView.image = mediaObject.computedThumbnail;
    self.progressView.progress = mediaObject.lastPosition.floatValue;
50

51 52 53
    _mediaObject = mediaObject;

    [self setNeedsDisplay];
54 55
}

56
- (IBAction)removeMedia:(id)sender
57
{
58 59
    VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
    [appDelegate.playlistViewController removeMediaObject:self.mediaObject];
60 61 62
}

@end