luizgrp / SectionedRecyclerViewAdapter

An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers. Each Section can have its state controlled individually.
MIT License
1.68k stars 372 forks source link

removeAllSections #202

Closed luojt closed 4 years ago

luojt commented 4 years ago

If there are section a, Section B, Section C, all addsections, then the sectionedrecyclerviewadapter calls the removeallsections() method, then addsection (b), addsection (c), and calls the notifydatasetchanged() method, an error will be reported. The viewholder of section a is obtained from the onbinditemviewholder of section B, java.lang.ClassCastException

luizgrp commented 4 years ago

thanks for reporting it, I tried the steps mentioned and did not see any crash

        Section sectionA = addNewSectionToAdapter();
        Section sectionB = addNewSectionToAdapter();
        Section sectionC = addNewSectionToAdapter();

        sectionedAdapter.removeAllSections();

        sectionedAdapter.addSection(sectionB);
        sectionedAdapter.addSection(sectionC);

        sectionedAdapter.notifyDataSetChanged();

please use the pull request template to report issues so more details can be provided

Thecrazyskull commented 4 years ago

I can reproduce this issue. In my case i'm calling removeAllSections, then adding 8 other sections and finally I call notifyDataSetChanged.