123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // CCControlCenterActivity.m
- // Nextcloud
- //
- // Created by Marino Faggiana on 01/03/17.
- // Copyright © 2017 TWS. All rights reserved.
- //
- #import "CCControlCenterActivity.h"
- #import "AppDelegate.h"
- #import "CCControlCenterActivityCell.h"
- @interface CCControlCenterActivity ()
- {
- // Datasource
- NSArray *_sectionDataSource;
- }
- @end
- @implementation CCControlCenterActivity
- #pragma --------------------------------------------------------------------------------------------
- #pragma mark ===== Init =====
- #pragma --------------------------------------------------------------------------------------------
- - (id)initWithCoder:(NSCoder *)aDecoder
- {
- if (self = [super initWithCoder:aDecoder]) {
-
- app.controlCenterActivity = self;
- }
- return self;
- }
- - (void)viewDidLoad {
-
- [super viewDidLoad];
-
- _sectionDataSource = [NSArray new];
-
- // Custom Cell
- [_tableView registerNib:[UINib nibWithNibName:@"CCControlCenterActivityCell" bundle:nil] forCellReuseIdentifier:@"ControlCenterActivityCell"];
-
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.backgroundColor = [UIColor clearColor];
- }
- // Apparirà
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
- [self reloadDatasource];
- }
- // E' arrivato
- - (void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- }
- - (void)didReceiveMemoryWarning {
-
- [super didReceiveMemoryWarning];
- }
- #pragma --------------------------------------------------------------------------------------------
- #pragma mark - ==== Datasource ====
- #pragma --------------------------------------------------------------------------------------------
- - (void)reloadDatasource
- {
- // test
- if (app.activeAccount.length == 0)
- return;
-
- if (app.controlCenter.isOpen) {
-
- _sectionDataSource = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
-
- if ([_sectionDataSource count] == 0) {
-
- app.controlCenter.noRecord.text = NSLocalizedString(@"_no_recent_",nil);
- app.controlCenter.noRecord.hidden = NO;
-
- } else {
-
- app.controlCenter.noRecord.hidden = YES;
- }
- }
-
- [_tableView reloadData];
-
- [app updateApplicationIconBadgeNumber];
- }
- #pragma --------------------------------------------------------------------------------------------
- #pragma mark - ==== Table ====
- #pragma --------------------------------------------------------------------------------------------
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 50;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_sectionDataSource count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- CCControlCenterActivityCell *cell = (CCControlCenterActivityCell *)[tableView dequeueReusableCellWithIdentifier:@"ControlCenterActivityCell" forIndexPath:indexPath];
- cell.backgroundColor = [UIColor clearColor];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
-
- TableActivity *activity = [_sectionDataSource objectAtIndex:indexPath.row];
- cell.labelTitle.text = activity.subject;
- cell.labelInfoFile.text = [CCUtility dateDiff:activity.date];
-
- return cell;
- }
- @end
|