From b9b0fd6e4bcf68daaa8861967020297b5f96e32c Mon Sep 17 00:00:00 2001 From: lilthree <87437904@qq.com> Date: Thu, 28 Dec 2017 00:24:50 +0800 Subject: [PATCH] improve settingController scroll performance --- seafile/SeafSettingsViewController.m | 21 ++++++------------ seafile/en.lproj/FolderView_iPad.storyboard | 20 ++++++++--------- seafile/en.lproj/FolderView_iPhone.storyboard | 22 +++++++++---------- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/seafile/SeafSettingsViewController.m b/seafile/SeafSettingsViewController.m index 14574964..d565fc94 100644 --- a/seafile/SeafSettingsViewController.m +++ b/seafile/SeafSettingsViewController.m @@ -398,12 +398,11 @@ - (void)viewDidLoad _versionCell.detailTextLabel.text = _version; [self configureView]; - WS(weakSelf); SeafDataTaskManager.sharedObject.trySyncBlock = ^(id _Nonnull task) { - [weakSelf updateSyncInfo]; + [self performSelectorInBackground:@selector(updateSyncInfo) withObject:nil]; }; SeafDataTaskManager.sharedObject.finishBlock = ^(id _Nonnull task) { - [weakSelf updateSyncInfo]; + [self performSelectorInBackground:@selector(updateSyncInfo) withObject:nil]; }; } @@ -479,12 +478,11 @@ - (void)configureView -(void)updateSyncInfo{ NSInteger downloadingNum = [[SeafDataTaskManager.sharedObject accountQueueForConnection:self.connection].fileQueue taskNumber]; NSInteger uploadingNum = [[SeafDataTaskManager.sharedObject accountQueueForConnection:self.connection].uploadQueue taskNumber]; - dispatch_async(dispatch_get_main_queue(), ^ { - self.downloadingCell.detailTextLabel.text = [NSString stringWithFormat:@"%lu",(long)downloadingNum]; - self.uploadingCell.detailTextLabel.text = [NSString stringWithFormat:@"%lu",(long)uploadingNum]; - NSIndexPath *downloadlingCellIndex = [NSIndexPath indexPathForRow:CELL_DOWNLOAD inSection:SECTION_UPDOWNLOAD]; - NSIndexPath *uploadlingCellIndex = [NSIndexPath indexPathForRow:CELL_UPLOAD inSection:SECTION_UPDOWNLOAD]; - [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:downloadlingCellIndex, uploadlingCellIndex, nil] withRowAnimation:UITableViewRowAnimationNone]; + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.tableView.dragging == false && self.tableView.decelerating == false && self.tableView.tracking == false) { + _downloadingCell.detailTextLabel.text = [NSString stringWithFormat:@"%lu",(long)downloadingNum]; + _uploadingCell.detailTextLabel.text = [NSString stringWithFormat:@"%lu",(long)uploadingNum]; + } }); } @@ -698,11 +696,6 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte } else { remainStr = [NSString stringWithFormat:NSLocalizedString(@"%ld photos remain", @"Seafile"), num]; } -#if DEBUG - NSInteger downloadingNum = [[SeafDataTaskManager.sharedObject accountQueueForConnection:self.connection].fileQueue taskNumber]; - NSInteger uploadingNum = [[SeafDataTaskManager.sharedObject accountQueueForConnection:self.connection].uploadQueue taskNumber]; - remainStr = [remainStr stringByAppendingFormat:@" U:%lu D:%lu",(long)uploadingNum,(long)downloadingNum]; -#endif return [sectionNames[section] stringByAppendingFormat:@"\t %@", remainStr]; } #if DEBUG diff --git a/seafile/en.lproj/FolderView_iPad.storyboard b/seafile/en.lproj/FolderView_iPad.storyboard index be455476..08d382bb 100644 --- a/seafile/en.lproj/FolderView_iPad.storyboard +++ b/seafile/en.lproj/FolderView_iPad.storyboard @@ -1,11 +1,11 @@ - + - + @@ -346,8 +346,8 @@ -