Skip to content

Commit

Permalink
Merge pull request stfalcon-studio#191 from mathroule/upsert-dialog
Browse files Browse the repository at this point in the history
Add upsert method to dialogs list
  • Loading branch information
bevzaanton authored Sep 25, 2018
2 parents f6e3ee3 + 2254593 commit 9918fa4
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,26 @@ public void updateItemById(DIALOG item) {
}
}

/**
* Upsert dialog in dialogs list or add it to then end of dialogs list
*
* @param item dialog item
*/
public void upsertItem(DIALOG item) {
boolean updated = false;
for (int i = 0; i < items.size(); i++) {
if (items.get(i).getId().equals(item.getId())) {
items.set(i, item);
notifyItemChanged(i);
updated = true;
break;
}
}
if (!updated) {
addItem(item);
}
}

/**
* Find an item by its id
*
Expand Down

0 comments on commit 9918fa4

Please sign in to comment.