|
|
@ -20,6 +20,7 @@ import com.fr.plugin.basic.version.Version; |
|
|
|
import com.fr.plugin.basic.version.VersionIntervalFactory; |
|
|
|
import com.fr.plugin.basic.version.VersionIntervalFactory; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.EncodeConstants; |
|
|
|
import com.fr.stable.EncodeConstants; |
|
|
|
|
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.net.URLEncoder; |
|
|
@ -29,7 +30,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.function.ToLongFunction; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by XiaXiang on 2017/3/27. |
|
|
|
* Created by XiaXiang on 2017/3/27. |
|
|
@ -120,7 +121,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { |
|
|
|
return lessModelList; |
|
|
|
return lessModelList; |
|
|
|
} |
|
|
|
} |
|
|
|
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE); |
|
|
|
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE); |
|
|
|
if(noConnectList != null){ |
|
|
|
if (noConnectList != null) { |
|
|
|
return noConnectList; |
|
|
|
return noConnectList; |
|
|
|
} |
|
|
|
} |
|
|
|
for (int j = 0; j < searchText.length; j++) { |
|
|
|
for (int j = 0; j < searchText.length; j++) { |
|
|
@ -184,7 +185,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { |
|
|
|
List<PluginModel> pluginModels = new ArrayList<>(); |
|
|
|
List<PluginModel> pluginModels = new ArrayList<>(); |
|
|
|
pluginModels.addAll(parseDefaultPluginModel(plugins)); |
|
|
|
pluginModels.addAll(parseDefaultPluginModel(plugins)); |
|
|
|
|
|
|
|
|
|
|
|
pluginModels.forEach(m->this.defaultModelList.add(m)); |
|
|
|
pluginModels.forEach(m -> this.defaultModelList.add(m)); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error("plugin search error :" + e.getMessage()); |
|
|
|
FineLoggerFactory.getLogger().error("plugin search error :" + e.getMessage()); |
|
|
@ -196,33 +197,31 @@ public class PluginSearchManager implements AlphaFineSearchProvider { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 将jsonobject转化为PluginModel |
|
|
|
* 将jsonobject转化为PluginModel |
|
|
|
* 并按照更新时间排序,取最新的10个 |
|
|
|
* 并按照更新时间排序,取最新的10个,并过滤掉不是当前版本的 |
|
|
|
* */ |
|
|
|
*/ |
|
|
|
List<PluginModel> parseDefaultPluginModel(List<Map> jsonObjects) { |
|
|
|
List<PluginModel> parseDefaultPluginModel(List<Map> jsonObjects) { |
|
|
|
List<PluginModel> pluginModels = new ArrayList<>(); |
|
|
|
List<PluginModel> pluginModels = new ArrayList<>(); |
|
|
|
|
|
|
|
String version = "v" + ProductConstants.MAIN_VERSION; |
|
|
|
if (!Collections.isEmpty(jsonObjects)) { |
|
|
|
if (!Collections.isEmpty(jsonObjects)) { |
|
|
|
|
|
|
|
pluginModels = jsonObjects.stream() |
|
|
|
|
|
|
|
.filter(o -> ((Integer) o.get(version)) == 1) |
|
|
|
|
|
|
|
.sorted((Map map1, Map map2) -> Long.compare(parseTime(map2), parseTime(map1))) |
|
|
|
|
|
|
|
.limit(DEFAULT_LIST_SIZE) |
|
|
|
|
|
|
|
.map(jsonObject -> getPluginModel(new JSONObject(jsonObject), false)) |
|
|
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return pluginModels; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static long parseTime(Map value) { |
|
|
|
SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); |
|
|
|
SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); |
|
|
|
|
|
|
|
long t = 0L; |
|
|
|
try { |
|
|
|
try { |
|
|
|
jsonObjects.sort(Comparator.comparingLong(new ToLongFunction<Map>() { |
|
|
|
t = format.parse((String) value.get(UPLOAD_TIME)).getTime(); |
|
|
|
@Override |
|
|
|
|
|
|
|
public long applyAsLong(Map value) { |
|
|
|
|
|
|
|
long time = 0L; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
time = format.parse((String) value.get(UPLOAD_TIME)).getTime(); |
|
|
|
|
|
|
|
} catch (ParseException e) { |
|
|
|
} catch (ParseException e) { |
|
|
|
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
|
|
|
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
return time; |
|
|
|
return t; |
|
|
|
} |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < DEFAULT_LIST_SIZE; i++) { |
|
|
|
|
|
|
|
pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return pluginModels; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|