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);
}
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) {
WikivoyageSearchHistoryItem item = historyMap.get(cityId);
boolean newItem = item == null;
@ -52,6 +56,7 @@ public class WikivoyageSearchHistoryHelper {
if (newItem) {
dbHelper.add(item);
historyItems.add(item);
historyMap.put(item.cityId, item);
} else {
dbHelper.update(item);
}