Ver Fonte

Modify the default prompt message that the background interface returns an error -- 修改后台接口返回出错的默认提示消息(resolve: #14533)
Log in with a non-existent account, prompt message error -- 用不存在的账号登陆,提示消息错误(resolve: #14534)
common editor adds the editing function for date type -- common editor 增加对日期类型的编辑功能 (resolve: #14532)
Add logic, the dirty data can be discarded after the control refresh -- 添加控件刷新后可以抛弃脏数据逻辑(resolve: #14535)

Ray Zhang há 4 anos atrás
pai
commit
43a1c3dab7

+ 62 - 40
ApexDrivers/CommonEditorLib/src/main/java/com/usai/commoneditorlib/CommonEditorActivity.java

@@ -613,6 +613,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
             JSONObject sub_action = item_json.optJSONObject("item_" + subaction_tag);
             int refresh = sub_action.optInt("refresh");
+            boolean discardDirty =sub_action.optBoolean("discarddirty");
             String refresh_trigger = sub_action.optString("name");
             JSONObject restore_json = sub_action.optJSONObject("restore");
 
@@ -767,7 +768,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                     }
                 }
 
-                refresh(refresh_trigger);
+                refresh(refresh_trigger,discardDirty);
                 return;
             }
             adapter.notifyDataSetChanged();
@@ -775,6 +776,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             // is_subaction
         } else {
             int refresh = item_json.optInt("refresh");
+            boolean discardDirty = item_json.optBoolean("discardDirty");
             String refresh_trigger = item_json.optString("name");
             JSONObject restore_json = item_json.optJSONObject("restore");
 
@@ -916,7 +918,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                     }
                 }
 
-                refresh(refresh_trigger);
+                refresh(refresh_trigger,discardDirty);
                 return;
             }
 
@@ -1123,7 +1125,13 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
     }
 
     public int url_type = URL_REMOTE;
-    public void refresh(String trigger) {
+
+//    public void refresh(String trigger)
+//    {
+//        refresh(trigger,false);
+//    }
+
+    public void refresh(String trigger,boolean discardDirty) {
 
         if (lastEditText != null) {
             endEditting();
@@ -1167,7 +1175,12 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                                 return;
                             }
                             if (Integer.valueOf(editor_json.optString("result")) == 2) {
-                                content_data_download = copyDirtyTo(content_data_download,editor_json);
+
+                                if(!discardDirty)
+                                {
+                                    content_data_download = copyDirtyTo(content_data_download,editor_json);
+                                }
+
                                 content_data_control = translateChange(content_data_download,changed_data);
 
                                 download_success();
@@ -2392,61 +2405,63 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
         {
             item_json.put("value",value);
             item_json.put("dirty",true);
-        } catch (JSONException e)
-        {
-            e.printStackTrace();
-        }
 
         if(TextUtils.isEmpty(subid))
         {
-            section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+            section_json =content_data_download.optJSONObject("section_"+groupindex);
+//            JSONObject item_json = ((JSONArray)content_data_control.getJSONArray(group)).getJSONObject(child);
+//        [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
             int count=0;
 
-            count=[[section_json valueForKey:@"count"] intValue];
+            count=section_json.optInt("count");
 
             for(int i=0;i<count;i++)
             {
-                NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]];
-                if([[olditem valueForKey:@"name"] isEqualToString:[item_json valueForKey:@"name" ]])
-                [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",i ]];
-
+                JSONObject  olditem=section_json.optJSONObject("item_"+i);
+                if(olditem.optString("name").equals(item_json.optString("name")))
+                {
+                   section_json.put("item_"+i,item_json);
 
+                }
             }
 
         }
         else
         {
-            NSArray* idarr=[subid componentsSeparatedByString:@"_"];
-            int section = [(String)idarr[0] intValue];
-            int item=[(String)idarr[1] intValue];
+            String [] idarr=subid.split("_");
 
+            int section = Integer.parseInt(idarr[0]);
+            int item=Integer.parseInt(idarr[1]);
 
-            section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
-            NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]];
-            item_json= [self enum_subitem_changed:[olditem mutableCopy] subid:idarr value:item_json step:2];
-        [item_json setValue:@"true" forKey:@"dirty"];
-        [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",item ]];
-        }
 
+            section_json =content_data_download.optJSONObject("section_"+section);
+            JSONObject  olditem=section_json.optJSONObject("item_"+item);
 
+            item_json = enum_subitem_changed(olditem,idarr,item_json,2);
 
-    [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
 
-        self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
+                item_json.put("dirty",true);
+            section_json.put("item_"+item,item_json);
+
+        }
+
+            content_data_download.put("section_"+groupindex,section_json);
+
+            content_data_control = translateChange(content_data_download,changed_data);
+
 
         //  NSRange range = NSMakeRange(indexPath.section, 1);
         //   NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
         //  [self.editorTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
 
-
-        if(refresh==1)
+        } catch (JSONException e)
         {
-            if(!discardDirty)
-            [self refresh:refresh_trigger] ;
-        else
-            [self refresh:refresh_trigger discardDirty:true];
+            e.printStackTrace();
         }
-    [self.editorTable reloadData ];
+
+
+            refresh(refresh_trigger,discardDirty);
+        adapter.notifyDataSetChanged();
     }
 
 
@@ -3509,6 +3524,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             JSONObject section_json = null;
             JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
             int refresh = item_json.optInt("refresh");
+            boolean discardDirty = item_json.optBoolean("discarddirty");
             String refresh_trigger = item_json.optString("name");
             String subid = item_json.optString("subid");
             item_json.put("img_url_" + index,url_down);
@@ -3543,9 +3559,9 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             content_data_download.put("section_" + group,section_json);
             content_data_control = translateChange(content_data_download,changed_data);
 
-            if (refresh == 1) {
-                refresh(refresh_trigger);
-            }
+
+                refresh(refresh_trigger,discardDirty);
+
 
             adapter.notifyDataSetChanged();
 
@@ -3571,6 +3587,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
 
             int refresh = item_json.optInt("refresh");
+            boolean discardDirty = item_json.optBoolean("discarddirty");
             String refresh_trigger = item_json.optString("name");
             String subid = item_json.optString("subid");
             String check = "false";
@@ -3612,7 +3629,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                 adapter.notifyDataSetChanged();
 
                 if (refresh == 1) {
-                    refresh(refresh_trigger);
+                    refresh(refresh_trigger,discardDirty);
                 }
 
 
@@ -3642,6 +3659,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             int i = Integer.valueOf(arr[2]);
 
             int refresh = 0;
+            boolean discardDirty = false;
             JSONObject section_json = null;
             JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
             String subid = item_json.optString("subid");
@@ -3654,6 +3672,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                 // end edit
 
                 refresh = sub_action.optInt("refresh");
+                discardDirty = sub_action.optBoolean("discarddirty");
                 JSONObject keymap = sub_action.optJSONObject("key_map");
                 JSONObject value = create_value_map(keymap);
 
@@ -3728,7 +3747,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                 }
 
                 if (refresh == 1) {
-                    refresh(refresh_trigger);
+                    refresh(refresh_trigger,discardDirty);
                     return;
                 }
                 adapter.notifyDataSetChanged();
@@ -4144,6 +4163,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                 content_data_control = translateChange(content_data_download,changed_data);
 
                 int refresh = item_json.optInt("refresh");
+                boolean discardDirty = item_json.optBoolean("discarddirty");
                 JSONObject restore_json = item_json.optJSONObject("restore");
                 boolean partial_refresh = item_json.optBoolean("partial_refresh");
                 if (refresh == 1) {
@@ -4167,7 +4187,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                             }
                         }
                     }
-                    refresh(refresh_trigger);
+                    refresh(refresh_trigger,discardDirty);
 
                 } // refresh == 1
                 else if (partial_refresh) {
@@ -4241,6 +4261,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                 content_data_control = translateChange(content_data_download,changed_data);
 
                 int refresh = item_json.optInt("refresh");
+                boolean discardDirty = item_json.optBoolean("discarddirty");
                 JSONObject restore_json = item_json.optJSONObject("restore");
                 boolean partial_refresh = item_json.optBoolean("partial_refresh");
                 if (refresh == 1) {
@@ -4264,7 +4285,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                             }
                         }
                     }
-                    refresh(refresh_trigger);
+                    refresh(refresh_trigger,discardDirty);
 
                 } // refresh == 1
                 else if (partial_refresh) {
@@ -4378,6 +4399,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
 
             int refresh = item_json.optInt("refresh");
+            boolean discardDirty = item_json.optBoolean("discarddirty");
             String refresh_trigger = item_json.optString("name");
             String subid = item_json.optString("subid");
 
@@ -4433,7 +4455,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                         }
                     }
                 }
-                refresh(refresh_trigger);
+                refresh(refresh_trigger,discardDirty);
                 return;
             }
             adapter.notifyDataSetChanged();

+ 14 - 3
ApexDrivers/ratradefiling/src/main/java/com/usai/ratradefiling/login/LoginFragment.java

@@ -40,6 +40,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import static com.usai.redant.rautils.utils.Network.RESULT_AUTH_EXPIRED;
+import static com.usai.redant.rautils.utils.Network.RESULT_FAILED_WITH_MESSAGE;
 import static com.usai.redant.rautils.utils.Network.RESULT_TRUE;
 //import com.usai.util.AES;
 //import com.usai.util.Network;
@@ -486,6 +487,8 @@ public class LoginFragment extends Fragment/* implements OnClickListener */
 							return;
 						}
 						case OnlineDataProvider.RESULT_ERROR:
+
+						case RESULT_FAILED_WITH_MESSAGE:
 							// case Network.RESULT_RESPONSE_NULL:
 						{
 
@@ -506,10 +509,18 @@ public class LoginFragment extends Fragment/* implements OnClickListener */
 							return;
 
 						}
+
 						default: {
-							Toast toast = Toast.makeText(getActivity()
-											.getApplicationContext(),
-									getText(R.string.msg_net_resulterror), Toast.LENGTH_LONG);
+
+
+							String msg =  json.optString("err_msg");
+
+							if(TextUtils.isEmpty(msg))
+								msg=getText(R.string.msg_net_resulterror).toString();
+							Toast toast = Toast.makeText(
+									getActivity().getApplicationContext(),
+									msg,
+									Toast.LENGTH_LONG);
 							toast.setGravity(Gravity.CENTER, 0, 0);
 							toast.show();
 							break;

+ 1 - 1
ApexDrivers/ratradefiling/src/main/res/values-zh/strings.xml

@@ -17,7 +17,7 @@
     <string name="error_invalid_email">This email address is invalid</string>
     <string name="msg_connection_none">No available connection </string>
     <string name="msg_net_error">Can not connect to server</string>
-    <string name="msg_net_resulterror">Can not connect to the server, please contact admin.</string>
+    <string name="msg_net_resulterror">Can not connect to the server, please contact administrator.</string>
     <string name="str_invalid_pore">Invalid user name or email</string>
     <string name="str_ver">ver:</string>
     <string name="msg_ver_low">Client version is too low</string>

+ 1 - 1
ApexDrivers/ratradefiling/src/main/res/values/strings.xml

@@ -20,7 +20,7 @@
     <string name="error_invalid_email">This email address is invalid</string>
     <string name="msg_connection_none">No available connection </string>
     <string name="msg_net_error">Can not connect to server</string>
-    <string name="msg_net_resulterror">Can not connect to the server, please contact admin.</string>
+    <string name="msg_net_resulterror">Can not connect to the server, please contact administrator.</string>
     <string name="str_invalid_pore">Invalid user name or email</string>
     <string name="str_ver">Ver:</string>
     <string name="msg_ver_low">Client version is too low</string>