Fix NPE in TravelLocalDataHelper

This commit is contained in:
Alex Sytnyk 2018-04-30 13:04:57 +03:00
parent faa88a3347
commit 1ec9acd00f

View file

@ -22,7 +22,7 @@ public class TravelLocalDataHelper {
private WikivoyageLocalDataDbHelper dbHelper; private WikivoyageLocalDataDbHelper dbHelper;
private TLongObjectHashMap<WikivoyageSearchHistoryItem> historyMap; private TLongObjectHashMap<WikivoyageSearchHistoryItem> historyMap;
private List<TravelArticle> savedArticles; private List<TravelArticle> savedArticles = new ArrayList<>();
private Listener listener; private Listener listener;
@ -36,7 +36,8 @@ public class TravelLocalDataHelper {
void refreshCachedData() { void refreshCachedData() {
historyMap = dbHelper.getAllHistoryMap(); historyMap = dbHelper.getAllHistoryMap();
savedArticles = dbHelper.readSavedArticles(); savedArticles.clear();
savedArticles.addAll(dbHelper.readSavedArticles());
} }
public List<WikivoyageSearchHistoryItem> getAllHistory() { public List<WikivoyageSearchHistoryItem> getAllHistory() {
@ -114,7 +115,7 @@ public class TravelLocalDataHelper {
savedArticles.add(article); savedArticles.add(article);
dbHelper.addSavedArticle(article); dbHelper.addSavedArticle(article);
notifySavedUpdated(); notifySavedUpdated();
} }
} }
public void removeArticleFromSaved(@NonNull TravelArticle article) { public void removeArticleFromSaved(@NonNull TravelArticle article) {