浏览代码

TrackSelctorTableViewCell: setShowsCurrentTrack should only be called for when we have the current track

Carola Nitz 7 年之前
父节点
当前提交
8cdc43db12

+ 1 - 3
Sources/VLCEqualizerView.m

@@ -332,9 +332,7 @@
     unsigned int profile = (unsigned int)[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingEqualizerProfile] integerValue];
 
     if (profile == row)
-        [cell setShowsCurrentTrack:YES];
-    else
-        [cell setShowsCurrentTrack:NO];
+        [cell setShowsCurrentTrack];
 
     return cell;
 }

+ 1 - 1
Sources/VLCTrackSelectorTableViewCell.h

@@ -14,6 +14,6 @@
 
 @interface VLCTrackSelectorTableViewCell : UITableViewCell
 
-- (void)setShowsCurrentTrack:(BOOL)value;
+- (void)setShowsCurrentTrack;
 
 @end

+ 10 - 8
Sources/VLCTrackSelectorTableViewCell.m

@@ -14,15 +14,17 @@
 
 @implementation VLCTrackSelectorTableViewCell
 
-- (void)setShowsCurrentTrack:(BOOL)value
+- (void)setShowsCurrentTrack
 {
-    if (value) {
-        self.backgroundColor = [UIColor VLCLightTextColor];
-        self.textLabel.textColor = [UIColor VLCDarkBackgroundColor];
-    } else {
-        self.backgroundColor = [UIColor clearColor];
-        self.textLabel.textColor = [UIColor VLCLightTextColor];
-    }
+    self.backgroundColor = [UIColor VLCLightTextColor];
+    self.textLabel.textColor = [UIColor VLCDarkBackgroundColor];
 }
 
+- (void)prepareForReuse
+{
+    [super prepareForReuse];
+
+    self.backgroundColor = [UIColor clearColor];
+    self.textLabel.textColor = [UIColor VLCLightTextColor];
+}
 @end

+ 4 - 6
Sources/VLCTrackSelectorView.m

@@ -148,7 +148,6 @@
     NSInteger row = indexPath.row;
     NSInteger section = indexPath.section;
     VLCMediaPlayer *mediaPlayer =  [VLCPlaybackController sharedInstance].mediaPlayer;
-    BOOL cellShowsCurrentTrack = NO;
 
     if (_switchingTracksNotChapters) {
         NSArray *indexArray;
@@ -157,7 +156,7 @@
             indexArray = mediaPlayer.audioTrackIndexes;
 
             if ([indexArray indexOfObject:[NSNumber numberWithInt:mediaPlayer.currentAudioTrackIndex]] == row)
-                cellShowsCurrentTrack = YES;
+                [cell setShowsCurrentTrack];
 
             NSArray *audioTrackNames = mediaPlayer.audioTrackNames;
             if (row < audioTrackNames.count) {
@@ -167,7 +166,7 @@
             indexArray = mediaPlayer.videoSubTitlesIndexes;
 
             if ([indexArray indexOfObject:[NSNumber numberWithInt:mediaPlayer.currentVideoSubTitleIndex]] == row)
-                cellShowsCurrentTrack = YES;
+                [cell setShowsCurrentTrack];
 
             NSArray *videoSubtitlesNames = mediaPlayer.videoSubTitlesNames;
             if (row < videoSubtitlesNames.count) {
@@ -191,7 +190,7 @@
             }
 
             if (row == mediaPlayer.currentTitleIndex)
-                cellShowsCurrentTrack = YES;
+                [cell setShowsCurrentTrack];
         } else {
             NSArray *chapterDescriptions = [mediaPlayer chapterDescriptionsOfTitle:mediaPlayer.currentTitleIndex];
             if (row < chapterDescriptions.count) {
@@ -200,10 +199,9 @@
             }
 
             if (row == mediaPlayer.currentChapterIndex)
-                cellShowsCurrentTrack = YES;
+                [cell setShowsCurrentTrack];
         }
     }
-    [cell setShowsCurrentTrack:cellShowsCurrentTrack];
 
     return cell;
 }