Fix trying to delete object not in list (#6127)
* fix trying to delete object by index -1 * correction in checkstyle-supressions.xml Co-authored-by: camo0112 <56369484+camo0112@users.noreply.github.com>
This commit is contained in:
parent
31ea44ccf1
commit
5b4fbe32b1
2 changed files with 14 additions and 3 deletions
|
@ -126,8 +126,19 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
|
|
||||||
public void removeItem(final LocalItem data) {
|
public void removeItem(final LocalItem data) {
|
||||||
final int index = localItems.indexOf(data);
|
final int index = localItems.indexOf(data);
|
||||||
localItems.remove(index);
|
if (index != -1) {
|
||||||
notifyItemRemoved(index + (header != null ? 1 : 0));
|
localItems.remove(index);
|
||||||
|
notifyItemRemoved(index + (header != null ? 1 : 0));
|
||||||
|
} else {
|
||||||
|
// this happens when
|
||||||
|
// 1) removeItem is called on infoItemDuplicate as in showStreamItemDialog of
|
||||||
|
// LocalPlaylistFragment in this case need to implement delete object by it's duplicate
|
||||||
|
|
||||||
|
// OR
|
||||||
|
|
||||||
|
// 2)data not in itemList and UI is still not updated so notifyDataSetChanged()
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean swapItems(final int fromAdapterPosition, final int toAdapterPosition) {
|
public boolean swapItems(final int fromAdapterPosition, final int toAdapterPosition) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<suppressions>
|
<suppressions>
|
||||||
<suppress checks="FinalParameters"
|
<suppress checks="FinalParameters"
|
||||||
files="LocalItemListAdapter.java"
|
files="LocalItemListAdapter.java"
|
||||||
lines="221,293"/>
|
lines="232,304"/>
|
||||||
|
|
||||||
<suppress checks="FinalParameters"
|
<suppress checks="FinalParameters"
|
||||||
files="InfoListAdapter.java"
|
files="InfoListAdapter.java"
|
||||||
|
|
Loading…
Reference in a new issue