uploadFileRecordViewController.m 55 KB

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