Skip to content

Commit e63f282

Browse files
committed
文件数量的显示
1 parent 6109e94 commit e63f282

3 files changed

Lines changed: 9 additions & 13 deletions

File tree

Coding_iOS/Models/ProjectFolder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
+ (ProjectFolder *)folderWithId:(NSNumber *)file_id;
2020
- (ProjectFolder *)hasFolderWithId:(NSNumber *)file_id;
2121

22-
- (void)setCountWithArray:(NSArray *)countArray;
2322
- (BOOL)isDefaultFolder;
2423
- (BOOL)canCreatSubfolder;
24+
- (NSInteger)fileCountIncludeSub;
2525

2626
- (NSString *)toFilesPath;
2727
- (NSDictionary *)toFilesParams;

Coding_iOS/Models/ProjectFolder.m

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,19 @@ - (instancetype)init
4444
}
4545
return self;
4646
}
47-
- (void)setCountWithArray:(NSArray *)countArray{
48-
__block NSInteger count = _sub_folders.count;
49-
[countArray enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) {
50-
NSNumber *folder_id = [obj objectForKey:@"folder"];
51-
if (folder_id && folder_id.integerValue == _file_id.integerValue) {
52-
count += [(NSNumber *)[obj objectForKey:@"count"] integerValue];
53-
*stop = YES;
54-
}
55-
}];
56-
self.count = [NSNumber numberWithInteger:count];
57-
}
5847
- (BOOL)isDefaultFolder{
5948
return !(_file_id && _file_id.integerValue != 0);
6049
}
6150
- (BOOL)canCreatSubfolder{
6251
return !((_parent_id && _parent_id.integerValue != 0) || [self isDefaultFolder]);
6352
}
53+
- (NSInteger)fileCountIncludeSub{
54+
NSInteger fileCount = self.count.integerValue;
55+
for (ProjectFolder *subFolder in self.sub_folders) {
56+
fileCount += subFolder.fileCountIncludeSub;
57+
}
58+
return fileCount;
59+
}
6460
- (NSString *)toFilesPath{
6561
return [NSString stringWithFormat:@"api/project/%@/files/%@", _project_id.stringValue, _file_id.stringValue];
6662
}

Coding_iOS/Views/Cell/ProjectFolderListCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ - (void)layoutSubviews{
5050
_iconView.image = [UIImage imageNamed:@"icon_file_folder_normal"];
5151
}
5252
_nameLabel.text = !_useToMove?
53-
[NSString stringWithFormat:@"%@%ld", _folder.name, (long)(_folder.count.integerValue)]
53+
[NSString stringWithFormat:@"%@%ld", _folder.name, (long)(_folder.fileCountIncludeSub)]
5454
:[NSString stringWithFormat:@"%@%ld", _folder.name, (long)_folder.sub_folders.count];
5555
}
5656

0 commit comments

Comments
 (0)