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

NullPointerEx in example app #71

Closed
spectrumIG opened this issue Jan 18, 2017 · 5 comments
Closed

NullPointerEx in example app #71

spectrumIG opened this issue Jan 18, 2017 · 5 comments
Milestone

Comments

@spectrumIG
Copy link

Hi @lisawray
I tried today for the first time the example app and it keeps crashing on the newly added onClickListener code with this stacktrace:

java.lang.NullPointerException: Attempt to invoke interface method 'void com.genius.groupie.OnItemClickListener.onItemClick(com.genius.groupie.Item, android.view.View)' on a null object reference at com.genius.groupie.ViewHolder$1.onClick(ViewHolder.java:22)at android.view.View.performClick(View.java:5637)at android.view.View$PerformClick.run(View.java:22429)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:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Debugging show me that in this piece of code:
if (getAdapterPosition() != NO_POSITION) { onItemClickListener.onItemClick(getItem(), v); }
onItemClickListener it's always null. At first, I thoughts it was an error in the ViewHolder bind method but I'm not quite sure now.
Before writing this, I tried to find a duplicate issue in the list and it seems not present.Anyway, I could be wrong so...sorry, just in case :)

@lisawray
Copy link
Owner

lisawray commented Jan 18, 2017 via email

@lkishor
Copy link
Contributor

lkishor commented Jan 19, 2017

Hi @lisawray
you missed setting the onItemClickListener reference in bind() of ViewHolder
i.e within the if block
if (onItemClickListener != null && item.isClickable()) { binding.getRoot().setOnClickListener(onClickListener); this.onItemClickListener = onItemClickListener; //Currently missing }

@spectrumIG
Copy link
Author

@lisawray I can confirm actually this solved the problem. It's now working perfectly. @lkishor are u gonna submit a PR for this?

@lisawray
Copy link
Owner

Thank you for your patience. I've just worked through transferring the library on github with the guys at Genius and will be publishing a new release ASAP under a different package name!

@lisawray
Copy link
Owner

We're live with this fix now on jcenter at com.xwray:groupie:1.0.0 :)

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

3 participants