Browse Source

Merge pull request #734 in DESIGN/design from ~RICHIE/design:release/10.0 to release/10.0

* commit '8094f08ff919fa8a6508ef7f5b70dc44c1844c44':
  KERNEL-216 去掉奇葩的JsonDecode使用
bugfix/10.0
richie 6 years ago
parent
commit
290ef45089
  1. 11
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  2. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java

11
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -17,10 +17,11 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchMana
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager;
import com.fr.general.ProcessCanceledException; import com.fr.general.ProcessCanceledException;
import com.fr.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
import com.fr.json.JSON;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.json.JSONUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.List; import java.util.List;
@ -110,7 +111,7 @@ public class AlphaFineHelper {
public static SearchResult getModelListFromJSONArray(String result, String keyword) throws ClassCastException, JSONException { public static SearchResult getModelListFromJSONArray(String result, String keyword) throws ClassCastException, JSONException {
SearchResult allModelList = new SearchResult(); SearchResult allModelList = new SearchResult();
JSONArray jsonArray = (JSONArray) JSONUtils.jsonDecode(result); JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, result);
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();
JSONObject jsonObject = jsonArray.optJSONObject(i); JSONObject jsonObject = jsonArray.optJSONObject(i);
@ -128,11 +129,12 @@ public class AlphaFineHelper {
/** /**
* 网络异常时的处理 * 网络异常时的处理
*
* @param object * @param object
* @return * @return
*/ */
public static SearchResult getNoConnectList(Object object) { public static SearchResult getNoConnectList(Object object) {
if (isNetworkOk()){ if (isNetworkOk()) {
return null; return null;
} }
SearchResult result = new SearchResult(); SearchResult result = new SearchResult();
@ -153,9 +155,10 @@ public class AlphaFineHelper {
/** /**
* 判断网络是否异常 * 判断网络是否异常
*
* @return * @return
*/ */
public static boolean isNetworkOk(){ public static boolean isNetworkOk() {
try { try {
HttpToolbox.get(URL_FOR_TEST_NETWORK); HttpToolbox.get(URL_FOR_TEST_NETWORK);
return true; return true;

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java

@ -6,8 +6,10 @@ import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.cell.model.RobotModel; import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
import com.fr.json.JSON;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.json.JSONUtils; import com.fr.json.JSONUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -73,7 +75,7 @@ public class HotIssuesManager {
try { try {
String result = HttpToolbox.get(AlphaFineConstants.ALPHA_HOT_SEARCH); String result = HttpToolbox.get(AlphaFineConstants.ALPHA_HOT_SEARCH);
JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result); JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, result);
if(jsonArray != null){ if(jsonArray != null){
for (int i = 0; i < HOT_ITEM_NUM; i++) { for (int i = 0; i < HOT_ITEM_NUM; i++) {
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();

Loading…
Cancel
Save