Add "addToHistory" method overloading; add new history items to historyMap too
This commit is contained in:
parent
0706968dc1
commit
b3815da757
1 changed files with 5 additions and 0 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue