CallLogDataSource: make NumberInfo cache part of DS

This commit is contained in:
xynngh 2020-09-30 14:16:06 +04:00
parent 4bffec08a1
commit 8398658e12
1 changed files with 4 additions and 3 deletions

View File

@ -93,6 +93,8 @@ public class CallLogDataSource extends ItemKeyedDataSource<CallLogDataSource.Gro
private final Function<List<CallLogItem>, List<CallLogItemGroup>> groupConverter;
private final Map<String, NumberInfo> numberInfoCache = new HashMap<>();
public CallLogDataSource(Function<List<CallLogItem>, List<CallLogItemGroup>> groupConverter) {
this.groupConverter = groupConverter;
}
@ -151,14 +153,13 @@ public class CallLogDataSource extends ItemKeyedDataSource<CallLogDataSource.Gro
}
private List<CallLogItem> loadInfo(List<CallLogItem> items) {
Map<String, NumberInfo> cache = new HashMap<>();
String countryCode = App.getSettings().getCachedAutoDetectedCountryCode();
for (CallLogItem item : items) {
NumberInfo numberInfo = cache.get(item.number);
NumberInfo numberInfo = numberInfoCache.get(item.number);
if (numberInfo == null) {
numberInfo = YacbHolder.getNumberInfo(item.number, countryCode);
cache.put(item.number, numberInfo);
numberInfoCache.put(item.number, numberInfo);
}
item.numberInfo = numberInfo;