1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // VLCPlaylistTableViewCell.m
- // AspenProject
- //
- // Created by Felix Paul Kühne on 01.04.13.
- // Copyright (c) 2013 VideoLAN. All rights reserved.
- //
- // Refer to the COPYING file of the official project for license.
- //
- #import "VLCPlaylistTableViewCell.h"
- @implementation VLCPlaylistTableViewCell
- + (VLCPlaylistTableViewCell *)cellWithReuseIdentifier:(NSString *)ident
- {
- NSArray *nibContentArray = [[NSBundle mainBundle] loadNibNamed:@"VLCPlaylistTableViewCell" owner:nil options:nil];
- NSAssert([nibContentArray count] == 1, @"meh");
- NSAssert([[nibContentArray lastObject] isKindOfClass:[VLCPlaylistTableViewCell class]], @"meh meh");
- VLCPlaylistTableViewCell *cell = (VLCPlaylistTableViewCell *)[nibContentArray lastObject];
- return cell;
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
- {
- [self _updatedDisplayedInformationForKeyPath:keyPath];
- }
- - (void)setMediaObject:(MLFile *)mediaObject
- {
- if (_mediaObject != mediaObject) {
- [_mediaObject removeObserver:self forKeyPath:@"computedThumbnail"];
- [_mediaObject removeObserver:self forKeyPath:@"lastPosition"];
- [_mediaObject removeObserver:self forKeyPath:@"duration"];
- [_mediaObject removeObserver:self forKeyPath:@"fileSizeInBytes"];
- [_mediaObject removeObserver:self forKeyPath:@"title"];
- [_mediaObject removeObserver:self forKeyPath:@"thumbnailTimeouted"];
- [_mediaObject removeObserver:self forKeyPath:@"unread"];
- [_mediaObject didHide];
- _mediaObject = mediaObject;
- [_mediaObject addObserver:self forKeyPath:@"computedThumbnail" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"lastPosition" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"duration" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"fileSizeInBytes" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"title" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"thumbnailTimeouted" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"unread" options:0 context:nil];
- [_mediaObject willDisplay];
- }
- [self _updatedDisplayedInformationForKeyPath:NULL];
- }
- - (void)setEditing:(BOOL)editing animated:(BOOL)animated
- {
- [super setEditing:editing animated:animated];
- [self _updatedDisplayedInformationForKeyPath:@"editing"];
- }
- - (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
- {
- self.titleLabel.text = self.mediaObject.title;
- if (self.isEditing)
- self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %i MB", [VLCTime timeWithNumber:[self.mediaObject duration]], (int)([self.mediaObject fileSizeInBytes] / 1e6)];
- else {
- self.subtitleLabel.text = [NSString stringWithFormat:@"%@", [VLCTime timeWithNumber:[self.mediaObject duration]]];
- if (self.mediaObject.videoTrack)
- self.subtitleLabel.text = [self.subtitleLabel.text stringByAppendingFormat:@" — %@x%@", [[self.mediaObject videoTrack] valueForKey:@"width"], [[self.mediaObject videoTrack] valueForKey:@"height"]];
- }
- if ([keyPath isEqualToString:@"computedThumbnail"] || !keyPath)
- self.thumbnailView.image = self.mediaObject.computedThumbnail;
- self.progressIndicator.progress = self.mediaObject.lastPosition.floatValue;
- self.progressIndicator.hidden = ((self.progressIndicator.progress < .1f) || (self.progressIndicator.progress > .95f)) ? YES : NO;
- self.mediaIsUnreadView.hidden = !self.mediaObject.unread.intValue;
- [self setNeedsDisplay];
- }
- + (CGFloat)heightOfCell
- {
- return 80.;
- }
- @end
|