CCControlCenterActivity.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. //
  2. // CCControlCenterActivity.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 01/03/17.
  6. // Copyright © 2017 TWS. All rights reserved.
  7. //
  8. #import "CCControlCenterActivity.h"
  9. #import "AppDelegate.h"
  10. #import "CCControlCenterActivityCell.h"
  11. @interface CCControlCenterActivity ()
  12. {
  13. // Datasource
  14. NSArray *_sectionDataSource;
  15. }
  16. @end
  17. @implementation CCControlCenterActivity
  18. #pragma --------------------------------------------------------------------------------------------
  19. #pragma mark ===== Init =====
  20. #pragma --------------------------------------------------------------------------------------------
  21. - (id)initWithCoder:(NSCoder *)aDecoder
  22. {
  23. if (self = [super initWithCoder:aDecoder]) {
  24. app.controlCenterActivity = self;
  25. }
  26. return self;
  27. }
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. _sectionDataSource = [NSArray new];
  31. // empty Data Source
  32. /*
  33. _tableView.delegate = self;
  34. _tableView.dataSource = self;
  35. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  36. _tableView.backgroundColor = [UIColor clearColor];
  37. */
  38. }
  39. // Apparirà
  40. - (void)viewWillAppear:(BOOL)animated
  41. {
  42. [super viewWillAppear:animated];
  43. [self reloadDatasource];
  44. }
  45. // E' arrivato
  46. - (void)viewDidAppear:(BOOL)animated
  47. {
  48. [super viewDidAppear:animated];
  49. }
  50. - (void)didReceiveMemoryWarning {
  51. [super didReceiveMemoryWarning];
  52. }
  53. #pragma --------------------------------------------------------------------------------------------
  54. #pragma mark - ==== Datasource ====
  55. #pragma --------------------------------------------------------------------------------------------
  56. - (void)reloadDatasource
  57. {
  58. // test
  59. if (app.activeAccount.length == 0)
  60. return;
  61. if (app.controlCenter.isOpen) {
  62. _sectionDataSource = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
  63. if ([_sectionDataSource count] == 0) {
  64. app.controlCenter.noRecord.text = NSLocalizedString(@"_no_activity_",nil);
  65. app.controlCenter.noRecord.hidden = NO;
  66. } else {
  67. app.controlCenter.noRecord.hidden = YES;
  68. }
  69. }
  70. [self.collectionView reloadData];
  71. [app updateApplicationIconBadgeNumber];
  72. }
  73. #pragma --------------------------------------------------------------------------------------------
  74. #pragma mark - ==== Table ====
  75. #pragma --------------------------------------------------------------------------------------------
  76. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  77. {
  78. return 50;
  79. }
  80. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  81. {
  82. return 1;
  83. }
  84. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  85. {
  86. return [_sectionDataSource count];
  87. }
  88. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  89. {
  90. UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
  91. /*
  92. cell.backgroundColor = [UIColor clearColor];
  93. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  94. TableActivity *activity = [_sectionDataSource objectAtIndex:indexPath.row];
  95. cell.labelTitle.text = activity.subject;
  96. cell.labelInfoFile.text = [CCUtility dateDiff:activity.date];
  97. */
  98. return cell;
  99. }
  100. @end