Add "addToHistory" method overloading; add new history items to historyMap too

This commit is contained in:
Alex Sytnyk 2018-04-04 17:33:01 +03:00
parent 0706968dc1
commit b3815da757

View file

@ -38,6 +38,10 @@ public class WikivoyageSearchHistoryHelper {
return new ArrayList<>(historyItems); return new ArrayList<>(historyItems);
} }
public void addToHistory(WikivoyageArticle article) {
addToHistory(article.getCityId(), article.getTitle(), article.getLang(), article.getIsPartOf());
}
public void addToHistory(long cityId, String title, String lang, String isPartOf) { public void addToHistory(long cityId, String title, String lang, String isPartOf) {
WikivoyageSearchHistoryItem item = historyMap.get(cityId); WikivoyageSearchHistoryItem item = historyMap.get(cityId);
boolean newItem = item == null; boolean newItem = item == null;
@ -52,6 +56,7 @@ public class WikivoyageSearchHistoryHelper {
if (newItem) { if (newItem) {
dbHelper.add(item); dbHelper.add(item);
historyItems.add(item); historyItems.add(item);
historyMap.put(item.cityId, item);
} else { } else {
dbHelper.update(item); dbHelper.update(item);
} }