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

IndexOutOfBoundsException when using FastAdapterDiffUtil on expandable list #628

Closed
5 tasks done
michalbujalski opened this issue Jan 31, 2018 · 1 comment
Closed
5 tasks done
Assignees
Labels

Comments

@michalbujalski
Copy link

michalbujalski commented Jan 31, 2018

About this issue

I'm using FastAdapterDiffUtil to update current list of items. The adapter which uses ExpandableExtension and has withIsExpanded set before putting into DiffUtil
Nothing new when updating the list:
FastAdapterDiffUtil.set( expandableAdapter.getItemAdapter(), items, new ExpandedDiffCallback(), false );
Also I need to manually control expanded items state so my ISubItem has isAutoExpanding set to false

Stacktrace:
java.lang.IndexOutOfBoundsException: Index: 2, Size: 2 at java.util.ArrayList.get(ArrayList.java:437) at com.mikepenz.fastadapter.utils.DefaultItemListImpl.get(DefaultItemListImpl.java:29) at com.mikepenz.fastadapter.utils.DefaultItemListImpl.get(DefaultItemListImpl.java:15) at com.mikepenz.fastadapter.adapters.ModelAdapter.getAdapterItem(ModelAdapter.java:265) at com.mikepenz.fastadapter.FastAdapter.getItem(FastAdapter.java:856) at com.mikepenz.fastadapter.expandable.ExpandableExtension.notifyAdapterItemRangeChanged(ExpandableExtension.java:154) at com.mikepenz.fastadapter.FastAdapter.notifyAdapterItemRangeChanged(FastAdapter.java:1364) at com.mikepenz.fastadapter.commons.utils.FastAdapterDiffUtil$FastAdapterListUpdateCallback.onChanged(FastAdapterDiffUtil.java:191) at android.support.v7.util.BatchingListUpdateCallback.dispatchLastEvent(BatchingListUpdateCallback.java:65) at android.support.v7.util.BatchingListUpdateCallback.onRemoved(BatchingListUpdateCallback.java:94) at android.support.v7.util.DiffUtil$DiffResult.dispatchRemovals(DiffUtil.java:791) at android.support.v7.util.DiffUtil$DiffResult.dispatchUpdatesTo(DiffUtil.java:713) at com.mikepenz.fastadapter.commons.utils.FastAdapterDiffUtil.set(FastAdapterDiffUtil.java:57) at com.mikepenz.fastadapter.commons.utils.FastAdapterDiffUtil.set(FastAdapterDiffUtil.java:75)

Steps to reproduce:

List with two expandable items everyone of each has one child
Expand the first parent. Update the list with new items.

Calling collapse before FastAdapterDiffUtil.set solves the problem. Checked out previous implementation and noticed that in v 2.x callapse was caled at the beginning (before calculating diff result). Is this a bug? Is there a build-in way to persist expandable state after using diff utils ?

Details

  • [ 3.2.2@aar] Used library version
  • [27.0.2 ] Used support library version
  • [26.0.2 ] Used gradle build tools version
  • [3.0.1] Used tooling / Android Studio version
  • [] Other used libraries, potential conflicting libraries

Checklist

@mikepenz
Copy link
Owner

@michalbujalski sorry the FastAdapterDiffUtil can not handle expendables. if they are expanded.

I think you are right that we require a collapse before that again. as I don't think there is a nice solution to maintain the current open state. (other than collapsing, remembering, restoring it.

@mikepenz mikepenz self-assigned this Jan 31, 2018
@mikepenz mikepenz added the bug label Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants