Bläddra i källkod

1.修改iOS Apex Drivers离线Detail Action过滤。
2.修改iOS Apex Drivers离线文件压缩。

Pen Li 7 år sedan
förälder
incheckning
2b2c91d230

+ 6 - 0
Redant Drivers/Apex And Drivers.xcodeproj/project.pbxproj

@@ -32,6 +32,7 @@
 		420D11262133F7E200149B37 /* RAOrderFilterViewController+DataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 420D11252133F7E200149B37 /* RAOrderFilterViewController+DataSource.m */; };
 		420D11292133F7F600149B37 /* RAOrderFilterViewController+TableDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 420D11282133F7F600149B37 /* RAOrderFilterViewController+TableDelegate.m */; };
 		420D112B2133F98600149B37 /* fake_order_filter.json in Resources */ = {isa = PBXBuildFile; fileRef = 420D112A2133F98600149B37 /* fake_order_filter.json */; };
+		4212ABE32192BE0F00E3317C /* RAArchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 4212ABE22192BE0F00E3317C /* RAArchiver.m */; };
 		421C417621719EB500835447 /* RALoginNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 421C417521719EB500835447 /* RALoginNavigationController.m */; };
 		421C417921719F8100835447 /* RALoginBackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 421C417821719F8100835447 /* RALoginBackgroundView.m */; };
 		421C43ED217EEF0600D80B82 /* RAReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 421C43EC217EEF0600D80B82 /* RAReachability.m */; };
@@ -260,6 +261,8 @@
 		420D11272133F7F600149B37 /* RAOrderFilterViewController+TableDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RAOrderFilterViewController+TableDelegate.h"; sourceTree = "<group>"; };
 		420D11282133F7F600149B37 /* RAOrderFilterViewController+TableDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RAOrderFilterViewController+TableDelegate.m"; sourceTree = "<group>"; };
 		420D112A2133F98600149B37 /* fake_order_filter.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = fake_order_filter.json; sourceTree = "<group>"; };
+		4212ABE12192BE0F00E3317C /* RAArchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAArchiver.h; sourceTree = "<group>"; };
+		4212ABE22192BE0F00E3317C /* RAArchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RAArchiver.m; sourceTree = "<group>"; };
 		421C417421719EB500835447 /* RALoginNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RALoginNavigationController.h; sourceTree = "<group>"; };
 		421C417521719EB500835447 /* RALoginNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RALoginNavigationController.m; sourceTree = "<group>"; };
 		421C417721719F8100835447 /* RALoginBackgroundView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RALoginBackgroundView.h; sourceTree = "<group>"; };
@@ -919,6 +922,8 @@
 		42529D2C20C0EA3F000C0F4D /* zip */ = {
 			isa = PBXGroup;
 			children = (
+				4212ABE12192BE0F00E3317C /* RAArchiver.h */,
+				4212ABE22192BE0F00E3317C /* RAArchiver.m */,
 				42529D2D20C0EA3F000C0F4D /* minizip */,
 				42529D3720C0EA3F000C0F4D /* ZipArchive.h */,
 				42529D3820C0EA3F000C0F4D /* ZipArchive.mm */,
@@ -1703,6 +1708,7 @@
 				4281100220E4D47000315156 /* JLRefreshHeader.m in Sources */,
 				42529D4020C0EA59000C0F4D /* Reachability.m in Sources */,
 				4255EC9320C526FE00E5DA24 /* RAEditBaseModel.m in Sources */,
+				4212ABE32192BE0F00E3317C /* RAArchiver.m in Sources */,
 				42529D3920C0EA3F000C0F4D /* ioapi.c in Sources */,
 				42D8B8B720C24656001C125F /* RADetailActionsCell.m in Sources */,
 				425959832148F83C00F7DD41 /* RASettingOptionCell.m in Sources */,

+ 3 - 3
Redant Drivers/Apex And Drivers/AppDelegate.m

@@ -169,9 +169,9 @@
     }];
 #endif
     
-//    [RADataProvider downloadOfflineData];
-//    [RASingleton sharedInstance].offline = YES;
-        
+    [RADataProvider downloadOfflineData];
+    [RASingleton sharedInstance].offline = YES;
+    
     // View
     
     self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];

+ 30 - 24
Redant Drivers/Apex And Drivers/Offline/RAOfflineHandler.m

@@ -8,12 +8,12 @@
 
 #import "RAOfflineHandler.h"
 #import "NetworkUtils.h"
-#import "ZipArchive.h"
 #import "RADetailBaseModel.h"
 #import "RAHomeOrderModel.h"
 #import "RADetailActionModel.h"
 #import "AppDelegate.h"
 #import "RAEditImageBaseModel.h"
+#import "RAArchiver.h"
 
 #define Lock() dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER)
 #define Unlock() dispatch_semaphore_signal(_lock)
@@ -405,14 +405,7 @@ static dispatch_semaphore_t _lock;
  */
 - (BOOL)_unzipOfflineZip:(NSString *)path toDir:(NSString *)to {
     
-    ZipArchive *zip = [[ZipArchive alloc] init];
-    BOOL zipRes = [zip UnzipOpenFile:path Password:self.zipPassword];
-    if (zipRes) {
-        zipRes = [zip UnzipFileTo:to overWrite:YES];
-    }
-    [zip UnzipCloseFile];
-    
-    return zipRes;
+    return [RAArchiver ra_unzipOfflineZip:path toDir:to withPassword:self.zipPassword];
 }
 
 /**
@@ -422,21 +415,12 @@ static dispatch_semaphore_t _lock;
  */
 - (NSString *)_zipDir:(NSString *)dir {
     
-    NSString *name = [[dir lastPathComponent] stringByAppendingString:@".zip"];
-    NSString *zipFile = [[dir stringByDeletingLastPathComponent] stringByAppendingPathComponent:name];
+    NSString *zipFile = [dir stringByAppendingPathExtension:@"zip"];
     
-    ZipArchive *zip = [[ZipArchive alloc] init];
-    [zip CreateZipFile2:zipFile Password:self.zipPassword];
-    
-    NSFileManager *fm = [NSFileManager defaultManager];
-    NSArray *list = [fm contentsOfDirectoryAtPath:dir error:nil];
-    for (NSString *imgPath in list) {
-        [zip addFileToZip:imgPath newname:imgPath.lastPathComponent];
+    if ([RAArchiver ra_zipFile:dir withPassword:self.zipPassword]) {
+        return zipFile;
     }
-    
-    [zip CloseZipFile2];
-    
-    return zipFile;
+    return nil;
 }
 
 /**
@@ -457,10 +441,15 @@ static dispatch_semaphore_t _lock;
     
     // 一层层解开,获取到目标值后作出修改,然后反向一层层的套回去
     NSMutableArray<NSDictionary *> *sections = [[detail objectForKey:@"sections"] mutableCopy];
+    
+    NSMutableIndexSet *rmSectionArr = [NSMutableIndexSet indexSet];
+    
     [sections enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
         
         NSMutableDictionary *section = [obj mutableCopy];
         NSMutableArray<NSDictionary *> *values = [[section objectForKey:@"values"] mutableCopy];
+        
+        NSMutableIndexSet *rmValueArr = [NSMutableIndexSet indexSet];
         [values enumerateObjectsUsingBlock:^(NSDictionary *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
             
             int type = [[obj objectForKey:@"type"] intValue];
@@ -477,16 +466,33 @@ static dispatch_semaphore_t _lock;
                     
                 }];
                 [actions removeObjectsInArray:rmArr];
+                
+                if (actions.count == 0) {
+                    [rmValueArr addIndex:idx];
+                }
+                
                 [mObj setObject:actions forKey:@"actions"];
                 [values replaceObjectAtIndex:idx withObject:mObj];
             }
             
-            
-            
         }];
+        
+        if (rmValueArr.count > 0) {
+            [values removeObjectsAtIndexes:rmValueArr];
+        }
+        
+        if (values.count == 0) {
+            [rmSectionArr addIndex:idx];
+        }
+        
         [section setObject:values forKey:@"values"];
         [sections replaceObjectAtIndex:idx withObject:section];
     }];
+    
+    if (rmSectionArr.count > 0) {
+        [sections removeObjectsAtIndexes:rmSectionArr];
+    }
+    
     [detail setObject:sections forKey:@"sections"];
     
     return detail;

+ 0 - 1
Redant Drivers/Apex And Drivers/RADataProvider.m

@@ -8,7 +8,6 @@
 
 #import "RADataProvider.h"
 #import "NetworkUtils.h"
-#import "ZipArchive.h"
 #import "AESCrypt.h"
 #import "RAOfflineHandler.h"
 #import <CoreLocation/CoreLocation.h>

+ 0 - 45
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -18,7 +18,6 @@
 #import "RAEditMultPhotoModel.h"
 
 #import "RAProgressHUD.h"
-#import "ZipArchive.h"
 #import "AppDelegate.h"
 #import "UIScrollView+Empty.h"
 #import "RAEmptyView.h"
@@ -852,50 +851,6 @@
     return photoArr;
 }
 
-//- (NSMutableDictionary *)preparePackage {
-//
-//    NSMutableDictionary *params = [NSMutableDictionary dictionary];
-//    NSInteger photoCount = [self prepareParams:params].count;
-//    NSString *photoDir = [self photoDir];
-//
-//    NSMutableDictionary *task = [@{
-//                                   @"order" : self.orderID,
-//                                   @"action" : self.actionTitle,
-//                                   @"url" : URL_HOST,
-//                                   @"noFile" : @(YES)
-//                                  } mutableCopy];
-//
-//    if (photoCount > 0) {
-//
-//        // 压缩文件
-//        NSString *zipPath = [photoDir stringByAppendingPathExtension:@".zip"];
-//        ZipArchive *zip = [[ZipArchive alloc] init];
-//        [zip CreateZipFile2:zipPath];
-//        NSArray *subPaths = [[NSFileManager defaultManager] subpathsAtPath:photoDir];
-//        for (NSString *subPath in subPaths) {
-//            NSString *fullPath = [photoDir stringByAppendingPathComponent:subPath];
-//            BOOL isDir;
-//            if([[NSFileManager defaultManager] fileExistsAtPath:fullPath isDirectory:&isDir]) {
-//                if (!isDir) {
-//                    [zip addFileToZip:fullPath newname:subPath];
-//                }
-//            }
-//        }
-//        [zip CloseZipFile2];
-//
-//        [[NSFileManager defaultManager] removeItemAtPath:photoDir error:nil];
-//
-//        NSString *md5 = [RAUtils md5WithFile:zipPath];
-//
-//        [params setObject:md5 forKey:@"md5"];
-//        [task setObject:@"file" forKey:zipPath.lastPathComponent];
-//    }
-//
-//    [task setObject:params forKey:@"params"];
-//
-//    return task;
-//}
-
 #pragma mark - Offline
 
 - (NSDictionary *)offlineUpdate:(NSDictionary *)params photos:(NSArray *)photos {