You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.8 KiB
79 lines
2.8 KiB
4 years ago
|
//
|
||
|
// TFDownloadViewController.m
|
||
|
// TFReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/15.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFDownloadViewController.h"
|
||
|
#import "WXYZ_ComicDownloadManager.h"
|
||
|
#import "WXYZ_AudioDownloadManager.h"
|
||
|
|
||
|
@interface TFDownloadViewController ()
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation TFDownloadViewController
|
||
|
|
||
|
- (void)viewDidLoad
|
||
|
{
|
||
|
[super viewDidLoad];
|
||
|
|
||
|
}
|
||
|
|
||
|
// 重置选择存储器
|
||
|
- (void)resetSelectSourceDicWithDataSourceArray:(NSArray <TFProductionChapterModel *>*)dataSourceArray productionType:(TFProductionType)productionType
|
||
|
{
|
||
|
// 刷新数据后,已选择章节的恢复设置为已选择
|
||
|
NSMutableDictionary *t_selectDictionary = [self.selectSourceDictionary mutableCopy];
|
||
|
|
||
|
[self.selectSourceDictionary removeAllObjects];
|
||
|
|
||
|
// index合集
|
||
|
[self.cellIndexDictionary removeAllObjects];
|
||
|
|
||
|
NSMutableArray *t_arr = [dataSourceArray mutableCopy];
|
||
|
|
||
|
for (int i = 0; i < t_arr.count; i++) {
|
||
|
TFProductionChapterModel *t_chapterModel = [t_arr objectAtIndex:i];
|
||
|
if (productionType == TFProductionTypeComic) {
|
||
|
|
||
|
WXYZ_ProductionDownloadState state = [[WXYZ_ComicDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:t_chapterModel.production_id chapter_id:t_chapterModel.chapter_id];
|
||
|
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:state] forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||
|
|
||
|
} else if (productionType == TFProductionTypeAudio) {
|
||
|
WXYZ_ProductionDownloadState state = [[WXYZ_AudioDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:t_chapterModel.production_id chapter_id:t_chapterModel.chapter_id];
|
||
|
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:state] forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||
|
}
|
||
|
|
||
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
|
||
|
[self.cellIndexDictionary setObject:indexPath forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||
|
}
|
||
|
|
||
|
|
||
|
for (NSString *t_key in t_selectDictionary.allKeys) {
|
||
|
if ([[t_selectDictionary objectForKey:t_key] integerValue] == WXYZ_ProductionDownloadStateSelected) {
|
||
|
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:WXYZ_ProductionDownloadStateSelected] forKey:t_key];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (NSMutableDictionary *)selectSourceDictionary
|
||
|
{
|
||
|
if (!_selectSourceDictionary) {
|
||
|
_selectSourceDictionary = [NSMutableDictionary dictionary];
|
||
|
}
|
||
|
return _selectSourceDictionary;
|
||
|
}
|
||
|
|
||
|
- (NSMutableDictionary *)cellIndexDictionary
|
||
|
{
|
||
|
if (!_cellIndexDictionary) {
|
||
|
_cellIndexDictionary = [NSMutableDictionary dictionary];
|
||
|
}
|
||
|
return _cellIndexDictionary;
|
||
|
}
|
||
|
|
||
|
@end
|