Browse Source

1.修改NPD,将ContentPreview中iSalesDB替换为FileCache。
2.CommonEditor导入ContentPreview。

Pen Li 8 years ago
parent
commit
83444f2a3c

+ 4 - 3
RedAnt ERP Mobile/common/CommonEditor/CommonEditorBannerCell.m

@@ -9,6 +9,7 @@
 #import "CommonEditorBannerCell.h"
 #import "CommonEditorBannerItemCell.h"
 #import "YTPlayerView.h"
+#import "FileCache.h"
 
 @interface CommonEditorBannerCell () <UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
 {
@@ -110,8 +111,8 @@
                 NSLog(@"load img : %@",img_url);
                 if([item_json[@"is_localfile"] boolValue])
                     img_data = [NSData dataWithContentsOfFile:img_url];
-//                else
-//                    img_data = [iSalesDB load_cached_img:file_name loadFrom:img_url];
+                else
+                    img_data = [FileCache load_cached_img:file_name loadFrom:img_url];
             }
             
             if(img_data!=nil)
@@ -133,7 +134,7 @@
                     if(downloadimg_data!=nil)
                     {
                         
-//                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                        [FileCache cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
                         UIImage * img =[UIImage imageWithData:downloadimg_data];
                         [self updateImage:img atIndex:i];

+ 11 - 5
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -50,6 +50,7 @@
 #import "CommonEditorRangeCell.h"
 #import "CommonEditorWebCell.h"
 #import "CommonEditorBannerCell.h"
+#import "ContentPreviewController.h"
 
 
 
@@ -6287,11 +6288,16 @@
 #pragma mark - Banner Delegate
 
 - (void)commonEditorBannerCell:(CommonEditorBannerCell *)cell didClickItemAtIndexPath:(NSIndexPath *)indexPath {
-//    ContentPreviewController *preVC = [[UIStoryboard storyboardWithName:@"PhotoList" bundle:nil] instantiateViewControllerWithIdentifier:@"ContentPreviewController"];
-//    preVC.content = [cell content];
-//
-//    [preVC setOffset:indexPath.row];
-//    [self presentViewController:preVC animated:true completion:nil];
+   
+    ContentPreviewController *preVC = [[UIStoryboard storyboardWithName:@"PhotoList" bundle:nil] instantiateViewControllerWithIdentifier:@"ContentPreviewController"];
+    preVC.content = [cell content];
+
+    [preVC setOffset:indexPath.row];
+    if (self.navigationController) {
+        [self.navigationController pushViewController:preVC animated:YES];
+    } else {
+        [self presentViewController:preVC animated:true completion:nil];
+    }
 }
 
 @end

+ 14 - 8
RedAnt ERP Mobile/common/PhotoList/Controller/ContentPreviewController.m

@@ -9,10 +9,8 @@
 #import "ContentPreviewController.h"
 #import "PhotoPreviewCell.h"
 #import "VideoPreviewCell.h"
-
-#import "iSalesDB.h"
 #import "AppDelegate.h"
-
+#import "FileCache.h"
 
 @interface ContentPreviewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
 
@@ -355,7 +353,7 @@
         if([item_json[@"is_localfile"] boolValue])
             img_data = [NSData dataWithContentsOfFile:img_url];
         else
-            img_data = [iSalesDB load_cached_img:file_name loadFrom:img_url];
+            img_data = [FileCache load_cached_img:file_name loadFrom:img_url];
     }
     
     // 设置Image
@@ -371,7 +369,11 @@
     else
     {
         NSData*  downloadimg_data = nil;
-        if (!appDelegate.offline_mode) {
+        BOOL offline_mode = NO;
+#ifdef OFFLINE_MODE
+        offline_mode = appDelegate.offline_mode;
+#endif
+        if (!offline_mode) {
             downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
         }
         dispatch_async(dispatch_get_main_queue(), ^{
@@ -381,7 +383,7 @@
             if(downloadimg_data!=nil)
             {
                 
-                [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                [FileCache cache_img:downloadimg_data filename:file_name saveTo:img_url];
                 
                 UIImage * img =[UIImage imageWithData:downloadimg_data];
                 [cell setPhoto:img];
@@ -405,8 +407,12 @@
 
 - (IBAction)closeBtnClick:(UIButton *)sender {
     
-    self.navigationController.navigationBarHidden = self.hideNavigationBar;
-    [self.navigationController popViewControllerAnimated:YES];
+    if (self.navigationController) {
+        self.navigationController.navigationBarHidden = self.hideNavigationBar;
+        [self.navigationController popViewControllerAnimated:YES];
+    } else {
+        [self dismissViewControllerAnimated:YES completion:nil];
+    }
     
 }