VLCCloudStorageTVViewController.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "VLCCloudStorageTVViewController.h"
  12. @interface VLCCloudStorageTVViewController ()
  13. @end
  14. @implementation VLCCloudStorageTVViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
  18. _activityIndicator.hidesWhenStopped = YES;
  19. _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
  20. [self.view addSubview:_activityIndicator];
  21. [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
  22. [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
  23. }
  24. - (void)mediaListUpdated
  25. {
  26. [_activityIndicator stopAnimating];
  27. [self.collectionView reloadData];
  28. }
  29. - (void)updateViewAfterSessionChange
  30. {
  31. if (![self.controller isAuthorized]) {
  32. [_activityIndicator stopAnimating];
  33. return;
  34. }
  35. //reload if we didn't come back from streaming
  36. if (self.currentPath == nil)
  37. self.currentPath = @"";
  38. if([self.controller.currentListFiles count] == 0)
  39. [self requestInformationForCurrentPath];
  40. }
  41. - (void)requestInformationForCurrentPath
  42. {
  43. [_activityIndicator startAnimating];
  44. [self.controller requestDirectoryListingAtPath:self.currentPath];
  45. [_activityIndicator stopAnimating];
  46. }
  47. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
  48. {
  49. return 1;
  50. }
  51. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  52. {
  53. return self.controller.currentListFiles.count;
  54. }
  55. @end