Prevent concurrent modification exception

This commit is contained in:
Sylvain Berfini 2019-03-14 13:33:08 +01:00
parent 995a088490
commit ada430e8b8

View file

@ -177,7 +177,7 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
return position; return position;
} }
public boolean isContactSelected(SearchResult sr) { public synchronized boolean isContactSelected(SearchResult sr) {
for (ContactAddress c : mContactsSelected) { for (ContactAddress c : mContactsSelected) {
Address addr = c.getAddress(); Address addr = c.getAddress();
if (addr != null && sr.getAddress() != null) { if (addr != null && sr.getAddress() != null) {
@ -193,11 +193,11 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
return false; return false;
} }
public ArrayList<ContactAddress> getContactsSelectedList() { public synchronized ArrayList<ContactAddress> getContactsSelectedList() {
return mContactsSelected; return mContactsSelected;
} }
public void setContactsSelectedList(ArrayList<ContactAddress> contactsList) { public synchronized void setContactsSelectedList(ArrayList<ContactAddress> contactsList) {
if (contactsList == null) { if (contactsList == null) {
mContactsSelected = new ArrayList<>(); mContactsSelected = new ArrayList<>();
} else { } else {
@ -205,7 +205,7 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
} }
} }
public boolean toggleContactSelection(ContactAddress ca) { public synchronized boolean toggleContactSelection(ContactAddress ca) {
if (mContactsSelected.contains(ca)) { if (mContactsSelected.contains(ca)) {
mContactsSelected.remove(ca); mContactsSelected.remove(ca);
return false; return false;