Skip to content

Commit

Permalink
fix delete and deleteByIds methods in MessagesListAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
bevzaanton committed Sep 26, 2018
1 parent 719b67a commit 3a754d7
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,18 @@ public void delete(MESSAGE message) {
* @param messages messages list to delete.
*/
public void delete(List<MESSAGE> messages) {
boolean result = false;
for (MESSAGE message : messages) {
int index = getMessagePositionById(message.getId());
items.remove(index);
notifyItemRemoved(index);
if (index >= 0) {
items.remove(index);
notifyItemRemoved(index);
result = true;
}
}
if (result) {
recountDateHeaders();
}
recountDateHeaders();
}

/**
Expand All @@ -267,12 +273,18 @@ public void deleteById(String id) {
* @param ids array of identifiers of messages to delete.
*/
public void deleteByIds(String[] ids) {
boolean result = false;
for (String id : ids) {
int index = getMessagePositionById(id);
items.remove(index);
notifyItemRemoved(index);
if (index >= 0) {
items.remove(index);
notifyItemRemoved(index);
result = true;
}
}
if (result) {
recountDateHeaders();
}
recountDateHeaders();
}

/**
Expand Down

0 comments on commit 3a754d7

Please sign in to comment.