Kaynağa Gözat

1.app数据缓存

huangxiaodong 2 ay önce
ebeveyn
işleme
ebed1d11fc

+ 63 - 8
创维盒子/code/NAS/NasPreviewAPPViewController.m

@@ -78,6 +78,25 @@
     self.navBarBGView.backgroundColor = [UIColor whiteColor];
     [self.view setBackgroundColor:[UIColor whiteColor]];
     
+    
+    //数据缓存
+    NSString *key = stringKeyAddSn(@"getInstalledApk");
+    NSDictionary *DataDict = [HWDataManager getObjectWithKey:key];
+    if(DataDict){
+        _getInstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:DataDict error:nil];
+        if (_getInstalledAppListMod) {
+            _curInstalledAppListMod = _getInstalledAppListMod;
+        }
+    }
+    
+    //数据缓存
+    NSString *keyUninstall = stringKeyAddSn(@"getUninstallApk");
+    NSDictionary *DataDictUninstall = [HWDataManager getObjectWithKey:keyUninstall];
+    if(DataDictUninstall){
+        _getUninstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:DataDictUninstall error:nil];
+    }
+   
+    
     [self drawAnyView];
     
     _didSelectListArr = [NSMutableArray new];
@@ -625,9 +644,16 @@
 {
     self.appInstallTypeV.hidden = !isDefaultTabType;
     
+    if (isSecondTabType) {
+        _curInstalledAppListMod = _getUninstalledAppListMod;
+    }
+    else{
+        _curInstalledAppListMod = _getInstalledAppListMod;
+    }
+    
     if(isDefaultTabType //&& !isSecondTabType
        ){
-        _curInstalledAppListMod = _getInstalledAppListMod;
+        //_curInstalledAppListMod = _getInstalledAppListMod;
         self.curEditTypeBottomView.isCanDeleteType = NO;
         
         [_searchBarThridTypeV mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -640,7 +666,7 @@
         }];
     }
     else{
-        _curInstalledAppListMod = _getUninstalledAppListMod;
+        //_curInstalledAppListMod = _getUninstalledAppListMod;
         self.curEditTypeBottomView.isCanDeleteType = YES;
         
         [_searchBarThridTypeV mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -901,7 +927,8 @@
     [self showDownloadTipFun];
     [self checkFileTransferTask];
     
-    if(!_getInstalledAppListMod){
+    //if(!_getInstalledAppListMod)
+    {
         [self getFileListFun:NO];
         [self getUninstallAppListFun:NO];
         [self queryShareSwitchFunFun];
@@ -938,11 +965,11 @@
     
     //KWeakSelf
     /*弹窗提示恢复出厂*/
-    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
+    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:@""
                                                                                      msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
-                                                                                imageStr:nil
+                                                                                imageStr:@""
                                                                              cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
-                                                                                 okTitle:nil
+                                                                                 okTitle:@""
                                                                         isOkBtnHighlight:NO
                                                                               didClickOk:^{
         
@@ -1018,10 +1045,25 @@
     [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getInstalledApk" Parameters:paraDict success:^(id  _Nonnull responseObject) {
         //[weakSelf.tableView.mj_footer endRefreshing];
         [weakSelf removeNewIndicatorHaveStr];
-        weakSelf.getInstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
+        getInstalledAppListModel *curModel = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
         
-        if(weakSelf.getInstalledAppListMod && weakSelf.getInstalledAppListMod.status == 0){
+        if(curModel && curModel.status == 0){
+            
+            weakSelf.getInstalledAppListMod = curModel;
             [weakSelf RefreshAllUIFun];
+            
+            NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
+            
+            for (NSString *key in responseObject) {
+                id object = IdDataDict[key];
+                if(!object || [object isKindOfClass:[NSNull class]]){
+                    [IdDataDict removeObjectForKey:key];
+                }
+            }
+            
+            //数据缓存
+            NSString *key = stringKeyAddSn(@"getInstalledApk");
+            [HWDataManager setObjectWithKey:key value:IdDataDict];
         }
         
     } failure:^(NSError * _Nonnull error) {
@@ -1106,6 +1148,19 @@
         
         if(weakSelf.getUninstalledAppListMod && weakSelf.getUninstalledAppListMod.status == 0 ){
             [weakSelf RefreshAllUIFun];
+            
+            NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
+            
+            for (NSString *key in responseObject) {
+                id object = IdDataDict[key];
+                if(!object || [object isKindOfClass:[NSNull class]]){
+                    [IdDataDict removeObjectForKey:key];
+                }
+            }
+            
+            //数据缓存
+            NSString *key = stringKeyAddSn(@"getUninstallApk");
+            [HWDataManager setObjectWithKey:key value:IdDataDict];
         }
         
     } failure:^(NSError * _Nonnull error) {