Просмотр исходного кода

规范Apex Mobile部分网络请求出错后的提示
Apex Mobile detail 网络请求失败后,增加提示消息。
底层网络接口增加网络不可用时的默认错误消息。
修复网络不可用时,文档下载失败,提示为空的bug。

Ray Zhang 6 лет назад
Родитель
Сommit
b383708792

+ 2 - 2
Apex Mobile/Apex Mobile/Base.lproj/Localizable.strings

@@ -6,7 +6,7 @@
   Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
 */
 "net_not_available"="Network connection is not available, please check.";
-"net_error"="Network error, can not access server.";
+"net_error"="Can not connect to the server, please try again later.";
 "auth_error"="Can not login, user or password may not correct.";
 "ver_low"="Current App version is too low, please update.";
 "about_appinfo" = "Apex Mobile\n\nVersion:%@\nSupport:USAIRedAnt@united-us.net";
@@ -20,7 +20,7 @@
 "no_more"="No more";
 "loading"="Loading...";
 "new_message" = "New message from Apex";
-"alert_title_error"="Error";
+"alert_title_error"="Warning";
 "alert_msg_upcanotempty"="User&Password can not be empty!";
 "alert_msg_customizefield"="At least keep one field visiable.";
 

+ 1 - 1
Apex Mobile/Apex Mobile/DetailContent.h

@@ -17,7 +17,7 @@
 -(NSString*) get_segmentname : (long)seg;
 -(NSDictionary*)get_item_seg :(long)seg row:(long)row;
 @property int result_code;
-
+@property (strong,nonatomic) NSString* err_msg;
 //-(float) itemHeightAtIndexPath:(NSIndexPath *)indexPath;
 //-(void) set_itemheight:(float)height AtIndexPath:(NSIndexPath *)indexPath;
 @property (strong,nonatomic) NSArray* segments;

+ 12 - 1
Apex Mobile/Apex Mobile/DetailPageViewController.m

@@ -347,7 +347,18 @@
             {
                 self.table.hidden =false;
                 [self.table reloadData];
-                
+                UIAlertController *alertVC = [UIAlertController alertControllerWithTitle: @"Warning"
+                                                                                              message: self.content.err_msg
+                                                                                       preferredStyle: UIAlertControllerStyleAlert];
+                UIAlertAction *action_back = [UIAlertAction actionWithTitle:@"Back" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+                    [weakSelf.navigationController popViewControllerAnimated:false];
+                }];
+                UIAlertAction *action_reload = [UIAlertAction actionWithTitle:@"Reload" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                    [weakSelf ReloadData];
+                }];
+                [alertVC addAction:action_back];
+                [alertVC addAction:action_reload];
+                [weakSelf presentViewController:alertVC animated:YES completion:nil];
             }
             else
             if([self.content get_segmentcount]==0)

+ 14 - 2
Apex Mobile/Apex Mobile/RANetwork.m

@@ -1894,7 +1894,12 @@
             [appDelegate Logout];
             return RESULT_NET_NOTAVAILABLE;
         }
-        
+        if(result==RESULT_NET_ERROR)
+        {
+            DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
+            [appDelegate Logout];
+            return RESULT_NET_ERROR;
+        }
         if(result!=AP_USER_AUTH)
         {
             DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
@@ -2318,9 +2323,15 @@
         DetailContent * detailContent = [[DetailContent alloc] init];
         NSMutableArray* segments = [[NSMutableArray alloc] init];
         detailContent.segments = segments;
-        if(![NetworkUtils IsNetworkAvailable])
+//        if(![NetworkUtils IsNetworkAvailable])
+//        {
+//            detailContent.result_code = RESULT_NET_NOTAVAILABLE;
+//            return detailContent;
+//        }
+        if([jsobj[@"result"]intValue]== RESULT_NET_NOTAVAILABLE)
         {
             detailContent.result_code = RESULT_NET_NOTAVAILABLE;
+            detailContent.err_msg =  NSLocalizedString(@"net_not_available", nil);
             return detailContent;
         }
         if (jsobj==nil)
@@ -2362,6 +2373,7 @@
             {
                 DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
                 detailContent.result_code = result;
+                detailContent.err_msg = jsobj[@"err_msg"];
                 return detailContent;
                 
             }

+ 1 - 1
Apex Mobile/Apex Mobile/Result/Presenter/ApexResultPresenter.m

@@ -412,7 +412,7 @@ static const NSInteger detal = 20;
                 
             } else {
                 
-                NSString *msg = [result objectForKey:@"msg"];
+                NSString *msg = [result objectForKey:@"err_msg"];
                 [self.delegate onFailed:msg];
             }
         };

+ 1 - 1
Apex Mobile/Apex Mobile/config.h

@@ -13,7 +13,7 @@
 # ifdef DEBUG
 #define DEBUG_DB
 
-//#define test_server
+#define test_server
 //#define old_server
 
 # endif