123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- /*****************************************************************************
- * VLCPlaylistTableViewCell.m
- * VLC for iOS
- *****************************************************************************
- * Copyright (c) 2013-2015 VideoLAN. All rights reserved.
- * $Id$
- *
- * Authors: Felix Paul Kühne <fkuehne # videolan.org>
- * Gleb Pinigin <gpinigin # gmail.com>
- * Carola Nitz <nitz.carola #googlemail.com>
- *
- * Refer to the COPYING file of the official project for license.
- *****************************************************************************/
- #import "VLCPlaylistTableViewCell.h"
- #import "VLCLinearProgressIndicator.h"
- #import "VLCThumbnailsCache.h"
- #import "NSString+SupportedMedia.h"
- #import <MediaLibraryKit/MLAlbum.h>
- @interface VLCPlaylistTableViewCell ()
- {
- UILongPressGestureRecognizer *_longPress;
- }
- @end
- @implementation VLCPlaylistTableViewCell
- - (void)dealloc
- {
- [self _removeObserver];
- }
- + (VLCPlaylistTableViewCell *)cellWithReuseIdentifier:(NSString *)ident
- {
- NSArray *nibContentArray;
- 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];
- cell.multipleSelectionBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
- cell.metaDataLabel.hidden = YES;
- return cell;
- }
- - (void)setNeedsDisplay
- {
- [self collapsWithAnimation:NO];
- [super setNeedsDisplay];
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
- {
- [self _updatedDisplayedInformationForKeyPath:keyPath];
- }
- - (void)_removeObserver
- {
- @try {
- if ([_mediaObject isKindOfClass:[MLLabel class]]) {
- [_mediaObject removeObserver:self forKeyPath:@"files"];
- [_mediaObject removeObserver:self forKeyPath:@"name"];
- } else if ([_mediaObject isKindOfClass:[MLShow class]])
- [_mediaObject removeObserver:self forKeyPath:@"episodes"];
- else if ([_mediaObject isKindOfClass:[MLShowEpisode class]]) {
- [_mediaObject removeObserver:self forKeyPath:@"name"];
- [_mediaObject removeObserver:self forKeyPath:@"files"];
- [_mediaObject removeObserver:self forKeyPath:@"artworkURL"];
- [_mediaObject removeObserver:self forKeyPath:@"unread"];
- } else if ([_mediaObject isKindOfClass:[MLAlbum class]]) {
- [_mediaObject removeObserver:self forKeyPath:@"name"];
- [_mediaObject removeObserver:self forKeyPath:@"tracks"];
- } else if ([_mediaObject isKindOfClass:[MLAlbumTrack class]]) {
- [_mediaObject addObserver:self forKeyPath:@"unread" options:0 context:nil];
- [_mediaObject removeObserver:self forKeyPath:@"artist"];
- [_mediaObject removeObserver:self forKeyPath:@"title"];
- [_mediaObject removeObserver:self forKeyPath:@"files"];
- MLFile *anyFileFromTrack = [(MLAlbumTrack *)_mediaObject files].anyObject;
- if (anyFileFromTrack)
- [anyFileFromTrack removeObserver:self forKeyPath:@"artworkURL"];
- } else if ([_mediaObject isKindOfClass:[MLFile class]]) {
- [_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 removeObserver:self forKeyPath:@"albumTrackNumber"];
- [_mediaObject removeObserver:self forKeyPath:@"album"];
- [_mediaObject removeObserver:self forKeyPath:@"artist"];
- [_mediaObject removeObserver:self forKeyPath:@"genre"];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [(MLFile*)_mediaObject didHide];
- }
- }
- @catch (NSException *exception) {
- APLog(@"removing observer failed");
- }
- }
- - (void)_addObserver
- {
- if ([_mediaObject isKindOfClass:[MLLabel class]]) {
- [_mediaObject addObserver:self forKeyPath:@"files" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"name" options:0 context:nil];
- } else if ([_mediaObject isKindOfClass:[MLShow class]])
- [_mediaObject addObserver:self forKeyPath:@"episodes" options:0 context:nil];
- else if ([_mediaObject isKindOfClass:[MLShowEpisode class]]) {
- [_mediaObject addObserver:self forKeyPath:@"name" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"files" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"artworkURL" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"unread" options:0 context:nil];
- } else if ([_mediaObject isKindOfClass:[MLAlbum class]]) {
- [_mediaObject addObserver:self forKeyPath:@"name" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"tracks" options:0 context:nil];
- } else if ([_mediaObject isKindOfClass:[MLAlbumTrack class]]) {
- [_mediaObject addObserver:self forKeyPath:@"unread" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"artist" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"title" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"files" options:0 context:nil];
- MLFile *anyFileFromTrack = [(MLAlbumTrack *)_mediaObject files].anyObject;
- if (anyFileFromTrack)
- [anyFileFromTrack addObserver:self forKeyPath:@"artworkURL" options:0 context:nil];
- } else if ([_mediaObject isKindOfClass:[MLFile class]]) {
- [_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 addObserver:self forKeyPath:@"albumTrackNumber" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"album" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"artist" options:0 context:nil];
- [_mediaObject addObserver:self forKeyPath:@"genre" options:0 context:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(thumbnailWasUpdated:)
- name:MLFileThumbnailWasUpdated
- object:nil];
- [(MLFile*)_mediaObject willDisplay];
- }
- }
- - (void)setMediaObject:(MLFile *)mediaObject
- {
- if (_mediaObject != mediaObject) {
- [self _removeObserver];
- _mediaObject = mediaObject;
- // prevent the cell from recycling the current snap for random contents
- self.thumbnailView.image = nil;
- [self _addObserver];
- }
- [self collapsWithAnimation:NO];
- [self _updatedDisplayedInformationForKeyPath:nil];
- }
- - (void)setEditing:(BOOL)editing animated:(BOOL)animated
- {
- [super setEditing:editing animated:animated];
- [self _updatedDisplayedInformationForKeyPath:@"editing"];
- if (editing) {
- if (_longPress)
- [self removeGestureRecognizer:_longPress];
- } else {
- if (!_longPress)
- _longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTouchGestureAction:)];
- [self addGestureRecognizer:_longPress];
- }
- }
- - (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
- {
- self.thumbnailView.contentMode = UIViewContentModeScaleAspectFill;
- if ([self.mediaObject isKindOfClass:[MLFile class]]) {
- [self _configureForMLFile:(MLFile *)self.mediaObject];
- } else if ([self.mediaObject isKindOfClass:[MLLabel class]]) {
- [self _configureForFolder:(MLLabel *)self.mediaObject];
- } else if ([self.mediaObject isKindOfClass:[MLAlbum class]]) {
- [self _configureForAlbum:(MLAlbum *)self.mediaObject];
- } else if ([self.mediaObject isKindOfClass:[MLAlbumTrack class]]) {
- [self _configureForAlbumTrack:(MLAlbumTrack *)self.mediaObject];
- if ([keyPath isEqualToString:@"computedThumbnail"] || !keyPath || (!self.thumbnailView.image && [keyPath isEqualToString:@"editing"])) {
- self.thumbnailView.image = [VLCThumbnailsCache thumbnailForManagedObject:self.mediaObject];
- }
- } else if ([self.mediaObject isKindOfClass:[MLShow class]]) {
- MLShow *mediaObject = (MLShow *)self.mediaObject;
- [self _configureForShow:mediaObject];
- if ([keyPath isEqualToString:@"computedThumbnail"] || [keyPath isEqualToString:@"episodes"] || !keyPath || (!self.thumbnailView.image && [keyPath isEqualToString:@"editing"])) {
- self.thumbnailView.image = [VLCThumbnailsCache thumbnailForManagedObject:mediaObject];
- }
- } else if ([self.mediaObject isKindOfClass:[MLShowEpisode class]]) {
- [self _configureForShowEpisode:(MLShowEpisode *)self.mediaObject];
- }
- if (![self.mediaObject isKindOfClass:[MLShow class]] && ([keyPath isEqualToString:@"computedThumbnail"] || !keyPath || (!self.thumbnailView.image && [keyPath isEqualToString:@"editing"]))) {
- self.thumbnailView.image = [VLCThumbnailsCache thumbnailForManagedObject:self.mediaObject];
- }
- [self setNeedsDisplay];
- }
- + (CGFloat)heightOfCell
- {
- return 90.;
- }
- #pragma mark - presentation
- - (void)_configureForShow:(MLShow *)show
- {
- self.titleLabel.text = show.name;
- NSUInteger count = show.episodes.count;
- NSString *string = @"";
- if (show.releaseYear)
- string = [NSString stringWithFormat:@"%@ — ", show.releaseYear];
- self.subtitleLabel.text = [string stringByAppendingString:[NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_EPISODES", nil) : NSLocalizedString(@"LIBRARY_SINGLE_EPISODE", nil), count, show.unreadEpisodes.count]];
- self.mediaIsUnreadView.hidden = YES;
- self.progressIndicator.hidden = YES;
- self.folderIconView.image = [UIImage imageNamed:@"tvShow"];
- self.folderIconView.hidden = NO;
- }
- - (void)_configureForAlbumTrack:(MLAlbumTrack *)albumTrack
- {
- MLFile *anyFileFromTrack = albumTrack.files.anyObject;
- self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@ — %@", albumTrack.artist, [NSString stringWithFormat:NSLocalizedString(@"LIBRARY_TRACK_N", nil), albumTrack.trackNumber.intValue], [VLCTime timeWithNumber:[anyFileFromTrack duration]]];
- self.titleLabel.text = albumTrack.title;
- [self _showPositionOfItem:anyFileFromTrack];
- self.folderIconView.hidden = YES;
- }
- - (void)_configureForShowEpisode:(MLShowEpisode *)showEpisode
- {
- self.titleLabel.text = showEpisode.name;
- MLFile *anyFileFromEpisode = showEpisode.files.anyObject;
- if (self.titleLabel.text.length < 1) {
- self.titleLabel.text = [NSString stringWithFormat:@"S%02dE%02d", showEpisode.seasonNumber.intValue, showEpisode.episodeNumber.intValue];
- self.subtitleLabel.text = [NSString stringWithFormat:@"%@", [VLCTime timeWithNumber:[anyFileFromEpisode duration]]];
- } else
- self.subtitleLabel.text = [NSString stringWithFormat:@"S%02dE%02d — %@", showEpisode.seasonNumber.intValue, showEpisode.episodeNumber.intValue, [VLCTime timeWithNumber:[anyFileFromEpisode duration]]];
- [self _showPositionOfItem:anyFileFromEpisode];
- self.folderIconView.hidden = YES;
- }
- - (void)_configureForAlbum:(MLAlbum *)album
- {
- self.titleLabel.text = album.name;
- MLAlbumTrack *anyTrack = [album.tracks anyObject];
- NSUInteger count = album.tracks.count;
- NSMutableString *string = [[NSMutableString alloc] init];
- if (anyTrack) {
- if (anyTrack.artist.length > 0) {
- [string appendString:anyTrack.artist];
- [string appendString:@" — "];
- }
- }
- [string appendString:[NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_TRACKS", nil) : NSLocalizedString(@"LIBRARY_SINGLE_TRACK", nil), count]];
- if (album.releaseYear.length > 0)
- [string appendFormat:@" — %@", album.releaseYear];
- self.subtitleLabel.text = string;
- self.mediaIsUnreadView.hidden = YES;
- self.progressIndicator.hidden = YES;
- self.folderIconView.hidden = YES;
- }
- - (void)_configureForFolder:(MLLabel *)label
- {
- self.titleLabel.text = label.name;
- NSUInteger count = label.files.count;
- self.subtitleLabel.text = (count == 1) ? NSLocalizedString(@"ONE_FILE", nil) : [NSString stringWithFormat:NSLocalizedString(@"NUM_OF_FILES", nil), count];
- self.mediaIsUnreadView.hidden = YES;
- self.progressIndicator.hidden = YES;
- self.folderIconView.image = [UIImage imageNamed:@"folderIcon"];
- self.folderIconView.hidden = NO;
- }
- - (void)_configureForMLFile:(MLFile *)mediaFile
- {
- if (mediaFile.isAlbumTrack) {
- NSString *string = @"";
- if (mediaFile.albumTrack.artist)
- string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
- else if (mediaFile.albumTrack.album.name)
- string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
- self.titleLabel.text = [string stringByAppendingString:(mediaFile.albumTrack.title.length > 1) ? mediaFile.albumTrack.title : mediaFile.title];
- } else
- self.titleLabel.text = mediaFile.title;
- if (self.isEditing)
- self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@", [VLCTime timeWithNumber:[mediaFile duration]], [NSByteCountFormatter stringFromByteCount:[mediaFile fileSizeInBytes] countStyle:NSByteCountFormatterCountStyleFile]];
- else {
- self.subtitleLabel.text = [NSString stringWithFormat:@"%@", [VLCTime timeWithNumber:[mediaFile duration]]];
- if (mediaFile.videoTrack) {
- NSString *width = [[mediaFile videoTrack] valueForKey:@"width"];
- NSString *height = [[mediaFile videoTrack] valueForKey:@"height"];
- if (width.intValue > 0 && height.intValue > 0)
- self.subtitleLabel.text = [self.subtitleLabel.text stringByAppendingFormat:@" — %@x%@", width, height];
- }
- }
- [self _showPositionOfItem:mediaFile];
- self.folderIconView.hidden = YES;
- }
- - (void)_showPositionOfItem:(MLFile *)mediaLibraryFile
- {
- if (!mediaLibraryFile)
- return;
- CGFloat position = mediaLibraryFile.lastPosition.floatValue;
- CGFloat duration = mediaLibraryFile.duration.floatValue;
- if (position > .05f && position < .95f && (duration * position - duration) < -60000) {
- [(UITextView*)self.mediaIsUnreadView setText:[NSString stringWithFormat:NSLocalizedString(@"LIBRARY_MINUTES_LEFT", nil), [[VLCTime timeWithInt:(duration * position - duration)] minuteStringValue]]];
- self.mediaIsUnreadView.hidden = NO;
- } else if (mediaLibraryFile.unread.intValue) {
- [(UILabel *)self.mediaIsUnreadView setText:[NSLocalizedString(@"NEW", nil) capitalizedStringWithLocale:[NSLocale currentLocale]]];
- self.mediaIsUnreadView.hidden = NO;
- } else
- self.mediaIsUnreadView.hidden = YES;
- }
- - (void)longTouchGestureAction:(UIGestureRecognizer *)recognizer
- {
- _isExpanded = YES;
- CGRect frame = self.frame;
- frame.size.height = 180.;
- BOOL metaHidden = NO;
- MLFile *theFile;
- if ([self.mediaObject isKindOfClass:[MLFile class]])
- theFile = (MLFile *)self.mediaObject;
- else if ([self.mediaObject isKindOfClass:[MLShowEpisode class]])
- theFile = [[(MLShowEpisode *)self.mediaObject files]anyObject];
- else if ([self.mediaObject isKindOfClass:[MLAlbumTrack class]])
- theFile = [[(MLAlbumTrack *)self.mediaObject files]anyObject];
- NSMutableString *mediaInfo = [[NSMutableString alloc] init];
- if (theFile) {
- NSMutableArray *videoTracks = [[NSMutableArray alloc] init];
- NSMutableArray *audioTracks = [[NSMutableArray alloc] init];
- NSMutableArray *spuTracks = [[NSMutableArray alloc] init];
- NSArray *tracks = [[theFile tracks] allObjects];
- NSUInteger trackCount = tracks.count;
- for (NSUInteger x = 0; x < trackCount; x++) {
- NSManagedObject *track = tracks[x];
- NSString *trackEntityName = [[track entity] name];
- if ([trackEntityName isEqualToString:@"VideoTrackInformation"])
- [videoTracks addObject:track];
- else if ([trackEntityName isEqualToString:@"AudioTrackInformation"])
- [audioTracks addObject:track];
- else if ([trackEntityName isEqualToString:@"SubtitlesTrackInformation"])
- [spuTracks addObject:track];
- }
- /* print video info */
- trackCount = videoTracks.count;
- if (trackCount > 0) {
- if (trackCount != 1)
- [mediaInfo appendFormat:@"%lu video tracks", (unsigned long)trackCount];
- else
- [mediaInfo appendString:@"1 video track"];
- [mediaInfo appendString:@" ("];
- for (NSUInteger x = 0; x < trackCount; x++) {
- int fourcc = [[videoTracks[x] valueForKey:@"codec"] intValue];
- if (x != 0)
- [mediaInfo appendFormat:@", %4.4s", (char *)&fourcc];
- else
- [mediaInfo appendFormat:@"%4.4s", (char *)&fourcc];
- }
- [mediaInfo appendString:@")"];
- }
- /* print audio info */
- trackCount = audioTracks.count;
- if (trackCount > 0) {
- if (mediaInfo.length > 0)
- [mediaInfo appendString:@"\n\n"];
- if (trackCount != 1)
- [mediaInfo appendFormat:@"%lu audio tracks", (unsigned long)trackCount];
- else
- [mediaInfo appendString:@"1 audio track"];
- [mediaInfo appendString:@":\n"];
- for (NSUInteger x = 0; x < trackCount; x++) {
- NSManagedObject *track = audioTracks[x];
- int fourcc = [[track valueForKey:@"codec"] intValue];
- if (x != 0)
- [mediaInfo appendFormat:@", %4.4s", (char *)&fourcc];
- else
- [mediaInfo appendFormat:@"%4.4s", (char *)&fourcc];
- int channelNumber = [[track valueForKey:@"channelsNumber"] intValue];
- NSString *language = [track valueForKey:@"language"];
- int bitrate = [[track valueForKey:@"bitrate"] intValue];
- if (channelNumber != 0 || language != nil || bitrate > 0) {
- [mediaInfo appendString:@" ["];
- if (bitrate > 0)
- [mediaInfo appendFormat:@"%i kbit/s", bitrate / 1024];
- if (channelNumber > 0) {
- if (bitrate > 0)
- [mediaInfo appendString:@", "];
- if (channelNumber == 1)
- [mediaInfo appendString:@"MONO"];
- else if (channelNumber == 2)
- [mediaInfo appendString:@"STEREO"];
- else
- [mediaInfo appendString:@"MULTI-CHANNEL"];
- }
- if (language != nil) {
- if (channelNumber > 0 || bitrate > 0)
- [mediaInfo appendString:@", "];
- [mediaInfo appendString:[language uppercaseString]];
- }
- [mediaInfo appendString:@"]"];
- }
- }
- }
- /* SPU */
- trackCount = spuTracks.count;
- if (trackCount == 0) {
- NSFileManager *fileManager = [NSFileManager defaultManager];
- NSString *folderLocation = [theFile.url.path stringByDeletingLastPathComponent];
- NSArray *allfiles = [fileManager contentsOfDirectoryAtPath:folderLocation error:nil];
- NSString *fileName = [theFile.path.lastPathComponent stringByDeletingPathExtension];
- NSUInteger count = allfiles.count;
- NSString *additionalFilePath;
- for (unsigned int x = 0; x < count; x++) {
- additionalFilePath = [NSString stringWithFormat:@"%@", allfiles[x]];
- if ([additionalFilePath isSupportedSubtitleFormat])
- if ([additionalFilePath rangeOfString:fileName].location != NSNotFound)
- trackCount ++;
- }
- }
- if ((trackCount > 0) && (spuTracks.count > 0)) {
- if (mediaInfo.length > 0)
- [mediaInfo appendString:@"\n\n"];
- if (trackCount != 1)
- [mediaInfo appendFormat:@"%lu subtitles tracks", (unsigned long)trackCount];
- else
- [mediaInfo appendString:@"1 subtitles track"];
- [mediaInfo appendString:@" ("];
- for (NSUInteger x = 0; x < trackCount; x++) {
- NSString *language = [spuTracks[x] valueForKey:@"language"];
- if (language) {
- if (x != 0)
- [mediaInfo appendFormat:@", %@", [language uppercaseString]];
- else
- [mediaInfo appendString:[language uppercaseString]];
- }
- }
- [mediaInfo appendString:@")"];
- }
- self.metaDataLabel.text = mediaInfo;
- videoTracks = audioTracks = spuTracks = nil;
- } else
- self.metaDataLabel.text = @"";
- void (^animationBlock)() = ^() {
- self.frame = frame;
- self.metaDataLabel.hidden = metaHidden;
- };
- void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
- self.frame = frame;
- self.metaDataLabel.hidden = metaHidden;
- };
- NSTimeInterval animationDuration = .2;
- [UIView animateWithDuration:animationDuration animations:animationBlock completion:completionBlock];
- }
- - (void)collapsWithAnimation:(BOOL)animate
- {
- _isExpanded = NO;
- if (!animate) {
- self.metaDataLabel.hidden = YES;
- CGRect frame = self.frame;
- frame.size.height = 90.;
- self.frame = frame;
- return;
- }
- CGRect frame = self.frame;
- frame.size.height = 90.;
- BOOL metaHidden = YES;
- void (^animationBlock)() = ^() {
- self.frame = frame;
- self.metaDataLabel.hidden = metaHidden;
- };
- void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
- self.frame = frame;
- self.metaDataLabel.hidden = metaHidden;
- };
- NSTimeInterval animationDuration = .2;
- [UIView animateWithDuration:animationDuration animations:animationBlock completion:completionBlock];
- }
- - (void)thumbnailWasUpdated:(NSNotification *)aNotification
- {
- self.thumbnailView.contentMode = UIViewContentModeScaleAspectFill;
- self.thumbnailView.image = [VLCThumbnailsCache thumbnailForManagedObject:self.mediaObject refreshCache:YES];
- }
- @end
|