fix concurrent modification exception in spread view

This commit is contained in:
woodser 2024-05-15 17:16:52 -04:00
parent 8462ff1019
commit 113a94b1f9

View File

@ -113,6 +113,7 @@ class SpreadViewModel extends ActivatableViewModel {
private void update(ObservableList<OfferBookListItem> offerBookListItems) { private void update(ObservableList<OfferBookListItem> offerBookListItems) {
Map<String, List<Offer>> offersByCurrencyMap = new HashMap<>(); Map<String, List<Offer>> offersByCurrencyMap = new HashMap<>();
synchronized (offerBookListItems) {
for (OfferBookListItem offerBookListItem : offerBookListItems) { for (OfferBookListItem offerBookListItem : offerBookListItems) {
Offer offer = offerBookListItem.getOffer(); Offer offer = offerBookListItem.getOffer();
String key = offer.getCurrencyCode(); String key = offer.getCurrencyCode();
@ -126,6 +127,7 @@ class SpreadViewModel extends ActivatableViewModel {
offersByCurrencyMap.put(key, new ArrayList<>()); offersByCurrencyMap.put(key, new ArrayList<>());
offersByCurrencyMap.get(key).add(offer); offersByCurrencyMap.get(key).add(offer);
} }
}
spreadItems.clear(); spreadItems.clear();
BigInteger totalAmount = BigInteger.ZERO; BigInteger totalAmount = BigInteger.ZERO;