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

Fatal Exception: java.lang.NullPointerException #22

Closed
mradzinski opened this issue Jul 7, 2017 · 1 comment
Closed

Fatal Exception: java.lang.NullPointerException #22

mradzinski opened this issue Jul 7, 2017 · 1 comment

Comments

@mradzinski
Copy link

Hi. Some of my users are experiencing the following exception:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
       at net.idik.lib.slimadapter.SlimAdapter.getItemViewType(SlimAdapter.java:242)
       at net.idik.lib.slimadapter.SlimAdapterEx.getItemViewType(SlimAdapterEx.java:99)
       at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5507)
       at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:282)
       at android.support.v7.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:336)
       at android.support.v7.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:349)
       at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:356)
       at android.support.v7.widget.GapWorker.run(GapWorker.java:387)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6688)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

It seems to be related to this line in particular. data.get(position); is returning null, hence dataTypes.indexOf(item.getClass()); fails with an NPE (item is null by that time).

Any idea what might be causing this?

@linisme
Copy link
Owner

linisme commented Sep 18, 2017

i am sorry for recheck the issues so late,i am getting busy these days,, T T

it seems like the “data“ in the adapter has changed outside the adapter,as you see in the source, the "data" is just a refrence to the raw data set, so u should let the adapter knew when the raw data set changed with the "notifydatasetchanged()" method. Hope this helps.

@linisme linisme closed this as completed Sep 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants