|
|
@ -12,6 +12,7 @@ import com.fr.general.FRLogger; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.json.JSONArray; |
|
|
|
import com.fr.json.JSONArray; |
|
|
|
|
|
|
|
import com.fr.json.JSONException; |
|
|
|
import com.fr.json.JSONObject; |
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
@ -24,7 +25,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { |
|
|
|
private static PluginSearchManager pluginSearchManager = null; |
|
|
|
private static PluginSearchManager pluginSearchManager = null; |
|
|
|
|
|
|
|
|
|
|
|
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN); |
|
|
|
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN); |
|
|
|
|
|
|
|
private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN); |
|
|
|
|
|
|
|
|
|
|
|
private SearchResult lessModelList; |
|
|
|
private SearchResult lessModelList; |
|
|
|
private SearchResult moreModelList; |
|
|
|
private SearchResult moreModelList; |
|
|
@ -58,33 +59,32 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { |
|
|
|
JSONObject jsonObject = new JSONObject(result); |
|
|
|
JSONObject jsonObject = new JSONObject(result); |
|
|
|
JSONArray jsonArray = jsonObject.optJSONArray("result"); |
|
|
|
JSONArray jsonArray = jsonObject.optJSONArray("result"); |
|
|
|
if (jsonArray != null) { |
|
|
|
if (jsonArray != null) { |
|
|
|
int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); |
|
|
|
SearchResult searchResult = new SearchResult(); |
|
|
|
for (int i = 0; i < length; i++) { |
|
|
|
for (int i = 0; i < jsonArray.length(); i++) { |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
|
|
|
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); |
|
|
|
|
|
|
|
this.lessModelList.add(cellModel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i = length; i < jsonArray.length(); i++) { |
|
|
|
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
|
|
|
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); |
|
|
|
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); |
|
|
|
this.moreModelList.add(cellModel); |
|
|
|
if (!AlphaFineHelper.getFilterResult().contains(cellModel)) { |
|
|
|
|
|
|
|
searchResult.add(cellModel); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { |
|
|
|
if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { |
|
|
|
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
lessModelList.add(0, TITLE_MODEL); |
|
|
|
lessModelList.add(0, TITLE_MODEL); |
|
|
|
if (lessModelList.size() == 1) { |
|
|
|
if (searchResult.size() == 0) { |
|
|
|
lessModelList.add(AlphaFineHelper.noResultModel); |
|
|
|
lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
lessModelList.addAll(searchResult); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
lessModelList.add(0, MORE_MODEL); |
|
|
|
|
|
|
|
lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); |
|
|
|
|
|
|
|
moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return getNoResultList(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (JSONException e) { |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
FRLogger.getLogger().error("plugin search json error :" + e.getMessage()); |
|
|
|
return getNoResultList(); |
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error("plugin search encode error :" + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return this.lessModelList; |
|
|
|
return this.lessModelList; |
|
|
@ -92,18 +92,10 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private SearchResult getNoResultList() { |
|
|
|
|
|
|
|
SearchResult result = new SearchResult(); |
|
|
|
|
|
|
|
result.add(0, TITLE_MODEL); |
|
|
|
|
|
|
|
result.add(AlphaFineHelper.noResultModel); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SearchResult getNoConnectList() { |
|
|
|
private SearchResult getNoConnectList() { |
|
|
|
SearchResult result = new SearchResult(); |
|
|
|
SearchResult result = new SearchResult(); |
|
|
|
result.add(0, TITLE_MODEL); |
|
|
|
result.add(0, TITLE_MODEL); |
|
|
|
result.add(AlphaFineHelper.noConnectionModel); |
|
|
|
result.add(AlphaFineHelper.NO_CONNECTION_MODEL); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -151,8 +143,4 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|