Commit e70df32f authored by Felix Paul Kühne's avatar Felix Paul Kühne

Remove AQGridView

parent c97b1813
......@@ -35,7 +35,7 @@
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBUICollectionViewCell" id="541525164">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUIView" id="343928585">
......@@ -47,7 +47,6 @@
<int key="NSvFlags">264</int>
<string key="NSFrame">{{19, 76}, {257, 20}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="405891686"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -74,7 +73,7 @@
<int key="type">1</int>
<double key="pointSize">18</double>
</object>
<object class="NSFont" key="IBUIFont" id="483977020">
<object class="NSFont" key="IBUIFont" id="670371248">
<string key="NSName">HelveticaNeue</string>
<double key="NSSize">18</double>
<int key="NSfFlags">16</int>
......@@ -85,7 +84,6 @@
<int key="NSvFlags">264</int>
<string key="NSFrame">{{20, 96}, {258, 28}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="99927648"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -108,7 +106,7 @@
<int key="type">1</int>
<double key="pointSize">14</double>
</object>
<object class="NSFont" key="IBUIFont" id="1017855913">
<object class="NSFont" key="IBUIFont" id="1007861149">
<string key="NSName">HelveticaNeue</string>
<double key="NSSize">14</double>
<int key="NSfFlags">16</int>
......@@ -119,7 +117,6 @@
<int key="NSvFlags">274</int>
<string key="NSFrame">{{21, 14}, {256, 144}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="501792178"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
......@@ -130,7 +127,6 @@
<int key="NSvFlags">264</int>
<string key="NSFrame">{{20, 167}, {258, 21}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="288639132"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -147,14 +143,13 @@
<bool key="IBUIAdjustsLetterSpacingToFitWidth">YES</bool>
<int key="IBUITextAlignment">1</int>
<reference key="IBUIFontDescription" ref="290339558"/>
<reference key="IBUIFont" ref="483977020"/>
<reference key="IBUIFont" ref="670371248"/>
</object>
<object class="IBUILabel" id="288639132">
<reference key="NSNextResponder" ref="343928585"/>
<int key="NSvFlags">264</int>
<string key="NSFrame">{{20, 190}, {258, 28}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
......@@ -171,7 +166,7 @@
<int key="IBUIBaselineAdjustment">0</int>
<int key="IBUITextAlignment">1</int>
<reference key="IBUIFontDescription" ref="106500751"/>
<reference key="IBUIFont" ref="1017855913"/>
<reference key="IBUIFont" ref="1007861149"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
</object>
<object class="IBUILabel" id="22663525">
......@@ -179,7 +174,6 @@
<int key="NSvFlags">264</int>
<string key="NSFrame">{{27, 12}, {230, 28}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="699596644"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -199,14 +193,13 @@
<float key="IBUIMinimumFontSize">9</float>
<bool key="IBUIAdjustsLetterSpacingToFitWidth">YES</bool>
<reference key="IBUIFontDescription" ref="106500751"/>
<reference key="IBUIFont" ref="1017855913"/>
<reference key="IBUIFont" ref="1007861149"/>
</object>
<object class="IBUIView" id="501792178">
<reference key="NSNextResponder" ref="343928585"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{21, 146}, {256, 12}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="634412904"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<object class="NSColor" key="IBUIBackgroundColor" id="476951524">
......@@ -220,7 +213,6 @@
<int key="NSvFlags">274</int>
<string key="NSFrame">{{16, 9}, {266, 154}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="22663525"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
......@@ -235,7 +227,6 @@
<int key="NSvFlags">-2147483356</int>
<string key="NSFrame">{{260, 2}, {33, 29}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="457142782"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -270,7 +261,6 @@
<int key="NSvFlags">297</int>
<string key="NSFrame">{{235, 12}, {44, 44}}</string>
<reference key="NSSuperview" ref="343928585"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="657061410"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
......@@ -283,7 +273,6 @@
</array>
<string key="NSFrameSize">{298, 220}</string>
<reference key="NSSuperview" ref="541525164"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="130196590"/>
<reference key="IBUIBackgroundColor" ref="476951524"/>
<bool key="IBUIOpaque">NO</bool>
......@@ -294,8 +283,6 @@
</object>
</array>
<string key="NSFrameSize">{298, 220}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="343928585"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -504,102 +491,7 @@
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">UICollectionReusableView</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/UICollectionReusableView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UICollectionViewCell</string>
<string key="superclassName">UICollectionReusableView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/UICollectionViewCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCLinearProgressIndicator</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/VLCLinearProgressIndicator.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCPlaylistCollectionViewCell</string>
<string key="superclassName">UICollectionViewCell</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">removeMedia:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">removeMedia:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">removeMedia:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="albumNameLabel">UILabel</string>
<string key="artistNameLabel">UILabel</string>
<string key="mediaIsUnreadView">UIImageView</string>
<string key="progressView">VLCLinearProgressIndicator</string>
<string key="removeMediaButton">UIButton</string>
<string key="seriesNameLabel">UILabel</string>
<string key="subtitleLabel">UILabel</string>
<string key="thumbnailView">UIImageView</string>
<string key="titleLabel">UILabel</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="albumNameLabel">
<string key="name">albumNameLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="artistNameLabel">
<string key="name">artistNameLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="mediaIsUnreadView">
<string key="name">mediaIsUnreadView</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo" key="progressView">
<string key="name">progressView</string>
<string key="candidateClassName">VLCLinearProgressIndicator</string>
</object>
<object class="IBToOneOutletInfo" key="removeMediaButton">
<string key="name">removeMediaButton</string>
<string key="candidateClassName">UIButton</string>
</object>
<object class="IBToOneOutletInfo" key="seriesNameLabel">
<string key="name">seriesNameLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="subtitleLabel">
<string key="name">subtitleLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="thumbnailView">
<string key="name">thumbnailView</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo" key="titleLabel">
<string key="name">titleLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/VLCPlaylistCollectionViewCell.h</string>
</object>
</object>
</array>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">YES</bool>
......
//
// VLCGridViewCell.h
// AspenProject
//
// Created by Felix Paul Kühne on 11.04.13.
// Copyright (c) 2013 VideoLAN. All rights reserved.
//
// Refer to the COPYING file of the official project for license.
//
#import "AQGridViewCell.h"
@class AQGridView;
@class VLCLinearProgressIndicator;
@interface VLCPlaylistGridView : AQGridViewCell
@property (nonatomic, strong) IBOutlet UILabel *titleLabel;
@property (nonatomic, strong) IBOutlet UILabel *subtitleLabel;
@property (nonatomic, strong) IBOutlet UIImageView *thumbnailView;
@property (nonatomic, strong) IBOutlet VLCLinearProgressIndicator *progressView;
@property (nonatomic, strong) IBOutlet UIButton *removeMediaButton;
@property (nonatomic, strong) IBOutlet UIImageView *mediaIsUnreadView;
@property (nonatomic, strong) IBOutlet UILabel *seriesNameLabel;
@property (nonatomic, strong) IBOutlet UILabel *artistNameLabel;
@property (nonatomic, strong) IBOutlet UILabel *albumNameLabel;
// Temporary workaround: until better solution
@property (nonatomic, weak) AQGridView *gridView;
@property (nonatomic, retain) MLFile *mediaObject;
- (IBAction)removeMedia:(id)sender;
+ (CGSize)preferredSize;
@end
//
// VLCGridViewCell.m
// AspenProject
//
// Created by Felix Paul Kühne on 11.04.13.
// Copyright (c) 2013 VideoLAN. All rights reserved.
//
// Refer to the COPYING file of the official project for license.
//
#import "VLCPlaylistGridView.h"
#import "VLCLinearProgressIndicator.h"
#import "AQGridView.h"
#import "VLCThumbnailsCache.h"
@interface VLCPlaylistGridView (Hack)
@property (nonatomic, retain) NSString *reuseIdentifier;
@end
@implementation VLCPlaylistGridView
+ (CGSize)preferredSize
{
return CGSizeMake(288, 220);
}
- (void)awakeFromNib {
[super awakeFromNib];
_contentView = self;
self.backgroundColor = [UIColor clearColor];
self.reuseIdentifier = @"AQPlaylistCell";
self.albumNameLabel.text = self.artistNameLabel.text = self.seriesNameLabel.text = @"";
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
self.removeMediaButton.hidden = !editing;
[self _updatedDisplayedInformationForKeyPath:@"editing"];
}
- (void)prepareForReuse
{
[super prepareForReuse];
self.removeMediaButton.hidden = YES;
}
- (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 removeObserver:self forKeyPath:@"albumTrackNumber"];
[_mediaObject removeObserver:self forKeyPath:@"album"];
[_mediaObject removeObserver:self forKeyPath:@"artist"];
[_mediaObject removeObserver:self forKeyPath:@"genre"];
if ([_mediaObject respondsToSelector:@selector(didHide)])
[(MLFile*)_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 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];
if ([_mediaObject respondsToSelector:@selector(willDisplay)])
[(MLFile*)_mediaObject willDisplay];
}
[self _updatedDisplayedInformationForKeyPath:nil];
}
- (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
{
self.albumNameLabel.text = self.artistNameLabel.text = self.seriesNameLabel.text = @"";
if ([self.mediaObject isKindOfClass:[MLFile class]]) {
MLFile *mediaObject = self.mediaObject;
[self configureForMLFile:mediaObject];
if (([keyPath isEqualToString:@"computedThumbnail"] || !keyPath) && !mediaObject.isAlbumTrack) {
self.thumbnailView.image = [VLCThumbnailsCache thumbnailForMediaFile:mediaObject];
}
} else if ([self.mediaObject isKindOfClass:[MLAlbum class]]) {
MLAlbum *mediaObject = (MLAlbum *)self.mediaObject;
[self configureForAlbum:mediaObject];
} else if ([self.mediaObject isKindOfClass:[MLAlbumTrack class]]) {
MLAlbumTrack *mediaObject = (MLAlbumTrack *)self.mediaObject;
[self configureForAlbumTrack:mediaObject];
} else if ([self.mediaObject isKindOfClass:[MLShow class]]) {
MLShow *mediaObject = (MLShow *)self.mediaObject;
[self configureForShow:mediaObject];
if ([keyPath isEqualToString:@"computedThumbnail"] || !keyPath) {
MLFile *anyFileFromAnyEpisode = [mediaObject.episodes.anyObject files].anyObject;
self.thumbnailView.image = [VLCThumbnailsCache thumbnailForMediaFile:anyFileFromAnyEpisode];
}
} else if ([self.mediaObject isKindOfClass:[MLShowEpisode class]]) {
MLShowEpisode *mediaObject = (MLShowEpisode *)self.mediaObject;
[self configureForShowEpisode:mediaObject];
if ([keyPath isEqualToString:@"computedThumbnail"] || !keyPath) {
MLFile *anyFileFromEpisode = mediaObject.files.anyObject;
self.thumbnailView.image = [VLCThumbnailsCache thumbnailForMediaFile:anyFileFromEpisode];
}
}
[self setNeedsDisplay];
}
- (IBAction)removeMedia:(id)sender
{
/* ask user if s/he really wants to delete the media file */
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DELETE_FILE", @"") message:[NSString stringWithFormat:NSLocalizedString(@"DELETE_FILE_LONG", @""), self.mediaObject.title] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_DELETE", @""), nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
NSUInteger cellIndex = [self.gridView indexForCell:self];
[self.gridView.delegate gridView:self.gridView commitEditingStyle:UITableViewCellEditingStyleDelete forRowAtIndex:cellIndex];
}
}
#pragma mark - presentation
- (void)configureForShow:(MLShow *)show
{
self.titleLabel.text = show.name;
self.artistNameLabel.text = @"";
self.albumNameLabel.text = show.releaseYear;
NSUInteger count = show.episodes.count;
self.subtitleLabel.text = [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_EPISODES", @"") : NSLocalizedString(@"LIBRARY_SINGLE_EPISODE", @""), count, show.unreadEpisodes.count];
self.mediaIsUnreadView.hidden = YES;
self.progressView.hidden = YES;
}
- (void)configureForAlbumTrack:(MLAlbumTrack *)albumTrack
{
self.artistNameLabel.text = albumTrack.artist;
self.albumNameLabel.text = [NSString stringWithFormat:NSLocalizedString(@"LIBRARY_SINGLE_TRACK", @""), albumTrack.trackNumber.intValue];
self.titleLabel.text = albumTrack.title;
self.thumbnailView.image = nil;
MLFile *anyFileFromTrack = albumTrack.files.anyObject;
self.subtitleLabel.text = [NSString stringWithFormat:@"%@", [VLCTime timeWithNumber:[anyFileFromTrack duration]]];
CGFloat position = anyFileFromTrack.lastPosition.floatValue;
self.progressView.progress = position;
self.progressView.hidden = ((position < .1f) || (position > .95f)) ? YES : NO;
[self.progressView setNeedsDisplay];
self.mediaIsUnreadView.hidden = !anyFileFromTrack.unread.intValue;
}
- (void)configureForAlbum:(MLAlbum *)album
{
self.titleLabel.text = album.name;
MLAlbumTrack *anyTrack = [album.tracks anyObject];
self.artistNameLabel.text = anyTrack? anyTrack.artist: @"";
self.albumNameLabel.text = album.releaseYear;
self.thumbnailView.image = nil;
NSUInteger count = album.tracks.count;
self.subtitleLabel.text = [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_TRACKS", @"") : NSLocalizedString(@"LIBRARY_SINGLE_TRACK", @""), count];
self.mediaIsUnreadView.hidden = YES;
self.progressView.hidden = YES;
}
- (void)configureForShowEpisode:(MLShowEpisode *)showEpisode
{
MLFile *anyFileFromEpisode = showEpisode.files.anyObject;
self.titleLabel.text = showEpisode.name;
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]]];
CGFloat position = anyFileFromEpisode.lastPosition.floatValue;
self.progressView.progress = position;
self.progressView.hidden = ((position < .1f) || (position > .95f)) ? YES : NO;
[self.progressView setNeedsDisplay];
self.mediaIsUnreadView.hidden = !showEpisode.unread.intValue;
}
- (void)configureForMLFile:(MLFile *)mediaFile
{
if ([mediaFile isAlbumTrack]) {
self.artistNameLabel.text = mediaFile.albumTrack.artist;
self.albumNameLabel.text = mediaFile.albumTrack.album.name;
self.titleLabel.text = (mediaFile.albumTrack.title.length > 0) ? mediaFile.albumTrack.title : mediaFile.title;
self.thumbnailView.image = nil;
} else if ([mediaFile isShowEpisode]) {
MLShowEpisode *episode = mediaFile.showEpisode;
self.seriesNameLabel.text = episode.show.name;
self.titleLabel.text = (episode.name.length > 0) ? [NSString stringWithFormat:@"%@ - S%02dE%02d", episode.name, mediaFile.showEpisode.seasonNumber.intValue, episode.episodeNumber.intValue] : [NSString stringWithFormat:@"S%02dE%02d", episode.seasonNumber.intValue, episode.episodeNumber.intValue];
} else
self.titleLabel.text = mediaFile.title;
if (self.isEditing)
self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %i MB", [VLCTime timeWithNumber:[mediaFile duration]], (int)([mediaFile fileSizeInBytes] / 1e6)];
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];
}
}
CGFloat position = mediaFile.lastPosition.floatValue;
self.progressView.progress = position;
self.progressView.hidden = ((position < .1f) || (position > .95f)) ? YES : NO;
[self.progressView setNeedsDisplay];
self.mediaIsUnreadView.hidden = !mediaFile.unread.intValue;
}
@end
......@@ -20,7 +20,6 @@ typedef enum {
@class VLCMovieViewController;
@class EmptyLibraryView;
@class AQGridView;
@interface VLCPlaylistViewController : UIViewController <UITabBarDelegate, UIPopoverControllerDelegate>
......
......@@ -12,14 +12,11 @@
#import "VLCMovieViewController.h"
#import "VLCPlaylistTableViewCell.h"
#import "VLCPlaylistCollectionViewCell.h"
#import "VLCPlaylistGridView.h"
#import "UINavigationController+Theme.h"
#import "NSString+SupportedMedia.h"
#import "VLCBugreporter.h"
#import "VLCAppDelegate.h"
#import "UIBarButtonItem+Theme.h"
#import "AQGridView.h"
#ifndef UIStatusBarStyleLightContent
#define UIStatusBarStyleLightContent 1
......@@ -28,7 +25,7 @@
@implementation EmptyLibraryView
@end
@interface VLCPlaylistViewController () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, AQGridViewDataSource, AQGridViewDelegate, UITableViewDataSource, UITableViewDelegate, MLMediaLibrary> {
@interface VLCPlaylistViewController () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UITableViewDataSource, UITableViewDelegate, MLMediaLibrary> {
NSMutableArray *_foundMedia;
VLCLibraryMode _libraryMode;
UIBarButtonItem *_menuButton;
......@@ -36,7 +33,6 @@
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) AQGridView *gridView;
@property (nonatomic, strong) EmptyLibraryView *emptyLibraryView;
@end
......@@ -53,26 +49,16 @@
_tableView.dataSource = self;
self.view = _tableView;
} else {
if ([UICollectionView class]) {
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:flowLayout];
_collectionView.alwaysBounceVertical = YES;
_collectionView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_collectionView.delegate = self;
_collectionView.dataSource = self;
self.view = _collectionView;
[_collectionView registerNib:[UINib nibWithNibName:@"VLCPlaylistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"PlaylistCell"];
} else {
_gridView = [[AQGridView alloc] initWithFrame:[UIScreen mainScreen].bounds];
_gridView.separatorStyle = AQGridViewCellSeparatorStyleEmptySpace;
_gridView.alwaysBounceVertical = YES;
_gridView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_gridView.delegate = self;
_gridView.dataSource = self;
self.view = _gridView;
}
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:flowLayout];
_collectionView.alwaysBounceVertical = YES;
_collectionView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_collectionView.delegate = self;
_collectionView.dataSource = self;
self.view = _collectionView;
[_collectionView registerNib:[UINib nibWithNibName:@"VLCPlaylistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"PlaylistCell"];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"libraryBackground"]];
}
......@@ -287,12 +273,8 @@
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
[self.tableView reloadData];
else {
if ([UICollectionView class])
[self.collectionView reloadData];
else
[self.gridView reloadData];
}
else
[self.collectionView reloadData];
[self _displayEmptyLibraryViewIfNeeded];
}
......@@ -380,46 +362,6 @@
[self openMediaObject:selectedObject];
}
#pragma mark - AQGridView
- (NSUInteger)numberOfItemsInGridView:(AQGridView *)gridView
{
return _foundMedia.count;
}
- (AQGridViewCell *)gridView:(AQGridView *)gridView cellForItemAtIndex:(NSUInteger)index
{
static NSString *AQCellIdentifier = @"AQPlaylistCell";
VLCPlaylistGridView *cell = (VLCPlaylistGridView *)[gridView dequeueReusableCellWithIdentifier:AQCellIdentifier];
if (cell == nil) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"VLCPlaylistGridView" owner:self options:nil] lastObject];
cell.selectionStyle = AQGridViewCellSelectionStyleNone;
cell.gridView = gridView;
}
cell.mediaObject = _foundMedia[index];
return cell;
}
- (CGSize)portraitGridCellSizeForGridView:(AQGridView *)gridView
{
return [VLCPlaylistGridView preferredSize];
}
- (void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index
{
[self.gridView deselectItemAtIndex:index animated:YES];
NSManagedObject *selectedObject = _foundMedia[index];
[self openMediaObject:selectedObject];
}
- (void)gridView:(AQGridView *)aGridView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndex:(NSUInteger)index
{
if (editingStyle == UITableViewCellEditingStyleDelete)
[self removeMediaObject: _foundMedia[index]];
}
#pragma mark - UI implementation
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
......@@ -442,18 +384,13 @@
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
if ([UICollectionView class]) {
NSArray *visibleCells = self.collectionView.visibleCells;
NSArray *visibleCells = self.collectionView.visibleCells;
[visibleCells enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
VLCPlaylistCollectionViewCell *aCell = (VLCPlaylistCollectionViewCell*)obj;
[visibleCells enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
VLCPlaylistCollectionViewCell *aCell = (VLCPlaylistCollectionViewCell*)obj;
[aCell setEditing:editing animated:animated];
}];
}
else {
[self.gridView setEditing:editing];
}
[aCell setEditing:editing animated:animated];
}];
} else
[self.tableView setEditing:editing animated:YES];
}
......