uploadFileRecordViewController.m 54 KB

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