Selaa lähdekoodia

Library: improve drawing performance when switching isEditing

Felix Paul Kühne 12 vuotta sitten
vanhempi
commit
9d8d311f34
2 muutettua tiedostoa jossa 12 lisäystä ja 11 poistoa
  1. 6 6
      AspenProject/VLCPlaylistGridView.m
  2. 6 5
      AspenProject/VLCPlaylistTableViewCell.m

+ 6 - 6
AspenProject/VLCPlaylistGridView.m

@@ -34,8 +34,7 @@
 {
     [super setEditing:editing animated:animated];
     self.removeMediaButton.hidden = !editing;
-    [self _updatedDisplayedInformation];
-
+    [self _updatedDisplayedInformationForKeyPath:@"editing"];
 }
 
 - (void)prepareForReuse
@@ -46,7 +45,7 @@
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
 {
-    [self _updatedDisplayedInformation];
+    [self _updatedDisplayedInformationForKeyPath:keyPath];
 }
 
 - (void)setMediaObject:(MLFile *)mediaObject
@@ -73,10 +72,10 @@
         [_mediaObject willDisplay];
     }
 
-    [self _updatedDisplayedInformation];
+    [self _updatedDisplayedInformationForKeyPath:NULL];
 }
 
-- (void)_updatedDisplayedInformation
+- (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
 {
     self.titleLabel.text = self.mediaObject.title;
     if (self.isEditing)
@@ -86,7 +85,8 @@
         if (self.mediaObject.videoTrack)
             self.subtitleLabel.text = [self.subtitleLabel.text stringByAppendingFormat:@" — %@x%@", [[self.mediaObject videoTrack] valueForKey:@"width"], [[self.mediaObject videoTrack] valueForKey:@"height"]];
     }
-    self.thumbnailView.image = self.mediaObject.computedThumbnail;
+    if ([keyPath isEqualToString:@"computedThumbnail"] || !keyPath)
+        self.thumbnailView.image = self.mediaObject.computedThumbnail;
     self.progressView.progress = self.mediaObject.lastPosition.floatValue;
 
     self.progressView.hidden = (self.progressView.progress < .1f || .95f) ? YES : NO;

+ 6 - 5
AspenProject/VLCPlaylistTableViewCell.m

@@ -24,7 +24,7 @@
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
 {
-    [self _updatedDisplayedInformation];
+    [self _updatedDisplayedInformationForKeyPath:keyPath];
 }
 
 - (void)setMediaObject:(MLFile *)mediaObject
@@ -51,16 +51,16 @@
         [_mediaObject willDisplay];
     }
 
-    [self _updatedDisplayedInformation];
+    [self _updatedDisplayedInformationForKeyPath:NULL];
 }
 
 - (void)setEditing:(BOOL)editing animated:(BOOL)animated
 {
     [super setEditing:editing animated:animated];
-    [self _updatedDisplayedInformation];
+    [self _updatedDisplayedInformationForKeyPath:@"editing"];
 }
 
-- (void)_updatedDisplayedInformation
+- (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
 {
     self.titleLabel.text = self.mediaObject.title;
     if (self.isEditing)
@@ -70,7 +70,8 @@
         if (self.mediaObject.videoTrack)
             self.subtitleLabel.text = [self.subtitleLabel.text stringByAppendingFormat:@" — %@x%@", [[self.mediaObject videoTrack] valueForKey:@"width"], [[self.mediaObject videoTrack] valueForKey:@"height"]];
     }
-    self.thumbnailView.image = self.mediaObject.computedThumbnail;
+    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;