Code Monkey home page Code Monkey logo

Comments (8)

mikepenz avatar mikepenz commented on June 5, 2024 1

@FabianTerhorst that's how the RecyclerView adapter works.

How have you removed the item?

In general you should call

itemAdapter.remove(int position);

This will not only remove the item at the given position, but it will also notify the adapter about the removed item so it can animate

from fastadapter.

FabianTerhorst avatar FabianTerhorst commented on June 5, 2024

@mikepenz when im calling mItemAdapter.notifyDataSetChanged(); it doesn´t crashes too, but when the data comes from a api for example and you get 3 items and before you got 4 items, you couldn´t know that.

from fastadapter.

mikepenz avatar mikepenz commented on June 5, 2024

@FabianTerhorst then you should provide this via a new List and not by modifiying the previously set list

This works:
bildschirmfoto 2016-01-04 um 17 47 41

As mentioned this is the way how adapters work with the RecyclerView that's no behavior changed by this lib

from fastadapter.

FabianTerhorst avatar FabianTerhorst commented on June 5, 2024

@mikepenz thanks, creating a new ArrayList works.

from fastadapter.

mikepenz avatar mikepenz commented on June 5, 2024

@FabianTerhorst to get a bit more into detail:

Yes it may work if we call notifyDataSetChanged(), but that's not true. If you set a list to the ItemAdapter you change all items of this adapter, but this one may isn't the only adapter providing items, and there are other adapters which also host items inside the RecyclerView as this is the case, we want to animate the change of items, so i call

notifyAdapterItemRangeChanged

and make sure the Adapter know how to correclty animate the changed items.


So in case when set is used, it is important that we really set a new list. If we set the previous used list it will cause problems inside the Adapter. If you modify items of the current list, the specific methods for those actions should be used

from fastadapter.

drayan85 avatar drayan85 commented on June 5, 2024

Please refer the stackoverflow post

http://stackoverflow.com/questions/35653439/recycler-view-inconsistency-detected-invalid-view-holder-adapter-positionviewh

from fastadapter.

alashow avatar alashow commented on June 5, 2024

@drayan85 that solution is only changes name of the exception. After catching IOOB exception, another exception Added View has RecyclerView as parent but view is not a real child. Unfiltered index:n starts to throw. I managed to fix it by wrapping set/add methods with Handler.postDelayed. But I still get Scrapped or attached views may not be recycled. isScrap:false isAttached:true, if I scroll down fast.

from fastadapter.

KonradSzewczuk avatar KonradSzewczuk commented on June 5, 2024

I had similiar issue, and also this solution has helped me, after I've added new item to my RV:
recyclerView.getRecycledViewPool().clear();
adapter.notifyDataSetChanged();

from fastadapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.