Skip to content

Commit

Permalink
Add reverse list handling
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedc committed Aug 17, 2022
1 parent e88af7b commit 9802951
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Apple-TV/VLCOpenNetworkStreamTVViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"RecentlyPlayedURLsTableViewCell"];
}

NSString *content = [_recentURLs[indexPath.row] stringByRemovingPercentEncoding];
NSString *possibleTitle = _recentURLTitles[[@(indexPath.row) stringValue]];
NSInteger index = newestFirst ? _recentURLs.count - 1 - indexPath.row : indexPath.row;
NSString *content = [_recentURLs[index] stringByRemovingPercentEncoding];
NSString *possibleTitle = _recentURLTitles[[@(index) stringValue]];

cell.detailTextLabel.text = content;
cell.textLabel.text = (possibleTitle != nil) ? possibleTitle : [content lastPathComponent];
Expand All @@ -124,7 +125,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.previouslyPlayedStreamsTableView deselectRowAtIndexPath:indexPath animated:NO];
[self _openURLStringAndDismiss:_recentURLs[indexPath.row]];
NSInteger index = newestFirst ? _recentURLs.count - 1 - indexPath.row : indexPath.row;
[self _openURLStringAndDismiss:_recentURLs[index]];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
Expand Down Expand Up @@ -212,12 +214,13 @@ - (void)emptyListAction:(id)sender
- (IBAction)reverseListSortingAction:(id)sender
{
newestFirst = !newestFirst;

if (newestFirst) {
self.reverseListSortingButton.transform = CGAffineTransformMakeRotation( M_PI );
} else {
self.reverseListSortingButton.transform = CGAffineTransformIdentity;
}

[self.previouslyPlayedStreamsTableView reloadData];
}

#pragma mark - editing
Expand All @@ -237,7 +240,7 @@ - (NSString *)itemToDelete

NSString *ret = nil;
@synchronized(_recentURLs) {
NSInteger index = indexPathToDelete.item;
NSInteger index = newestFirst ? _recentURLs.count - 1 - indexPathToDelete.item : indexPathToDelete.item;
if (index < _recentURLs.count) {
ret = _recentURLs[index];
}
Expand Down

0 comments on commit 9802951

Please sign in to comment.