Commit 4b3cc441 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
parent 5c6cfb36
......@@ -319,6 +319,9 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_trackSelectorTableView.dataSource = self;
_trackSelectorTableView.separatorColor = [UIColor clearColor];
_trackSelectorTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_trackSelectorTableView.rowHeight = 44.;
_trackSelectorTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_trackSelectorTableView.sectionHeaderHeight = 28.;
[_trackSelectorTableView registerClass:[VLCTrackSelectorTableViewCell class] forCellReuseIdentifier:TRACK_SELECTOR_TABLEVIEW_CELL];
[_trackSelectorTableView registerClass:[VLCTrackSelectorHeaderView class] forHeaderFooterViewReuseIdentifier:TRACK_SELECTOR_TABLEVIEW_SECTIONHEADER];
_trackSelectorTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
......@@ -883,10 +886,11 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
if (_trackSelectorContainer.hidden == YES || _switchingTracksNotChapters == NO) {
_switchingTracksNotChapters = YES;
[_trackSelectorTableView reloadData];
_trackSelectorContainer.hidden = NO;
_trackSelectorContainer.alpha = 1.;
[_trackSelectorTableView reloadData];
if (!_playbackSpeedViewHidden)
self.playbackSpeedView.hidden = _playbackSpeedViewHidden = YES;
......@@ -1128,7 +1132,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (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)
cell = [[VLCTrackSelectorTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TRACK_SELECTOR_TABLEVIEW_CELL];
......@@ -1136,25 +1140,22 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
NSInteger row = indexPath.row;
NSInteger section = indexPath.section;
VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
BOOL cellShowsCurrentTrack = NO;
if (_switchingTracksNotChapters == YES) {
NSArray *indexArray;
if (mediaPlayer.audioTrackIndexes.count > 2 && section == 0) {
if ([mediaPlayer numberOfAudioTracks] > 2 && section == 0) {
indexArray = mediaPlayer.audioTrackIndexes;
if ([indexArray indexOfObjectIdenticalTo:[NSNumber numberWithUnsignedInteger:mediaPlayer.currentAudioTrackIndex]] == row)
[cell setShowsCurrentTrack:YES];
else
[cell setShowsCurrentTrack:NO];
if ([indexArray indexOfObject:[NSNumber numberWithInt:mediaPlayer.currentAudioTrackIndex]] == row)
cellShowsCurrentTrack = YES;
cell.textLabel.text = [NSString stringWithFormat:@"%@", mediaPlayer.audioTrackNames[row]];
} else {
indexArray = mediaPlayer.videoSubTitlesIndexes;
if ([indexArray indexOfObjectIdenticalTo:[NSNumber numberWithUnsignedInteger:mediaPlayer.currentVideoSubTitleIndex]] == row)
[cell setShowsCurrentTrack:YES];
else
[cell setShowsCurrentTrack:NO];
if ([indexArray indexOfObject:[NSNumber numberWithInt:mediaPlayer.currentVideoSubTitleIndex]] == row)
cellShowsCurrentTrack = YES;
cell.textLabel.text = [NSString stringWithFormat:@"%@", mediaPlayer.videoSubTitlesNames[row]];
}
......@@ -1163,18 +1164,15 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
cell.textLabel.text = mediaPlayer.titles[row];
if (row == mediaPlayer.currentTitleIndex)
[cell setShowsCurrentTrack:YES];
else
[cell setShowsCurrentTrack:NO];
cellShowsCurrentTrack = YES;
} else {
cell.textLabel.text = [mediaPlayer chaptersForTitleIndex:mediaPlayer.currentTitleIndex][row];
if (row == mediaPlayer.currentChapterIndex)
[cell setShowsCurrentTrack:YES];
else
[cell setShowsCurrentTrack:NO];
cellShowsCurrentTrack = YES;
}
}
[cell setShowsCurrentTrack:cellShowsCurrentTrack];
return cell;
}
......
......@@ -2,7 +2,7 @@
* VLCTrackSelectorTableViewCell.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved.
* Copyright (c) 2014-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -14,16 +14,6 @@
@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
{
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