Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fine-grained control over data in ListComponent #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,31 @@ public void appendData(@NonNull List<T> data) {
notifyItemRangeInserted(oldSize, sizeChange);
}

/**
* Inserts the specified data at the specified index in the component data.
*
* @param index the index to insert the given data
* @param data the data to be inserted
*/
public void insertData(int index, @NonNull T data) {
mData.add(index, data);
notifyItemRangeInserted(index, index + 1);
zachbryant marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Removes the provided data items from the list.
*
* @param data The data item to remove from the list.
* @return an int representing the index that the removed data occupied
zachbryant marked this conversation as resolved.
Show resolved Hide resolved
*/
public void removeData(@NonNull T data) {
public int removeData(@NonNull T data) {
int index = mData.indexOf(data);
// Check if the object indeed is in the list.
if (index != -1) {
mData.remove(index);
notifyItemRangeRemoved(getRemoveIndexStart(index), getRemoveItemCount());
}
return index;
}

/**
Expand Down