Browse Source

1.第一个接口跑通

huangxiaodong 1 year ago
parent
commit
993c63ca7c

+ 25 - 68
创维盒子/双子星云手机/Class/Set/previewFile/previewAudioOrDocumentViewController.m

@@ -20,6 +20,8 @@
 #import "editShareView.h"
 #import "previewToUploadFileView.h"
 
+#import "netWorkManager.h"
+
 @interface previewAudioOrDocumentViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
 {
     UIButton *tapBtn;
@@ -59,10 +61,6 @@
     self.navBarBGView.backgroundColor = [UIColor whiteColor];
     [self.view setBackgroundColor:[UIColor whiteColor]];
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(searchFileListDoneFun:) name:searchFileListDoneNotification object:nil];
-    
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didDownloadOneFileFun) name:downloadThumbnailDoneOneNotification object:nil];
-    
     [self drawAnyView];
     
     _didSelectListArr = [NSMutableArray new];
@@ -308,7 +306,6 @@
     }
     
     self.defaultDiskPath = pathStr;
-    //[self searchFileListFun];
     [self setTitleAfterGetdiskFun];
     [self hideDiskListVieFun];
 }
@@ -678,20 +675,20 @@
         [self setTitleLabelText:NSLocalizedString(@"my_set_no_video_upload",nil)];
     }
     
-    [self searchFileListFun];
 }
 
 - (void)viewWillAppear:(BOOL)animated
 {
     [super viewWillAppear:animated];
     
-    
 }
 
 - (void)viewDidAppear:(BOOL)animated{
     [super viewDidAppear:animated];
     [self showDownloadTipFun];
     [self checkFileTransferTask];
+    
+    [self getFileListFun];
 }
 
 - (void)viewWillDisappear:(BOOL)animated{
@@ -701,62 +698,9 @@
     [self removeNewIndicatorHaveStr];
 }
 
-- (void)searchFileListFun
-{
-    NSMutableDictionary *dict = [NSMutableDictionary new];
-    NSNumber *curNum = [NSNumber numberWithBool:_isAudioType];
-    [dict setObject:curNum forKey:@"type"];
-    if(!_defaultDiskPath){
-        _defaultDiskPath = @"";
-    }
-    [dict setObject:_defaultDiskPath forKey:@"path"];
-    
-    [[NSNotificationCenter defaultCenter] postNotificationName:searchFileListBeginNotification object:dict];/*发送通知*/
-    
-    //[self showNewIndicatorWithCanBack:YES canTouch:NO];
-    [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
-    
-}
 
-- (void)searchFileListDoneFun:(NSNotification*)notification
-{
-    //[self removeNewIndicator];
-    [self removeNewIndicatorHaveStr];
-    
-    NSDictionary *dataDict = [notification object];
-    
-    if(!dataDict || ![dataDict isKindOfClass:[NSDictionary class]]){
-        return;
-    }
-    
-    _curCouldPhoneFileListMod = [[couldPhoneFileListModel alloc] initWithDictionary:dataDict error:nil];
-    
-    NSMutableArray *filterArr = [NSMutableArray new];
-    for (couldPhoneFileModel*model in _curCouldPhoneFileListMod.data.list) {
-        //if(model.length > 1024)
-        if(model.length > 1024*50)
-        {
-            [filterArr addObject:model];
-        }
-    }
-    
-    _curCouldPhoneFileListMod.data.list = filterArr;
-    
-    [self.tableView reloadData];
-    //[self.dataCollectionView reloadData];
-    
-    //这个要做判断 不能为空
-    [self gotoDownThumbnailManagerFun];
-}
 
 
-#pragma mark 去下载缩略图
-- (void)gotoDownThumbnailManagerFun
-{
-//    if(_curCouldPhoneFileListMod.data.list && _curCouldPhoneFileListMod.data.list.count >0){
-//        [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailWith:_curCouldPhoneFileListMod.data.list];
-//    }
-}
 
 - (void)gotoDownloadloadFileRecordFun
 {
@@ -797,14 +741,6 @@
     
 }
 
-- (void)didDownloadOneFileFun
-{
-    mainBlock(^{
-        [self.tableView reloadData];
-        //[self.dataCollectionView reloadData];
-    });
-}
-
 
 - (void)checkFileTransferTask
 {//有个偶现的闪退在BGFMDB
@@ -843,4 +779,25 @@
     [self.navigationController pushViewController:vc animated:YES];
 }
 
+#pragma mark 获取文件数据
+- (void)getFileListFun
+{
+    NSMutableDictionary*paraDict = [NSMutableDictionary new];
+    if(_isAudioType){
+        [paraDict setValue:@"audio" forKey:@"type"];
+    }
+    else{
+        [paraDict setValue:@"file" forKey:@"type"];
+    }
+    
+    
+    [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
+    
+    KWeakSelf
+    [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileList" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        [weakSelf removeNewIndicatorHaveStr];
+    } failure:^(NSError * _Nonnull error) {
+        [weakSelf removeNewIndicatorHaveStr];
+    }];
+}
 @end

+ 24 - 70
创维盒子/双子星云手机/Class/Set/previewFile/previewImageOrVideoViewController.m

@@ -60,10 +60,6 @@
     self.navBarBGView.backgroundColor = [UIColor whiteColor];
     [self.view setBackgroundColor:[UIColor whiteColor]];
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(searchFileListDoneFun:) name:searchFileListDoneNotification object:nil];
-    
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didDownloadOneFileFun) name:downloadThumbnailDoneOneNotification object:nil];
-    
     [self drawAnyView];
     
     _didSelectListArr = [NSMutableArray new];
@@ -691,8 +687,6 @@
         //self.titleLabel.text = NSLocalizedString(@"my_set_no_video_upload",nil) ;
         [self setTitleLabelText:NSLocalizedString(@"my_set_no_video_upload",nil)];
     }
-    
-    [self searchFileListFun];
 }
 
 - (void)viewWillAppear:(BOOL)animated
@@ -706,6 +700,8 @@
     [super viewDidAppear:animated];
     [self showDownloadTipFun];
     [self checkFileTransferTask];
+    
+    [self getFileListFun];
 }
 
 - (void)viewWillDisappear:(BOOL)animated{
@@ -715,62 +711,6 @@
     [self removeNewIndicatorHaveStr];
 }
 
-- (void)searchFileListFun
-{
-    NSMutableDictionary *dict = [NSMutableDictionary new];
-    NSNumber *curNum = [NSNumber numberWithBool:_isPhotoType];
-    [dict setObject:curNum forKey:@"type"];
-    if(!_defaultDiskPath){
-        _defaultDiskPath = @"";
-    }
-    [dict setObject:_defaultDiskPath forKey:@"path"];
-    
-    [[NSNotificationCenter defaultCenter] postNotificationName:searchFileListBeginNotification object:dict];/*发送通知*/
-    
-    //[self showNewIndicatorWithCanBack:YES canTouch:NO];
-    [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
-    
-}
-
-- (void)searchFileListDoneFun:(NSNotification*)notification
-{
-    //[self removeNewIndicator];
-    [self removeNewIndicatorHaveStr];
-    
-    NSDictionary *dataDict = [notification object];
-    
-    if(!dataDict || ![dataDict isKindOfClass:[NSDictionary class]]){
-        return;
-    }
-    
-    _curCouldPhoneFileListMod = [[couldPhoneFileListModel alloc] initWithDictionary:dataDict error:nil];
-    
-    NSMutableArray *filterArr = [NSMutableArray new];
-    for (couldPhoneFileModel*model in _curCouldPhoneFileListMod.data.list) {
-        //if(model.length > 1024)
-        if(model.length > 1024*50)
-        {
-            [filterArr addObject:model];
-        }
-    }
-    
-    _curCouldPhoneFileListMod.data.list = filterArr;
-    
-    //[self.tableView reloadData];
-    [self.dataCollectionView reloadData];
-    
-    //这个要做判断 不能为空
-    [self gotoDownThumbnailManagerFun];
-}
-
-
-#pragma mark 去下载缩略图
-- (void)gotoDownThumbnailManagerFun
-{
-//    if(_curCouldPhoneFileListMod.data.list && _curCouldPhoneFileListMod.data.list.count >0){
-//        [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailWith:_curCouldPhoneFileListMod.data.list];
-//    }
-}
 
 - (void)gotoDownloadloadFileRecordFun
 {
@@ -811,14 +751,6 @@
     
 }
 
-- (void)didDownloadOneFileFun
-{
-    mainBlock(^{
-        //[self.tableView reloadData];
-        [self.dataCollectionView reloadData];
-    });
-}
-
 
 - (void)checkFileTransferTask
 {//有个偶现的闪退在BGFMDB
@@ -857,4 +789,26 @@
     [self.navigationController pushViewController:vc animated:YES];
 }
 
+#pragma mark 获取文件数据
+- (void)getFileListFun
+{
+    NSMutableDictionary*paraDict = [NSMutableDictionary new];
+    if(_isPhotoType){
+        [paraDict setValue:@"pic" forKey:@"type"];
+    }
+    else{
+        [paraDict setValue:@"video" forKey:@"type"];
+    }
+    
+    
+    [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
+    
+    KWeakSelf
+    [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileList" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        [weakSelf removeNewIndicatorHaveStr];
+    } failure:^(NSError * _Nonnull error) {
+        [weakSelf removeNewIndicatorHaveStr];
+    }];
+}
+
 @end

+ 1 - 1
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.m

@@ -125,7 +125,7 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
             if(!connected || needReconnect){
                 weakSelf.curConnectDeviceState = DeviceConnectGetThridOK;
                 NSString *ipStr = weakSelf.DeviceThirdIdMod.data.ip;
-                [weakSelf startPingDeviceIp:ipStr];
+                //[weakSelf startPingDeviceIp:ipStr];
                 [weakSelf initRuiyunSDKFun];
             }
             

+ 5 - 1
创维盒子/双子星云手机/netWork/netWorkManager.h

@@ -6,7 +6,7 @@
 //
 
 #import <Foundation/Foundation.h>
-
+#import "connectDeviceManager.h"
 NS_ASSUME_NONNULL_BEGIN
 
 
@@ -31,6 +31,10 @@ typedef void (^netWork_Faild) (NSError *error);
 - (void)CommonGetWithCallBackCode:(NSString *)code Parameters:(NSDictionary *_Nullable)dic success:(netWork_Success)success failure:(netWork_Faild)faildStr;
 
 - (void)doUploadFileToFileServiceWithParams:(NSMutableDictionary *)params data:(NSData *)data success:(netWork_Success)success faild:(netWork_Faild)faildStr;
+
+#pragma mark  afnetwork  post 请求
+- (void)cloudPhoneGETCallBackCode:(NSString*)code  Parameters:(NSDictionary*)dict success:(netWork_Success)success failure:(netWork_Faild)failure;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 42 - 0
创维盒子/双子星云手机/netWork/netWorkManager.m

@@ -262,4 +262,46 @@ static netWorkManager *Game_NetWorkShareInstance = nil;
     }];
 }
 
+- (void)cloudPhoneGETCallBackCode:(NSString*)code  Parameters:(NSDictionary*)dict success:(netWork_Success)success failure:(netWork_Faild)failure
+{
+    
+    //NSString *curServer = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.ip;
+    NSString *curServer = @"192.168.11.248";
+    
+    if(!curServer ||curServer.length ==0){
+        NSDictionary *responseObject = @{@"code" : @(-998), @"msg" : @"ip wrong", @"data" : @""};
+        mainBlock(^{
+            success(responseObject);
+        });
+        return;
+    }
+    
+    NSString *url = [NSString stringWithFormat:@"http://%@:9888/%@",curServer,code];
+    HLog(@"地址:%@ \n接口名称:%@,\n 参数:%@\n",url,code,dict);
+    
+    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
+    
+    if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
+    {// 无网络状态
+        NSDictionary *responseObject = @{@"code" : @(-999), @"msg" : @"当前网络不可用", @"data" : @""};
+        mainBlock(^{
+            success(responseObject);
+        });
+        return;
+    }
+    
+    
+    [manager GET:url parameters:dict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
+        
+        HLog(@"接口名称:%@ 接口返回:%@,\n ",code,responseObject);
+        
+        success(responseObject);
+        
+        
+    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error, id  _Nonnull responseObject) {
+        
+        failure(error);
+        HLog(@"%@", error);
+    }];
+}
 @end