|
|
|
@ -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<PluginModel> parseDefaultPluginModel(List<Map> jsonObjects) { |
|
|
|
|
List<PluginModel> pluginModels = new ArrayList<>(); |
|
|
|
|
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++; |
|
|
|
|
} |
|
|
|
|
if (!Collections.isEmpty(jsonObjects)) { |
|
|
|
|
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; |
|
|
|
|