uploadFileRecordViewController.m 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  1. //
  2. // uoloadFileRecordViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/13.
  6. //
  7. #import "uploadFileRecordViewController.h"
  8. #import "uploadFileManager.h"
  9. #import "uploadFileDataModel.h"
  10. #import "uploadFileRecordheadView.h"
  11. //#import "uploadFileRecordBodyView.h"
  12. #import "uploadFileRecordEditBottomView.h"
  13. #import "uploadFileRecordBgScorllView.h"
  14. #import "uploadFileRecordTableView.h"
  15. #import "uploadFileRecordTableViewHeadView.h"
  16. #import "ComontAlretViewController.h"
  17. #import "backupsFilerecordTableView.h"
  18. #import "photosBackupsTaskModel.h"
  19. //#import "downloadManager.h"
  20. #import "downloadFileRecordTableView.h"
  21. #import "receiveView.h"
  22. #import "ComontAlretDeleteTypeViewController.h"
  23. #import "nonWifiTipInRecordView.h"
  24. #import "fileTransfeSetViewController.h"
  25. @interface uploadFileRecordViewController ()<UIScrollViewDelegate,UIDocumentPickerDelegate>
  26. //选中的项
  27. @property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems;
  28. @property (nonatomic, strong) uploadFileRecordheadView *uploadFileRecordheadV;
  29. @property (nonatomic, strong) uploadFileRecordBgScorllView *uploadFileRecordBgScorllV;
  30. @property (nonatomic, strong) uploadFileRecordTableView *leftTableView;
  31. @property (nonatomic, strong) downloadFileRecordTableView *midTableView;
  32. @property (nonatomic, strong) backupsFilerecordTableView *rightTableView;
  33. @property (nonatomic, strong) receiveView *curReceiveView;
  34. @property (nonatomic, strong) nonWifiTipInRecordView *nonWifiTipInRecordV;
  35. @property (nonatomic, assign) CGFloat nonWifiTipViewHeight;
  36. //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *leftHeadView;
  37. //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *midHeadView;
  38. //@property (nonatomic, strong) NSMutableArray *allDataArr;
  39. @property (nonatomic, strong) UIButton *leftButton;
  40. @property (nonatomic, strong) UIButton *rightButton;
  41. @property (nonatomic, strong) uploadFileRecordEditBottomView *uploadFileRecordEditBottomV;
  42. @property (nonatomic,assign) BOOL isEditType;
  43. @property(nonatomic,assign) NSInteger selectIndex;// 从1开始
  44. @property (nonatomic,assign) BOOL didGetUploadDataType;
  45. @property (nonatomic,assign) BOOL didGetDownloadDataType;
  46. @property (nonatomic,assign) BOOL didGetbackupsloadDataType;
  47. @property (nonatomic, copy) NSString *h5ShareDownloadUrl;
  48. @property (nonatomic,assign) BOOL isNotFirstPushType;//是否第一次进来
  49. @end
  50. @implementation uploadFileRecordViewController
  51. - (void)viewDidLoad {
  52. [super viewDidLoad];
  53. // Do any additional setup after loading the view.
  54. //[self.view setBackgroundColor:HWF5F7FAColor];
  55. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileRefreshFun:) name:uploadFileRefreshNotification object:nil];
  56. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileSuspendAllFun:) name:uploadFileSuspendAllNotification object:nil];
  57. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backupsFileRefreshFun:) name:backupsFileRefreshNotification object:nil];
  58. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileRefreshFun:) name:downloadFileRefreshNotification object:nil];
  59. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileSuspendAllFun:) name:downloadFileSuspendAllNotification object:nil];
  60. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:nasDownloadTaskFinishedNotification object:nil];
  61. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkStateChange:) name:NetWorkChangeNotification object:nil];
  62. [self.view setBackgroundColor:[UIColor whiteColor]];
  63. self.titleLabel.text = NSLocalizedString(@"my_set_no_File_Transfer_List",nil) ;
  64. [self.toolBar setHidden:YES];
  65. [self.navigationBar setHidden:YES];
  66. [self.navBarBGView setHidden:NO];
  67. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  68. [self initbaseUIFun];
  69. //数据埋点
  70. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Transmission_record"];
  71. }
  72. - (void)viewWillAppear:(BOOL)animated
  73. {
  74. [super viewWillAppear:animated];
  75. if(_isNotFirstPushType){//判断是否第一次进入 非第一次进入 不处理下面的逻辑
  76. if(!self.nonWifiTipInRecordV.hidden){
  77. if([AFNetworkReachabilityManager sharedManager].isReachableViaWWAN){//目前是流量模式
  78. BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
  79. if(isCanUseCellular){
  80. [self networkStateChange:nil];//
  81. }
  82. }
  83. }
  84. return;
  85. }
  86. _isNotFirstPushType = YES;
  87. if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024]
  88. && _isDownloadingType){
  89. mainBlock(^{
  90. [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show];
  91. });
  92. // [self.navigationController popViewControllerAnimated:YES];
  93. // return;
  94. }
  95. [self getAllDataFun];
  96. }
  97. - (void)viewWillDisappear:(BOOL)animated
  98. {
  99. [super viewWillDisappear:animated];
  100. [SVProgressHUD dismiss];
  101. }
  102. #pragma mark 获取数据
  103. - (void)getAllDataFun
  104. {
  105. [SVProgressHUD show];;
  106. if(!_isUploadingType){
  107. [self getUploadDataInDatabaseFun];
  108. }
  109. if(!_isDownloadingType){
  110. [self getDownloadDataInDatabaseFun:YES];
  111. }
  112. else{
  113. [self delayChangeUIFunWithIndex:2];
  114. }
  115. //检测是否还有没保存的任务
  116. [[nasDownloadFileManager shareInstance] checkDownloadDonePlistInfoFun];
  117. [self getBackupsDatabaseFun];
  118. if(!_isReceiveType){
  119. [_curReceiveView getAllDataFun];
  120. }
  121. }
  122. - (void)handleRemoveIndicator
  123. {
  124. if(_didGetUploadDataType
  125. && _didGetDownloadDataType
  126. && _didGetbackupsloadDataType){
  127. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  128. [SVProgressHUD dismiss];
  129. });
  130. }
  131. }
  132. //下载 2 接收 4
  133. - (void)delayChangeUIFunWithIndex:(NSInteger)index
  134. {
  135. _selectIndex = index;
  136. KWeakSelf
  137. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  138. [weakSelf didClickHeadFun:self->_selectIndex];
  139. [weakSelf didScorllBodyFun:self->_selectIndex];
  140. });
  141. }
  142. #pragma mark UI
  143. - (void)initbaseUIFun
  144. {
  145. _uploadFileRecordheadV = [[uploadFileRecordheadView alloc] init];
  146. [self.view addSubview:_uploadFileRecordheadV];
  147. [_uploadFileRecordheadV mas_makeConstraints:^(MASConstraintMaker *make) {
  148. make.left.mas_equalTo(15);
  149. make.right.mas_equalTo(-15);
  150. make.top.mas_equalTo(self.navBarBGView.mas_bottom).offset(15.0);
  151. make.height.mas_equalTo(50);
  152. }];
  153. _selectIndex = 1;
  154. KWeakSelf
  155. #pragma mark 头部点击事件
  156. _uploadFileRecordheadV.didClickButFun = ^(NSInteger index) {
  157. [weakSelf didClickHeadFun: index];
  158. };
  159. _nonWifiTipViewHeight = 0;
  160. [self.view addSubview:self.nonWifiTipInRecordV];
  161. //AFNetworkReachabilityStatus state = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
  162. BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
  163. //当前网络为流量 与流量传输没开
  164. if ([AFNetworkReachabilityManager sharedManager].isReachableViaWWAN
  165. && !isCanUseCellular) {
  166. _nonWifiTipViewHeight = 56;
  167. }
  168. [self.nonWifiTipInRecordV mas_makeConstraints:^(MASConstraintMaker *make) {
  169. make.left.mas_equalTo(15);
  170. make.right.mas_equalTo(-15);
  171. make.top.mas_equalTo(self.uploadFileRecordheadV.mas_bottom).offset(0.0);
  172. make.height.mas_equalTo(_nonWifiTipViewHeight);
  173. }];
  174. if(_nonWifiTipViewHeight == 0){
  175. self.nonWifiTipInRecordV.hidden = YES;
  176. }
  177. #pragma mark 点击去开启
  178. self.nonWifiTipInRecordV.didClickBut = ^{
  179. [weakSelf gotoTranSettingVCFun];
  180. };
  181. CGFloat curHeight = SCREEN_H - (H_STATE_BAR + 64.f) - 50 - _nonWifiTipViewHeight - 15;
  182. _uploadFileRecordBgScorllV= [[uploadFileRecordBgScorllView alloc] init];
  183. _uploadFileRecordBgScorllV.delegate = self;
  184. _uploadFileRecordBgScorllV.pagingEnabled = YES;
  185. //_uploadFileRecordBgScorllV.backgroundColor = [UIColor yellowColor];
  186. [self.view addSubview:_uploadFileRecordBgScorllV];
  187. [_uploadFileRecordBgScorllV mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.left.mas_equalTo(0);
  189. make.right.mas_equalTo(0);
  190. if(_nonWifiTipViewHeight > 0){
  191. make.top.mas_equalTo(self.nonWifiTipInRecordV.mas_bottom).offset(0.0);
  192. }
  193. else{
  194. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  195. }
  196. make.bottom.mas_equalTo(0);
  197. }];
  198. _leftTableView = [[uploadFileRecordTableView alloc] init];
  199. _leftTableView.tag =100;
  200. [_uploadFileRecordBgScorllV addSubview:_leftTableView];
  201. [_leftTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  202. make.left.mas_equalTo(SCREEN_W*0.0);
  203. make.width.mas_equalTo(SCREEN_W);
  204. make.top.mas_equalTo(0);
  205. make.height.mas_equalTo(curHeight);
  206. }];
  207. _leftTableView.didLongPressClick = ^{
  208. weakSelf.isEditType = YES;
  209. };
  210. _leftTableView.didClickSectionHeadViewRightButton = ^(NSInteger section) {
  211. [weakSelf didClikRightButInUploadTableVieFunBy:section];
  212. };
  213. _leftTableView.didNeedRefreshGetDatabaseFun = ^{
  214. [weakSelf RefreshUploadViewFun];
  215. };
  216. _midTableView = [[downloadFileRecordTableView alloc] init];
  217. _midTableView.tag = 101;
  218. [_uploadFileRecordBgScorllV addSubview:_midTableView];
  219. [_midTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.left.mas_equalTo(SCREEN_W*1.0);
  221. make.width.mas_equalTo(SCREEN_W);
  222. make.top.mas_equalTo(0);
  223. make.height.mas_equalTo(curHeight);
  224. }];
  225. _midTableView.didLongPressClick = ^{
  226. weakSelf.isEditType = YES;
  227. };
  228. _midTableView.didClickSectionHeadViewRightButton = ^(NSInteger section) {
  229. [weakSelf didClikRightButInDownloadTableVieFunBy:section];
  230. };
  231. _midTableView.didNeedRefreshGetDatabaseFun = ^{
  232. [weakSelf getDownloadDataInDatabaseFun:NO];
  233. };
  234. _rightTableView = [[backupsFilerecordTableView alloc] init];
  235. _rightTableView.tag = 102;
  236. [_uploadFileRecordBgScorllV addSubview:_rightTableView];
  237. [_rightTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  238. make.left.mas_equalTo(SCREEN_W*2.0);
  239. make.width.mas_equalTo(SCREEN_W);
  240. make.top.mas_equalTo(0);
  241. make.height.mas_equalTo(curHeight);
  242. }];
  243. _rightTableView.didLongPressClick = ^{
  244. // weakSelf.isEditType = YES;
  245. };
  246. //接收
  247. _curReceiveView = [[receiveView alloc] init];
  248. _curReceiveView.tag = 103;
  249. [_uploadFileRecordBgScorllV addSubview:_curReceiveView];
  250. [_curReceiveView mas_makeConstraints:^(MASConstraintMaker *make) {
  251. make.left.mas_equalTo(SCREEN_W*3.0);
  252. make.width.mas_equalTo(SCREEN_W);
  253. make.top.mas_equalTo(0);
  254. make.height.mas_equalTo(curHeight);
  255. }];
  256. _curReceiveView.didLongPressClick = ^{
  257. weakSelf.isEditType = YES;
  258. };
  259. _uploadFileRecordBgScorllV.contentSize = CGSizeMake(SCREEN_W*4.0, curHeight);
  260. // _leftHeadView = [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
  261. // _leftTableView.tableHeaderView = _leftHeadView;
  262. // _leftHeadView.didClickButFun = ^{
  263. // [weakSelf didClickAllSuspendInLoadingFun];
  264. // };
  265. //
  266. // _midHeadView = [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
  267. // _midTableView.tableHeaderView = _midHeadView;
  268. // _midHeadView.didClickButFun = ^{
  269. // [weakSelf didClickClearRecordInDoneFun];
  270. // };
  271. _leftButton = [[UIButton alloc] init];
  272. [_leftButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  273. _leftButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
  274. _leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  275. [_leftButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  276. _leftButton.tag = 1;
  277. [_leftButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  278. _leftButton.hidden = YES;
  279. [self.navBarBGView addSubview:_leftButton];
  280. [_leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
  281. make.width.mas_equalTo(80);
  282. make.left.mas_equalTo(15);
  283. make.height.mas_equalTo(self.backBtn.mas_height);
  284. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  285. }];
  286. _rightButton = [[UIButton alloc] init];
  287. [_rightButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  288. _rightButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
  289. _rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  290. [_rightButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  291. _rightButton.tag = 2;
  292. [_rightButton setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal];
  293. [_rightButton setTitle:NSLocalizedString(@"File_upload_cancel_select_all",nil) forState:UIControlStateSelected];
  294. _rightButton.hidden = YES;
  295. [self.navBarBGView addSubview:_rightButton];
  296. //多国语言适配
  297. NSString *languageCode = [NSLocale preferredLanguages][0];
  298. if([languageCode rangeOfString:@"ja-"].location != NSNotFound)
  299. {
  300. _rightButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
  301. _leftButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
  302. }
  303. [_rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  304. make.width.mas_equalTo(90);
  305. make.right.mas_equalTo(-15);
  306. make.height.mas_equalTo(self.backBtn.mas_height);
  307. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  308. }];
  309. _uploadFileRecordEditBottomV = [[uploadFileRecordEditBottomView alloc] init];
  310. _uploadFileRecordEditBottomV.hidden = YES;
  311. [self.view addSubview:_uploadFileRecordEditBottomV];
  312. [_uploadFileRecordEditBottomV mas_makeConstraints:^(MASConstraintMaker *make) {
  313. make.left.mas_equalTo(0);
  314. make.right.mas_equalTo(0);
  315. make.height.mas_equalTo(60 + safeArea);
  316. make.bottom.mas_equalTo(0);
  317. }];
  318. _uploadFileRecordEditBottomV.didClickButFun = ^{
  319. //[weakSelf.uploadFileRecordBodyV deleteModelOneByOneFun];
  320. [weakSelf didClickBottomDeleteFun];
  321. };
  322. }
  323. #pragma mark 懒加载
  324. - (nonWifiTipInRecordView*)nonWifiTipInRecordV
  325. {
  326. if(!_nonWifiTipInRecordV){
  327. _nonWifiTipInRecordV = [[nonWifiTipInRecordView alloc] init];
  328. }
  329. return _nonWifiTipInRecordV;
  330. }
  331. #pragma mark 底部删除点击
  332. -(void)didClickBottomDeleteFun
  333. {
  334. NSMutableArray *selectModelArr ;//= _leftTableView.selectModelArr;
  335. if(_selectIndex == 1){
  336. selectModelArr = _leftTableView.selectModelArr;
  337. }
  338. else if(_selectIndex == 2){
  339. selectModelArr = _midTableView.selectModelArr;
  340. }
  341. else if(_selectIndex == 3){
  342. return;
  343. }
  344. else if(_selectIndex == 4){
  345. selectModelArr = _curReceiveView.selectModelArr;
  346. }
  347. if(!selectModelArr || selectModelArr.count== 0){
  348. [[iToast makeText:NSLocalizedString(@"File_upload_Record_delete_noFile",nil)] show];
  349. return;
  350. }
  351. if(_selectIndex == 1){//上传相关特殊处理
  352. NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  353. NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  354. KWeakSelf
  355. ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  356. initWithTitle:titleStr
  357. msg:@""
  358. imageStr:@""
  359. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  360. okTitle:NSLocalizedString(@"other_confirm",nil)
  361. otherTitle:tipStr
  362. isOkBtnHighlight:YES
  363. didClickOk:^(BOOL isDeleteAll) {
  364. [weakSelf didClickDeleteOkButBy:isDeleteAll];
  365. } didClickCancel:^{
  366. }];
  367. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  368. [self presentViewController:curAlretVC animated:YES completion:^{
  369. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  370. }];
  371. }
  372. else{
  373. NSString *delTipTip = NSLocalizedString(@"box_receive_delete_msg",nil);
  374. /*弹窗提示二次确认*/
  375. KWeakSelf
  376. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  377. msg:delTipTip
  378. imageStr:@""
  379. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  380. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  381. didClickOk:^{
  382. [weakSelf didClickBottomDeleteFunAfterAleartFun];
  383. } didClickCancel:^{
  384. }];
  385. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  386. [self presentViewController:nextVC animated:YES completion:^{
  387. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  388. }];
  389. }
  390. }
  391. #pragma mark 选中上传任务的删除的处理
  392. - (void)didClickDeleteOkButBy:(BOOL)isDeleteAll
  393. {
  394. if(isDeleteAll){//删除云机上的文件
  395. [self delFileListFunWithData:_leftTableView.selectModelArr];
  396. }
  397. [self didClickBottomDeleteFunAfterAleartFun];
  398. }
  399. -(void)didClickBottomDeleteFunAfterAleartFun
  400. {
  401. [SVProgressHUD show];
  402. if(_selectIndex == 1){
  403. [_leftTableView deleteModelOneByOneFun];
  404. }
  405. else if(_selectIndex == 2){
  406. [_midTableView deleteModelOneByOneFun];
  407. }
  408. else if(_selectIndex == 3){
  409. //没有操作
  410. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  411. [SVProgressHUD dismiss];
  412. });
  413. }
  414. else if(_selectIndex == 4){
  415. [_curReceiveView deleteModelOneByOneFun];
  416. [SVProgressHUD dismiss];
  417. }
  418. }
  419. #pragma mark 头部点击 背景滚动
  420. - (void)didClickHeadFun:(NSInteger)index
  421. {
  422. //_uploadFileRecordBodyV.selectIndex = index;
  423. _selectIndex = index;
  424. _uploadFileRecordBgScorllV.contentOffset = CGPointMake(SCREEN_W *(index -1), 0);
  425. }
  426. - (void)didScorllBodyFun:(NSInteger)index
  427. {
  428. _uploadFileRecordheadV.selectIndex = index;
  429. _selectIndex = index;
  430. }
  431. #pragma mark 1.3版本UI修改后 上传文件列表的内容点击时间
  432. - (void)didClikRightButInUploadTableVieFunBy:(NSInteger)section
  433. {
  434. if(section == 0){
  435. [self didClickAllSuspendInLoadingFun];
  436. }
  437. else if(section == 1){//成功
  438. [self didClickClearRecordInDoneFun];
  439. }
  440. else if(section == 2){//失败
  441. [self didClickClearRecordInFailFun];
  442. }
  443. }
  444. #pragma mark 背景滚动代理
  445. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  446. {
  447. if(scrollView != _uploadFileRecordBgScorllV) return;
  448. CGFloat x = scrollView.contentOffset.x;
  449. NSInteger index = (x+1)/SCREEN_W;
  450. index += 1;//因为头部是从1开始的
  451. //HLog(@"index:%ld",index);
  452. [self didScorllBodyFun:index];
  453. }
  454. -(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems
  455. {
  456. KWeakSelf
  457. mainBlock(^{
  458. weakSelf.didGetUploadDataType = YES;
  459. [weakSelf handleRemoveIndicator];
  460. });
  461. [self realGotoUploadFile:indexPathsForSelectedItems];
  462. }
  463. - (void)realGotoUploadFile:(NSMutableArray *)indexPathsForSelectedItems
  464. {
  465. KWeakSelf
  466. [[nasUploadFileManager shareInstance] handlTZAssetModelToUploadFileDataFunBy:indexPathsForSelectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  467. //NSMutableArray *arr1 = Arr;
  468. //[weakSelf setRecordBodyDataFunBy:arr1];
  469. //weakSelf.leftTableView.curDataArr = Arr[0];
  470. mainBlock(^{
  471. weakSelf.leftTableView.outSideDataArr = Arr;
  472. [weakSelf handleUploadingRightButFun:YES];
  473. });
  474. }];
  475. }
  476. //处理文件app上传的文件
  477. -(void)gotoUploadFileByFileApp:(NSArray*)FileUrls{
  478. KWeakSelf
  479. mainBlock(^{
  480. weakSelf.didGetUploadDataType = YES;
  481. [weakSelf handleRemoveIndicator];
  482. });
  483. [self realGotoUploadFileByFileApp:FileUrls];
  484. }
  485. - (void)realGotoUploadFileByFileApp:(NSArray *)URLArr
  486. {
  487. KWeakSelf
  488. [[nasUploadFileManager shareInstance] handlUrlToUploadFileDataFunBy:URLArr complete:^(NSMutableArray * _Nonnull Arr) {
  489. //NSMutableArray *arr1 = Arr;
  490. //[weakSelf setRecordBodyDataFunBy:arr1];
  491. //weakSelf.leftTableView.curDataArr = Arr[0];
  492. mainBlock(^{
  493. weakSelf.leftTableView.outSideDataArr = Arr;
  494. [weakSelf handleUploadingRightButFun:YES];
  495. });
  496. }];
  497. }
  498. //处理文件录音上传的文件
  499. -(void)gotoUploadFileByRecord:(NSArray*)recordFileArr
  500. {
  501. KWeakSelf
  502. mainBlock(^{
  503. weakSelf.didGetUploadDataType = YES;
  504. [weakSelf handleRemoveIndicator];
  505. });
  506. //KWeakSelf
  507. [[nasUploadFileManager shareInstance] handlToRecorUploadFileDataFunBy:recordFileArr complete:^(NSMutableArray * _Nonnull Arr) {
  508. mainBlock(^{
  509. weakSelf.leftTableView.outSideDataArr = Arr;
  510. [weakSelf handleUploadingRightButFun:YES];
  511. });
  512. }];
  513. }
  514. #pragma mark 读取数据库数据
  515. - (void)getUploadDataInDatabaseFun
  516. {
  517. //查询是否为nas上传中
  518. BOOL isnasUploadingType = [nasMixUploadManager shareManager].isUploadIngType;
  519. //判断是否要重新拿数据
  520. BOOL isNeedRegetDataType = !isnasUploadingType;
  521. KWeakSelf
  522. [[nasUploadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
  523. //[weakSelf setRecordBodyDataFunBy:Arr];
  524. weakSelf.didGetUploadDataType = YES;
  525. [weakSelf handleRemoveIndicator];
  526. if(!Arr ||Arr.count != 3){
  527. HLog(@"数据库出错\n\n\n");
  528. return;
  529. }
  530. //不是上传视频和进来的 所以上传状态(上传中和等待)改为重新上传
  531. if(!weakSelf.isUploadingType && isNeedRegetDataType){
  532. //改为暂停
  533. // for (uploadFileDataModel * curModel in curLoadIngArr) {
  534. // curModel.curUploadStateType = uploadStateSuspend;
  535. // }
  536. //改为重新上传
  537. if(!isnasUploadingType){
  538. NSMutableArray *curLoadIngArr = Arr[0];
  539. NSMutableArray *handleUploadArr = [NSMutableArray new];
  540. for (uploadFileDataModel * curModel in curLoadIngArr) {
  541. if(!curModel){
  542. continue;
  543. }
  544. if(curModel.curUploadStateType != uploadStateSuspend)
  545. {
  546. [handleUploadArr addObject:curModel];
  547. }
  548. }
  549. if(handleUploadArr.count >0){
  550. //[[uploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES];
  551. [[nasUploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES];
  552. }
  553. }
  554. }
  555. mainBlock(^{
  556. weakSelf.leftTableView.outSideDataArr = Arr;
  557. [weakSelf handleUploadingRightButFun:NO];
  558. });
  559. }];
  560. }
  561. - (void)getBackupsDatabaseFun
  562. {
  563. KWeakSelf
  564. [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
  565. mainBlock(^{
  566. weakSelf.didGetbackupsloadDataType = YES;
  567. [weakSelf handleRemoveIndicator];
  568. weakSelf.rightTableView.curDataArr = array;
  569. });
  570. }];
  571. }
  572. #pragma mark 读取数据库数据
  573. - (void)getDownloadDataInDatabaseFun:(BOOL)isRegetType
  574. {
  575. if(isRegetType){
  576. //查询是否为nas下载中
  577. BOOL isDownLoadIngType = [nasDownloadManager shareManager].isDownLoadIngType;
  578. //判断是否要重新拿数据
  579. isRegetType = !isDownLoadIngType;
  580. }
  581. KWeakSelf
  582. [[nasDownloadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
  583. weakSelf.didGetDownloadDataType = YES;
  584. [weakSelf handleRemoveIndicator];
  585. if(!Arr ||Arr.count != 3){
  586. HLog(@"数据库出错\n\n\n");
  587. return;
  588. }
  589. NSMutableArray *curLoadIngArr = Arr[0];
  590. //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  591. if(![nasDownloadManager shareManager].isDownLoadIngType && isRegetType){
  592. // for (couldPhoneFileModel * curModel in curLoadIngArr) {
  593. // curModel.curDownloadStateType = downloadStateSuspend;
  594. // }
  595. //改为重新下载
  596. NSMutableArray *handleDownloadArr = [NSMutableArray new];
  597. for (couldPhoneFileModel * curModel in curLoadIngArr) {
  598. if(curModel.curDownloadStateType != downloadStateSuspend)
  599. {
  600. [handleDownloadArr addObject:curModel];
  601. }
  602. }
  603. if(handleDownloadArr.count >0){
  604. [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:handleDownloadArr withAll:NO];
  605. }
  606. }
  607. mainBlock(^{
  608. weakSelf.midTableView.outSideDataArr = Arr;
  609. [weakSelf.midTableView reloadDataFun];
  610. [weakSelf handleDownloadingRightButFun];
  611. });
  612. }];
  613. }
  614. #pragma mark 处理上传中的 全部暂停等
  615. - (void)handleUploadingRightButFun:(BOOL)isUserUploadIngType
  616. {
  617. // if(_leftTableView.uploadingArr.count == 0){
  618. // //不处理
  619. // }
  620. // else{
  621. // NSMutableArray *upLoadingArr = [uploadFileManager shareInstance].fileModelDataArr;
  622. // BOOL isUploadIngType = [uploadFileManager shareInstance].isUploadIngType;
  623. //
  624. // if(!isUserUploadIngType
  625. // &&(!upLoadingArr ||upLoadingArr.count == 0 || !isUploadIngType)){//不是上传状态
  626. // _leftTableView.uploadingHeadView.rightButton.selected = YES;
  627. // }
  628. // else if(upLoadingArr.count == _leftTableView.uploadingArr.count){
  629. // _leftTableView.uploadingHeadView.rightButton.selected = NO;
  630. // }
  631. // else{
  632. // _leftTableView.uploadingHeadView.rightButton.selected = YES;
  633. // }
  634. // }
  635. }
  636. #pragma mark 处理下载中的 全部暂停等
  637. - (void)handleDownloadingRightButFun
  638. {
  639. if(_midTableView.downloadingArr.count == 0){
  640. //不处理
  641. }
  642. else{
  643. NSMutableArray *downloadingArr = [nasDownloadFileManager shareInstance].downLoadFileModelDataArr;
  644. BOOL isDownloadIngType = [nasDownloadManager shareManager].isDownLoadIngType;
  645. if(!downloadingArr ||downloadingArr.count == 0 || !isDownloadIngType){//不是下载状态
  646. _midTableView.downloadingHeadView.rightButton.selected = YES;
  647. }
  648. else if(downloadingArr.count == _midTableView.downloadingArr.count){
  649. _midTableView.downloadingHeadView.rightButton.selected = NO;
  650. }
  651. else{
  652. _midTableView.downloadingHeadView.rightButton.selected = YES;
  653. }
  654. }
  655. }
  656. - (void)uploadFileRefreshFun:(NSNotification*)not
  657. {
  658. uploadFileDataModel *uploadFileDataMod = [not object];
  659. //HLog(@"%@",uploadFileDataMod);
  660. uploadFileDataMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  661. NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
  662. //HLog(@"传输列表的上传任务:%@",uploadingArr);
  663. // for (int i=0; i<uploadingArr.count; i++) {
  664. // uploadFileDataModel*preModel = uploadingArr[i];
  665. // if(preModel.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
  666. // [_leftTableView.uploadingArr replaceObjectAtIndex:i withObject:uploadFileDataMod];
  667. // break;
  668. // }
  669. // }
  670. if(uploadFileDataMod.curUploadStateType == uploadStateDone
  671. || uploadFileDataMod.curUploadStateType == uploadStateFail){
  672. [self RefreshUploadViewFun];
  673. }
  674. else{
  675. [_leftTableView RefreshAllDataFun];
  676. }
  677. }
  678. - (void)uploadFileSuspendAllFun:(NSNotification*)not
  679. {
  680. NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
  681. for (int i=0; i<uploadingArr.count; i++) {
  682. uploadFileDataModel*preModel = uploadingArr[i];
  683. if(preModel.curUploadStateType == uploadStateUploading
  684. ||preModel.curUploadStateType == uploadStateWait){
  685. preModel.curUploadStateType = uploadStateSuspend;
  686. //break;
  687. }
  688. }
  689. }
  690. #pragma mark 那上传那边的数据来更新页面
  691. - (void)RefreshUploadViewFun
  692. {
  693. KWeakSelf
  694. [[nasUploadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
  695. //[weakSelf setRecordBodyDataFunBy:Arr];
  696. if(!Arr ||Arr.count != 3){
  697. HLog(@"数据库出错\n\n\n");
  698. return;
  699. }
  700. mainBlock(^{
  701. weakSelf.leftTableView.outSideDataArr = Arr;
  702. //[weakSelf handleUploadingRightButFun];
  703. });
  704. }];
  705. }
  706. #pragma mark 按钮点击
  707. - (void)didClickButFun:(UIButton*)but
  708. {
  709. NSInteger tag = but.tag;
  710. if(tag == 1){
  711. self.isEditType = NO;
  712. //self.uploadFileRecordBodyV.isEditType = NO;
  713. if(_selectIndex == 1){
  714. self.leftTableView.isEditType = NO;
  715. }
  716. else if(_selectIndex == 2){
  717. self.midTableView.isEditType = NO;
  718. }
  719. else if(_selectIndex == 3){
  720. //self.rightTableView.isEditType = NO;
  721. }
  722. }
  723. else{
  724. //self.uploadFileRecordBodyV.isSelectAllType = YES;
  725. but.selected = !but.selected;
  726. BOOL curSelectAllType = but.selected;
  727. if(_selectIndex == 1){
  728. self.leftTableView.isSelectAllType = curSelectAllType;
  729. }
  730. else if(_selectIndex == 2){
  731. self.midTableView.isSelectAllType = curSelectAllType;
  732. }
  733. else if(_selectIndex == 3){
  734. //self.rightTableView.isSelectAllType = YES;
  735. }
  736. else if(_selectIndex == 4){
  737. self.curReceiveView.isSelectAllType = curSelectAllType;
  738. }
  739. }
  740. }
  741. -(void)setIsEditType:(BOOL)isEditType
  742. {
  743. _isEditType = isEditType;
  744. _leftButton.hidden = !isEditType;
  745. _rightButton.hidden = !isEditType;
  746. self.backBtn.hidden = isEditType;
  747. _uploadFileRecordEditBottomV.hidden = !isEditType;
  748. _uploadFileRecordheadV.userInteractionEnabled = !isEditType;
  749. _uploadFileRecordBgScorllV.scrollEnabled = !isEditType;
  750. //_leftHeadView.rightButton.userInteractionEnabled = !isEditType;
  751. _curReceiveView.isEditType = isEditType;
  752. if(_isEditType){
  753. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15 - (60 + safeArea + AdaptTabHeight);
  754. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  755. make.left.mas_equalTo(0);
  756. make.right.mas_equalTo(0);
  757. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  758. make.bottom.mas_equalTo(_uploadFileRecordEditBottomV.mas_top);
  759. }];
  760. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  761. make.left.mas_equalTo(SCREEN_W*0.0);
  762. make.width.mas_equalTo(SCREEN_W);
  763. make.top.mas_equalTo(0);
  764. make.height.mas_equalTo(curHeight);
  765. }];
  766. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  767. make.left.mas_equalTo(SCREEN_W*1.0);
  768. make.width.mas_equalTo(SCREEN_W);
  769. make.top.mas_equalTo(0);
  770. make.height.mas_equalTo(curHeight);
  771. }];
  772. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  773. make.left.mas_equalTo(SCREEN_W*2.0);
  774. make.width.mas_equalTo(SCREEN_W);
  775. make.top.mas_equalTo(0);
  776. make.height.mas_equalTo(curHeight);
  777. }];
  778. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  779. make.left.mas_equalTo(SCREEN_W*3.0);
  780. make.width.mas_equalTo(SCREEN_W);
  781. make.top.mas_equalTo(0);
  782. make.height.mas_equalTo(curHeight);
  783. }];
  784. }
  785. else{
  786. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
  787. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  788. make.left.mas_equalTo(0);
  789. make.right.mas_equalTo(0);
  790. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  791. make.bottom.mas_equalTo(0);
  792. }];
  793. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  794. make.left.mas_equalTo(SCREEN_W*0.0);
  795. make.width.mas_equalTo(SCREEN_W);
  796. make.top.mas_equalTo(0);
  797. make.height.mas_equalTo(curHeight);
  798. }];
  799. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  800. make.left.mas_equalTo(SCREEN_W*1.0);
  801. make.width.mas_equalTo(SCREEN_W);
  802. make.top.mas_equalTo(0);
  803. make.height.mas_equalTo(curHeight);
  804. }];
  805. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  806. make.left.mas_equalTo(SCREEN_W*2.0);
  807. make.width.mas_equalTo(SCREEN_W);
  808. make.top.mas_equalTo(0);
  809. make.height.mas_equalTo(curHeight);
  810. }];
  811. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  812. make.left.mas_equalTo(SCREEN_W*3.0);
  813. make.width.mas_equalTo(SCREEN_W);
  814. make.top.mas_equalTo(0);
  815. make.height.mas_equalTo(curHeight);
  816. }];
  817. }
  818. }
  819. #pragma mark 点击上传中的全部暂停
  820. - (void)didClickAllSuspendInLoadingFun
  821. {
  822. _leftTableView.uploadingHeadView.rightButton.selected = !_leftTableView.uploadingHeadView.rightButton.selected;
  823. if(_leftTableView.uploadingHeadView.rightButton.selected){
  824. //[[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  825. [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  826. [_leftTableView reloadDataFun];
  827. }
  828. else{
  829. NSMutableArray *leftArr = _leftTableView.uploadingArr;
  830. //[[uploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
  831. [[nasUploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
  832. }
  833. }
  834. #pragma mark 点击上传成功的清空记录
  835. - (void)didClickClearRecordInDoneFun
  836. {
  837. // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  838. // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  839. //
  840. // KWeakSelf
  841. // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  842. // initWithTitle:titleStr
  843. // msg:nil
  844. // imageStr:nil
  845. // cancelTitle:NSLocalizedString(@"other_cancel",nil)
  846. // okTitle:NSLocalizedString(@"other_confirm",nil)
  847. // otherTitle:tipStr
  848. // isOkBtnHighlight:YES
  849. // didClickOk:^(BOOL isDeleteAll) {
  850. // [weakSelf didClickClearAllRecordInUploadDoneFun:isDeleteAll];
  851. // } didClickCancel:^{
  852. //
  853. // }];
  854. //
  855. // curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  856. //
  857. // [self presentViewController:curAlretVC animated:YES completion:^{
  858. // curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  859. // }];
  860. /*弹窗提示二次确认*/
  861. KWeakSelf
  862. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  863. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  864. imageStr:@""
  865. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  866. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  867. didClickOk:^{
  868. [weakSelf ClearAllRecordInDoneFun];
  869. } didClickCancel:^{
  870. }];
  871. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  872. [self presentViewController:nextVC animated:YES completion:^{
  873. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  874. }];
  875. }
  876. #pragma mark 确认要删除上传完成的任务
  877. - (void)didClickClearAllRecordInUploadDoneFun:(BOOL)isDeleteAllType
  878. {
  879. if(isDeleteAllType){
  880. [self delFileListFunWithData:_leftTableView.uploadDoneArr];
  881. }
  882. [self ClearAllRecordInDoneFun];
  883. }
  884. - (void)ClearAllRecordInDoneFun
  885. {
  886. [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadDoneArr withDelCache:YES complete:^(BOOL isSuccess) {
  887. HLog(@"isSuccess:%d",isSuccess);
  888. if(isSuccess){
  889. [self->_leftTableView.uploadDoneArr removeAllObjects];
  890. [self->_leftTableView reloadDataFun];
  891. }
  892. }];
  893. }
  894. #pragma mark 点击上传失败的清空记录
  895. - (void)didClickClearRecordInFailFun
  896. {
  897. // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  898. // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  899. //
  900. // KWeakSelf
  901. // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  902. // initWithTitle:titleStr
  903. // msg:nil
  904. // imageStr:nil
  905. // cancelTitle:NSLocalizedString(@"other_cancel",nil)
  906. // okTitle:NSLocalizedString(@"other_confirm",nil)
  907. // otherTitle:tipStr
  908. // isOkBtnHighlight:YES
  909. // didClickOk:^(BOOL isDeleteAll) {
  910. // [weakSelf didClickClearAllRecordInUploadFailFun:isDeleteAll];
  911. // } didClickCancel:^{
  912. //
  913. // }];
  914. //
  915. // curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  916. //
  917. // [self presentViewController:curAlretVC animated:YES completion:^{
  918. // curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  919. // }];
  920. /*弹窗提示二次确认*/
  921. KWeakSelf
  922. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  923. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  924. imageStr:@""
  925. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  926. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  927. didClickOk:^{
  928. [weakSelf ClearAllRecordInFailFun];
  929. } didClickCancel:^{
  930. }];
  931. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  932. [self presentViewController:nextVC animated:YES completion:^{
  933. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  934. }];
  935. }
  936. #pragma mark 确认要删除上传失败的任务
  937. - (void)didClickClearAllRecordInUploadFailFun:(BOOL)isDeleteAllType
  938. {
  939. if(isDeleteAllType){
  940. [self delFileListFunWithData:_leftTableView.uploadfailArr];
  941. }
  942. [self ClearAllRecordInFailFun];
  943. }
  944. - (void)ClearAllRecordInFailFun
  945. {
  946. [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadfailArr withDelCache:YES complete:^(BOOL isSuccess) {
  947. HLog(@"isSuccess:%d",isSuccess);
  948. if(isSuccess){
  949. [self->_leftTableView.uploadfailArr removeAllObjects];
  950. [self->_leftTableView reloadDataFun];
  951. }
  952. }];
  953. }
  954. -(void)backBtnPressed{
  955. //[super backBtnPressed];
  956. NSArray *vcArrs = self.navigationController.viewControllers;
  957. NSInteger count = vcArrs.count;
  958. UIViewController *vc = nil;
  959. if(count > 2){
  960. UIViewController *lastVC = vcArrs[count-2];
  961. if([lastVC isKindOfClass:[uploadImageOrVideoViewController class]]){
  962. vc = vcArrs[count-3];
  963. }
  964. }
  965. if(vc){
  966. [self.navigationController popToViewController:vc animated:YES];
  967. }
  968. else{
  969. [self.navigationController popViewControllerAnimated:YES];
  970. }
  971. }
  972. - (void)backupsFileRefreshFun:(NSNotification*)not
  973. {
  974. photosBackupsTaskModel *photosBackupsTaskMod = [not object];
  975. //HLog(@"%@",uploadFileDataMod);
  976. if(photosBackupsTaskMod.didBackupsOneFileType){
  977. photosBackupsTaskMod.curTimeInterval = 0;
  978. photosBackupsTaskMod.preTimeInterval = 0;
  979. }
  980. else{
  981. photosBackupsTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  982. }
  983. _rightTableView.photosBackupsIngTaskModel = photosBackupsTaskMod;
  984. }
  985. -(void)gotoDownloadFile:(NSMutableArray*)selectedItems
  986. {
  987. KWeakSelf
  988. [[nasDownloadFileManager shareInstance] addNasDownloadRecordFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  989. weakSelf.didGetDownloadDataType = YES;
  990. [weakSelf handleRemoveIndicator];
  991. if(!Arr ||Arr.count != 3){
  992. HLog(@"数据库出错\n\n\n");
  993. return;
  994. }
  995. //NSMutableArray *curLoadIngArr = Arr[0];
  996. mainBlock(^{
  997. weakSelf.midTableView.outSideDataArr = Arr;
  998. [weakSelf.midTableView reloadDataFun];
  999. //[weakSelf handleUploadingRightButFun];
  1000. });
  1001. }];
  1002. // [[downloadManager shareInstance] handleCouldPhoneFileModelToDownloadFileDataFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  1003. //
  1004. // weakSelf.didGetDownloadDataType = YES;
  1005. // [weakSelf handleRemoveIndicator];
  1006. //
  1007. // if(!Arr ||Arr.count != 3){
  1008. // HLog(@"数据库出错\n\n\n");
  1009. // return;
  1010. // }
  1011. //
  1012. // //NSMutableArray *curLoadIngArr = Arr[0];
  1013. //
  1014. // mainBlock(^{
  1015. // weakSelf.midTableView.outSideDataArr = Arr;
  1016. // [weakSelf.midTableView reloadDataFun];
  1017. // //[weakSelf handleUploadingRightButFun];
  1018. // });
  1019. // }];
  1020. //处理数据埋点
  1021. NSString * firstFileType = nil;
  1022. BOOL isSameFileType = YES;
  1023. for (couldPhoneFileModel*model in selectedItems) {
  1024. if(!firstFileType){
  1025. firstFileType = model.fileType;
  1026. }
  1027. else if(![firstFileType isEqualToString:model.fileType]){
  1028. isSameFileType = NO;
  1029. break;
  1030. }
  1031. }
  1032. if(!isSameFileType){
  1033. //数据埋点
  1034. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"];
  1035. }
  1036. else if([firstFileType containsString:@"jpg"]){
  1037. //数据埋点
  1038. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_download"];
  1039. }
  1040. else if([firstFileType isEqualToString:@"video"]){
  1041. //数据埋点
  1042. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_download"];
  1043. }
  1044. else if([firstFileType isEqualToString:@"audio"]){
  1045. //数据埋点
  1046. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_download"];
  1047. }
  1048. else{
  1049. //数据埋点
  1050. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"];
  1051. }
  1052. }
  1053. #pragma mark nas http下载完成
  1054. - (void)downloadTaskFinishedNoti:(NSNotification *)notification
  1055. {
  1056. //customDownloadOperation *model = notification.object;
  1057. //NSString *url = model.url;
  1058. [self getDownloadDataInDatabaseFun:NO];
  1059. }
  1060. - (void)downloadFileRefreshFun:(NSNotification*)not
  1061. {
  1062. couldPhoneFileModel *downloadTaskMod = [not object];
  1063. if(!downloadTaskMod){
  1064. [_midTableView RefreshAllDataFun];
  1065. return;
  1066. }
  1067. HLog(@"hhhhhhh1 %@ didDownloadBytes:%ld",downloadTaskMod.name,downloadTaskMod.didDownloadBytes);
  1068. downloadTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  1069. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  1070. for (int i=0; i<downloadingArr.count; i++) {
  1071. couldPhoneFileModel*preModel = downloadingArr[i];
  1072. if(preModel.bg_id.integerValue == downloadTaskMod.bg_id.integerValue){
  1073. [_midTableView.downloadingArr replaceObjectAtIndex:i withObject:downloadTaskMod];
  1074. break;
  1075. }
  1076. }
  1077. if(downloadTaskMod.curDownloadStateType == downloadStateDone
  1078. ||downloadTaskMod.curDownloadStateType == downloadStateFail){
  1079. [self getDownloadDataInDatabaseFun:NO];
  1080. }
  1081. else{
  1082. [_midTableView RefreshAllDataFun];
  1083. }
  1084. }
  1085. - (void)downloadFileSuspendAllFun:(NSNotification*)not
  1086. {
  1087. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  1088. for (int i=0; i<downloadingArr.count; i++) {
  1089. couldPhoneFileModel*preModel = downloadingArr[i];
  1090. if(preModel.curDownloadStateType == downloadStateUploading
  1091. ||preModel.curDownloadStateType == downloadStateWait){
  1092. preModel.curDownloadStateType = downloadStateSuspend;
  1093. //break;
  1094. }
  1095. }
  1096. [_midTableView RefreshAllDataFun];
  1097. }
  1098. #pragma mark 1.3版本UI修改后 下载文件列表的头部点击事件
  1099. - (void)didClikRightButInDownloadTableVieFunBy:(NSInteger)section
  1100. {
  1101. if(section == 0){
  1102. [self didClickAllSuspendInDownLoadingFun];
  1103. }
  1104. else if(section == 1){//成功
  1105. [self didClickClearDownLoadRecordInDoneFun];
  1106. }
  1107. else if(section == 2){//失败
  1108. [self didClickClearRecordInDownLoadFailFun];
  1109. }
  1110. }
  1111. #pragma mark 点击下载中的全部暂停
  1112. - (void)didClickAllSuspendInDownLoadingFun
  1113. {
  1114. _midTableView.downloadingHeadView.rightButton.selected = !_midTableView.downloadingHeadView.rightButton.selected;
  1115. if(_midTableView.downloadingHeadView.rightButton.selected){
  1116. [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  1117. }
  1118. else{
  1119. NSMutableArray *leftArr = _midTableView.downloadingArr;
  1120. [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:leftArr withAll:YES];
  1121. }
  1122. }
  1123. #pragma mark 点击下载成功的清空记录
  1124. - (void)didClickClearDownLoadRecordInDoneFun
  1125. {
  1126. /*弹窗提示二次确认*/
  1127. KWeakSelf
  1128. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1129. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  1130. imageStr:@""
  1131. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1132. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1133. didClickOk:^{
  1134. [weakSelf ClearAllRecordInDownloadDoneFun];
  1135. } didClickCancel:^{
  1136. }];
  1137. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1138. [self presentViewController:nextVC animated:YES completion:^{
  1139. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1140. }];
  1141. }
  1142. - (void)ClearAllRecordInDownloadDoneFun
  1143. {
  1144. [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadDoneArr withDelCache:YES];
  1145. }
  1146. #pragma mark 点击下载失败的清空记录
  1147. - (void)didClickClearRecordInDownLoadFailFun
  1148. {
  1149. /*弹窗提示二次确认*/
  1150. KWeakSelf
  1151. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1152. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  1153. imageStr:@""
  1154. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1155. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1156. didClickOk:^{
  1157. [weakSelf ClearAllRecordInDownloadFailFun];
  1158. } didClickCancel:^{
  1159. }];
  1160. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1161. [self presentViewController:nextVC animated:YES completion:^{
  1162. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1163. }];
  1164. }
  1165. - (void)ClearAllRecordInDownloadFailFun
  1166. {
  1167. [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadfailArr withDelCache:YES];
  1168. }
  1169. /**********************************接收相关******************************************/
  1170. - (void)setIsReceiveType:(NSInteger)isReceiveType
  1171. {
  1172. _isReceiveType = isReceiveType;
  1173. KWeakSelf
  1174. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1175. weakSelf.curReceiveView.isReceiveType = isReceiveType;
  1176. [weakSelf.curReceiveView getAllDataFun];
  1177. [weakSelf delayChangeUIFunWithIndex:4];
  1178. });
  1179. }
  1180. #pragma mark 删除云机文件数据
  1181. - (void)delFileListFunWithData:(NSArray*)delDataArr
  1182. {
  1183. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1184. if(delDataArr){
  1185. NSMutableArray*pathArr = [NSMutableArray new];
  1186. for (uploadFileDataModel *uploadFileDataMod in delDataArr) {
  1187. NSString *uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  1188. if(uploadDefaultPath && uploadDefaultPath.length > 0){
  1189. //判断最后一个是否是/
  1190. NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1];
  1191. if(![lastStr isEqualToString:@"/"]){
  1192. uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath];
  1193. }
  1194. NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,uploadFileDataMod.filename];
  1195. [pathArr addObject:savePath];
  1196. }
  1197. }
  1198. [paraDict setValue:pathArr forKey:@"path"];
  1199. }
  1200. //[self showNewIndicatorWithCanBack:YES canTouch:NO];
  1201. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  1202. //KWeakSelf //@"delFile"
  1203. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1204. //[weakSelf removeNewIndicator];
  1205. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1206. if(model && model.status == 0){
  1207. //[[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  1208. }
  1209. else{
  1210. }
  1211. } failure:^(NSError * _Nonnull error) {
  1212. //[weakSelf removeNewIndicator];
  1213. }];
  1214. }
  1215. #pragma mark 跳转传输设置页面
  1216. - (void)gotoTranSettingVCFun
  1217. {
  1218. fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new];
  1219. [self.navigationController pushViewController:nextVC animated:YES];
  1220. }
  1221. #pragma - mark - 监听网络变化
  1222. - (void)networkStateChange:(NSNotification *)notification
  1223. {
  1224. //处理UI变化
  1225. if([AFNetworkReachabilityManager sharedManager].isReachableViaWiFi){//目前是wifi
  1226. HLog("wifi 环境")
  1227. if(_nonWifiTipViewHeight <=0){
  1228. HLog("wifi 环境 并且没有显示流量提示")
  1229. return;//wifi 而且前面没有显示提示开启wifi传输 不需要处理
  1230. }
  1231. _nonWifiTipViewHeight = 0;
  1232. [self RefreshBaseUIFun];
  1233. self.nonWifiTipInRecordV.hidden = YES;
  1234. }
  1235. else if([AFNetworkReachabilityManager sharedManager].isReachableViaWWAN){//目前是流量模式
  1236. BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
  1237. //当前网络为流量 与流量传输没开
  1238. if (!isCanUseCellular) {
  1239. HLog("流量 环境 需要显示流量提示")
  1240. _nonWifiTipViewHeight = 56;
  1241. [self RefreshBaseUIFun];
  1242. self.nonWifiTipInRecordV.hidden = NO;
  1243. }
  1244. else{
  1245. HLog("流量 环境 需要隐藏流量提示")
  1246. _nonWifiTipViewHeight = 0;
  1247. [self RefreshBaseUIFun];
  1248. self.nonWifiTipInRecordV.hidden = YES;
  1249. }
  1250. }
  1251. }
  1252. #pragma mark 更新UI
  1253. - (void)RefreshBaseUIFun
  1254. {
  1255. [self.nonWifiTipInRecordV mas_remakeConstraints:^(MASConstraintMaker *make) {
  1256. make.left.mas_equalTo(15);
  1257. make.right.mas_equalTo(-15);
  1258. make.top.mas_equalTo(self.uploadFileRecordheadV.mas_bottom).offset(0.0);
  1259. make.height.mas_equalTo(_nonWifiTipViewHeight);
  1260. }];
  1261. CGFloat curHeight = SCREEN_H - (H_STATE_BAR + 64.f) - 50 - _nonWifiTipViewHeight - 15;
  1262. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  1263. make.left.mas_equalTo(0);
  1264. make.right.mas_equalTo(0);
  1265. if(_nonWifiTipViewHeight > 0){
  1266. make.top.mas_equalTo(self.nonWifiTipInRecordV.mas_bottom).offset(0.0);
  1267. }
  1268. else{
  1269. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  1270. }
  1271. make.bottom.mas_equalTo(0);
  1272. }];
  1273. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  1274. make.left.mas_equalTo(SCREEN_W*0.0);
  1275. make.width.mas_equalTo(SCREEN_W);
  1276. make.top.mas_equalTo(0);
  1277. make.height.mas_equalTo(curHeight);
  1278. }];
  1279. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  1280. make.left.mas_equalTo(SCREEN_W*1.0);
  1281. make.width.mas_equalTo(SCREEN_W);
  1282. make.top.mas_equalTo(0);
  1283. make.height.mas_equalTo(curHeight);
  1284. }];
  1285. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  1286. make.left.mas_equalTo(SCREEN_W*2.0);
  1287. make.width.mas_equalTo(SCREEN_W);
  1288. make.top.mas_equalTo(0);
  1289. make.height.mas_equalTo(curHeight);
  1290. }];
  1291. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  1292. make.left.mas_equalTo(SCREEN_W*3.0);
  1293. make.width.mas_equalTo(SCREEN_W);
  1294. make.top.mas_equalTo(0);
  1295. make.height.mas_equalTo(curHeight);
  1296. }];
  1297. _uploadFileRecordBgScorllV.contentSize = CGSizeMake(SCREEN_W*4.0, curHeight);
  1298. }
  1299. @end