[vlc-commits] macosx/library collection view item: implement prepareForReuse

Felix Paul Kühne git at videolan.org
Thu May 16 16:33:24 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Thu May 16 16:29:54 2019 +0200| [fe552c29411838bded88836155405cf1b8cca736] | committer: Felix Paul Kühne

macosx/library collection view item: implement prepareForReuse

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fe552c29411838bded88836155405cf1b8cca736
---

 .../macosx/library/VLCLibraryCollectionViewItem.m  | 29 ++++++++++++++--------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
index d2457114a9..d06c0728b2 100644
--- a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
+++ b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
@@ -52,7 +52,9 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
 {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     if (self) {
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mediaItemUpdated:) name:VLCLibraryModelMediaItemUpdated object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self
+                                                 selector:@selector(mediaItemUpdated:)
+                                                     name:VLCLibraryModelMediaItemUpdated object:nil];
     }
     return self;
 }
@@ -67,7 +69,6 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
 
 - (void)awakeFromNib
 {
-    self.playInstantlyButton.hidden = YES;
     [(VLCTrackingView *)self.view setViewToHide:self.playInstantlyButton];
     self.mediaTitleTextField.font = [NSFont VLClibraryCellTitleFont];
     self.durationTextField.font = [NSFont VLClibraryCellSubtitleFont];
@@ -87,6 +88,7 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
     }
 
     [self updateColoredAppearance];
+    [self prepareForReuse];
 }
 
 - (void)observeValueForKeyPath:(NSString *)keyPath
@@ -104,6 +106,18 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
 
 #pragma mark - view representation
 
+- (void)prepareForReuse
+{
+    [super prepareForReuse];
+    _playInstantlyButton.hidden = YES;
+    _mediaTitleTextField.stringValue = @"";
+    _durationTextField.stringValue = [NSString stringWithTime:0];
+    _mediaImageView.image = nil;
+    _annotationTextField.hidden = YES;
+    _progressIndicator.hidden = YES;
+    _unplayedIndicatorTextField.hidden = YES;
+}
+
 - (void)setRepresentedMediaItem:(VLCMediaLibraryMediaItem *)representedMediaItem
 {
     if (!_libraryController) {
@@ -128,9 +142,6 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
 - (void)updateRepresentation
 {
     if (_representedMediaItem == nil) {
-        _mediaTitleTextField.stringValue = @"";
-        _durationTextField.stringValue = [NSString stringWithTime:0];
-        _mediaImageView.image = [NSImage imageNamed: @"noart.png"];
         return;
     }
 
@@ -159,19 +170,17 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
     } else if (width >= VLCMediaLibrary720pWidth || height >= VLCMediaLibrary720pHeight) {
         _annotationTextField.stringValue = @" HD ";
         _annotationTextField.hidden = NO;
-    } else {
-        _annotationTextField.hidden = YES;
     }
 
     CGFloat position = _representedMediaItem.lastPlaybackPosition;
     if (position > VLCLibraryCollectionViewItemMinimalDisplayedProgress && position < VLCLibraryCollectionViewItemMaximumDisplayedProgress) {
         _progressIndicator.progress = position;
         _progressIndicator.hidden = NO;
-    } else {
-        _progressIndicator.hidden = YES;
     }
 
-    _unplayedIndicatorTextField.hidden = _representedMediaItem.playCount > 0 ? YES : NO;
+    if (_representedMediaItem.playCount == 0) {
+        _unplayedIndicatorTextField.hidden = NO;
+    }
 }
 
 #pragma mark - actions



More information about the vlc-commits mailing list