Speedup travel article opening

This commit is contained in:
max-klaus 2021-01-24 12:22:52 +03:00
parent c6094c456f
commit d4514cefaa

View file

@ -130,7 +130,7 @@ public class TravelObfHelper implements TravelHelper {
@Nullable @Nullable
private TravelArticle cacheTravelArticles(File file, Amenity amenity, String lang, boolean readPoints) { private TravelArticle cacheTravelArticles(File file, Amenity amenity, String lang, boolean readPoints) {
TravelArticle article = null; TravelArticle article = null;
Map<String, TravelArticle> articles = readArticles(file, amenity, readPoints); Map<String, TravelArticle> articles = readArticles(file, amenity, false);
if (!Algorithms.isEmpty(articles)) { if (!Algorithms.isEmpty(articles)) {
TravelArticleIdentifier newArticleId = articles.values().iterator().next().generateIdentifier(); TravelArticleIdentifier newArticleId = articles.values().iterator().next().generateIdentifier();
cachedArticles.put(newArticleId, articles); cachedArticles.put(newArticleId, articles);
@ -536,8 +536,7 @@ public class TravelObfHelper implements TravelHelper {
@Override @Override
public boolean publish(Amenity amenity) { public boolean publish(Amenity amenity) {
if (Algorithms.stringsEqual(articleId.routeId, Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID, null))) if (Algorithms.stringsEqual(articleId.routeId, Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID, null))) || isDbArticle) {
&& Algorithms.stringsEqual(articleId.routeSource, Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_SOURCE, null))) || isDbArticle) {
amenities.add(amenity); amenities.add(amenity);
done = true; done = true;
} }
@ -552,7 +551,7 @@ public class TravelObfHelper implements TravelHelper {
if (!Double.isNaN(articleId.lat)) { if (!Double.isNaN(articleId.lat)) {
req.setBBoxRadius(articleId.lat, articleId.lon, ARTICLE_SEARCH_RADIUS); req.setBBoxRadius(articleId.lat, articleId.lon, ARTICLE_SEARCH_RADIUS);
if (!Algorithms.isEmpty(articleId.routeId)) { if (!Algorithms.isEmpty(articleId.title)) {
reader.searchPoiByName(req); reader.searchPoiByName(req);
} else { } else {
reader.searchPoi(req); reader.searchPoi(req);