VLCCloudStorageTVTableViewController.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*****************************************************************************
  2. * VLC for iOS
  3. *****************************************************************************
  4. * Copyright (c) 2015 VideoLAN. All rights reserved.
  5. * $Id$
  6. *
  7. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. #import "VLCCloudStorageTVTableViewController.h"
  12. #import "VLCCloudStorageTableViewCell.h"
  13. @implementation VLCCloudStorageTVTableViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.tableView.rowHeight = [VLCCloudStorageTableViewCell heightOfCell];
  17. self.tableView.backgroundColor = [UIColor VLCLightTextColor];
  18. _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
  19. _activityIndicator.hidesWhenStopped = YES;
  20. _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
  21. [self.view addSubview:_activityIndicator];
  22. [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
  23. [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
  24. }
  25. - (void)mediaListUpdated
  26. {
  27. [_activityIndicator stopAnimating];
  28. [self.tableView reloadData];
  29. }
  30. - (void)updateViewAfterSessionChange
  31. {
  32. if (![self.controller isAuthorized]) {
  33. [_activityIndicator stopAnimating];
  34. return;
  35. }
  36. //reload if we didn't come back from streaming
  37. if (self.currentPath == nil)
  38. self.currentPath = @"";
  39. if([self.controller.currentListFiles count] == 0)
  40. [self requestInformationForCurrentPath];
  41. }
  42. - (void)requestInformationForCurrentPath
  43. {
  44. [_activityIndicator startAnimating];
  45. [self.controller requestDirectoryListingAtPath:self.currentPath];
  46. [_activityIndicator stopAnimating];
  47. }
  48. #pragma mark - Table view data source
  49. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  50. {
  51. return 1;
  52. }
  53. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  54. {
  55. return self.controller.currentListFiles.count;
  56. }
  57. @end