Commit 72d7f763 authored by Felix Paul Kühne's avatar Felix Paul Kühne

movie view: make sure the track selector always shows the current selection (close #14628)

cleanup

(cherry picked from commit 4b3cc441)
parent f3eaf692
...@@ -341,6 +341,9 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -341,6 +341,9 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_trackSelectorTableView.dataSource = self; _trackSelectorTableView.dataSource = self;
_trackSelectorTableView.separatorColor = [UIColor clearColor]; _trackSelectorTableView.separatorColor = [UIColor clearColor];
_trackSelectorTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite; _trackSelectorTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_trackSelectorTableView.rowHeight = 44.;
_trackSelectorTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_trackSelectorTableView.sectionHeaderHeight = 28.;
[_trackSelectorTableView registerClass:[VLCTrackSelectorTableViewCell class] forCellReuseIdentifier:TRACK_SELECTOR_TABLEVIEW_CELL]; [_trackSelectorTableView registerClass:[VLCTrackSelectorTableViewCell class] forCellReuseIdentifier:TRACK_SELECTOR_TABLEVIEW_CELL];
[_trackSelectorTableView registerClass:[VLCTrackSelectorHeaderView class] forHeaderFooterViewReuseIdentifier:TRACK_SELECTOR_TABLEVIEW_SECTIONHEADER]; [_trackSelectorTableView registerClass:[VLCTrackSelectorHeaderView class] forHeaderFooterViewReuseIdentifier:TRACK_SELECTOR_TABLEVIEW_SECTIONHEADER];
_trackSelectorTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; _trackSelectorTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
...@@ -906,10 +909,11 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -906,10 +909,11 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
if (_trackSelectorContainer.hidden == YES || _switchingTracksNotChapters == NO) { if (_trackSelectorContainer.hidden == YES || _switchingTracksNotChapters == NO) {
_switchingTracksNotChapters = YES; _switchingTracksNotChapters = YES;
[_trackSelectorTableView reloadData];
_trackSelectorContainer.hidden = NO; _trackSelectorContainer.hidden = NO;
_trackSelectorContainer.alpha = 1.; _trackSelectorContainer.alpha = 1.;
[_trackSelectorTableView reloadData];
if (!_playbackSpeedViewHidden) if (!_playbackSpeedViewHidden)
self.playbackSpeedView.hidden = _playbackSpeedViewHidden = YES; self.playbackSpeedView.hidden = _playbackSpeedViewHidden = YES;
...@@ -1158,7 +1162,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1158,7 +1162,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
VLCTrackSelectorTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TRACK_SELECTOR_TABLEVIEW_CELL forIndexPath:indexPath]; VLCTrackSelectorTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TRACK_SELECTOR_TABLEVIEW_CELL];
if (!cell) if (!cell)
cell = [[VLCTrackSelectorTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TRACK_SELECTOR_TABLEVIEW_CELL]; cell = [[VLCTrackSelectorTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TRACK_SELECTOR_TABLEVIEW_CELL];
...@@ -1166,25 +1170,22 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1166,25 +1170,22 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
NSInteger row = indexPath.row; NSInteger row = indexPath.row;
NSInteger section = indexPath.section; NSInteger section = indexPath.section;
VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer; VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
BOOL cellShowsCurrentTrack = NO;
if (_switchingTracksNotChapters == YES) { if (_switchingTracksNotChapters == YES) {
NSArray *indexArray; NSArray *indexArray;
if (mediaPlayer.audioTrackIndexes.count > 2 && section == 0) { if ([mediaPlayer numberOfAudioTracks] > 2 && section == 0) {
indexArray = mediaPlayer.audioTrackIndexes; indexArray = mediaPlayer.audioTrackIndexes;
if ([indexArray indexOfObjectIdenticalTo:[NSNumber numberWithUnsignedInteger:mediaPlayer.currentAudioTrackIndex]] == row) if ([indexArray indexOfObject:[NSNumber numberWithInt:mediaPlayer.currentAudioTrackIndex]] == row)
[cell setShowsCurrentTrack:YES]; cellShowsCurrentTrack = YES;
else
[cell setShowsCurrentTrack:NO];
cell.textLabel.text = [NSString stringWithFormat:@"%@", mediaPlayer.audioTrackNames[row]]; cell.textLabel.text = [NSString stringWithFormat:@"%@", mediaPlayer.audioTrackNames[row]];
} else { } else {
indexArray = mediaPlayer.videoSubTitlesIndexes; indexArray = mediaPlayer.videoSubTitlesIndexes;
if ([indexArray indexOfObjectIdenticalTo:[NSNumber numberWithUnsignedInteger:mediaPlayer.currentVideoSubTitleIndex]] == row) if ([indexArray indexOfObject:[NSNumber numberWithInt:mediaPlayer.currentVideoSubTitleIndex]] == row)
[cell setShowsCurrentTrack:YES]; cellShowsCurrentTrack = YES;
else
[cell setShowsCurrentTrack:NO];
cell.textLabel.text = [NSString stringWithFormat:@"%@", mediaPlayer.videoSubTitlesNames[row]]; cell.textLabel.text = [NSString stringWithFormat:@"%@", mediaPlayer.videoSubTitlesNames[row]];
} }
...@@ -1193,18 +1194,15 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1193,18 +1194,15 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
cell.textLabel.text = mediaPlayer.titles[row]; cell.textLabel.text = mediaPlayer.titles[row];
if (row == mediaPlayer.currentTitleIndex) if (row == mediaPlayer.currentTitleIndex)
[cell setShowsCurrentTrack:YES]; cellShowsCurrentTrack = YES;
else
[cell setShowsCurrentTrack:NO];
} else { } else {
cell.textLabel.text = [mediaPlayer chaptersForTitleIndex:mediaPlayer.currentTitleIndex][row]; cell.textLabel.text = [mediaPlayer chaptersForTitleIndex:mediaPlayer.currentTitleIndex][row];
if (row == mediaPlayer.currentChapterIndex) if (row == mediaPlayer.currentChapterIndex)
[cell setShowsCurrentTrack:YES]; cellShowsCurrentTrack = YES;
else
[cell setShowsCurrentTrack:NO];
} }
} }
[cell setShowsCurrentTrack:cellShowsCurrentTrack];
return cell; return cell;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* VLCTrackSelectorTableViewCell.m * VLCTrackSelectorTableViewCell.m
* VLC for iOS * VLC for iOS
***************************************************************************** *****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved. * Copyright (c) 2014-2015 VideoLAN. All rights reserved.
* $Id$ * $Id$
* *
* Authors: Felix Paul Kühne <fkuehne # videolan.org> * Authors: Felix Paul Kühne <fkuehne # videolan.org>
...@@ -14,16 +14,6 @@ ...@@ -14,16 +14,6 @@
@implementation VLCTrackSelectorTableViewCell @implementation VLCTrackSelectorTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (!self)
return self;
return self;
}
- (void)setShowsCurrentTrack:(BOOL)value - (void)setShowsCurrentTrack:(BOOL)value
{ {
if (value) { if (value) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment