uploadFileRecordViewController.m 56 KB

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