From b3e723952d6b03dfd5e47f829f84ba8575784908 Mon Sep 17 00:00:00 2001 From: Yann Date: Wed, 1 Mar 2023 10:02:00 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-86430=20AlphaFine=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83tab=E9=A1=B5=E6=98=BE=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/impl/PluginSearchManager.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 9bf229f627..ec5fedbf25 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -29,6 +29,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * Created by XiaXiang on 2017/3/27. @@ -199,18 +200,15 @@ public class PluginSearchManager implements AlphaFineSearchProvider { */ List parseDefaultPluginModel(List jsonObjects) { List pluginModels = new ArrayList<>(); + String version = "v" + ProductConstants.MAIN_VERSION; if (!Collections.isEmpty(jsonObjects)) { - jsonObjects.sort(PluginSearchManager::sortPluginByUploadTime); - int pluginModelsCount = 0; - String version = "v" + ProductConstants.MAIN_VERSION; - for (Map obj : jsonObjects) { - if (pluginModelsCount == DEFAULT_LIST_SIZE) { - break; - } - if (((Integer) obj.get(version)) == 1) { - pluginModels.add(getPluginModel(new JSONObject(obj), false)); - pluginModelsCount++; - } + jsonObjects = jsonObjects.stream() + .filter(o -> ((Integer) o.get(version)) == 1) + .sorted(PluginSearchManager::sortPluginByUploadTime) + .collect(Collectors.toList()); + int size = Math.min(DEFAULT_LIST_SIZE, jsonObjects.size()); + for (int i = 0; i < size; i++) { + pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false)); } } return pluginModels;