question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow `ItemBinding` to be null while `List == null`

See original GitHub issue

Sometimes, you want to perform some initial processing to the list before creating the final OnItemBind subclass. However, the library will throw an error if ItemBinding is null.

It would really be helpful if ItemBinding can be null while the list is still null.

Right now, what we’re doing is providing a dummy ItemBinding, even though it won’t really be used, since we’ll swap it out with a different implementation anyway once we have a list.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
evantcommented, Feb 29, 2020

then allow BindingCollectionAdapter.setItemBinding(…) to accept nulls, so that it could be unset (and allow it to be GC’ed) when the list is unset.

Wouldn’t it be better to clear out the whole adapter in that case? (ex: recyclerview.setAdapter(null)).

0reactions
jasonsparccommented, Mar 3, 2020

We tried the new PR (#180) and I think it’s fine. No one bothered complaining so I would say, I approve it! The only thing that’s missing now is a note in the README file about the new behavior.

Thank you so much for the quick response and implementation! I’ll be sure to check back for the new release. 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data binding: set property if it isn't null - Stack Overflow
Well data binding avoids NullPointerException in general by checking for it and assigns the default value (null for example) even if item ...
Read more >
databinding ComboBoxAdv NULL value | WinForms Forums
Hi Lan Mo , I am afraid that I was not able to see the issue of 'ComboBoxAdv always display the first item...
Read more >
listOfNotNull - Kotlin Programming Language
Returns a new read-only list either of single given element, if it is not null, or empty list if the element is null....
Read more >
Layouts and binding expressions | Android Developers
Generated data binding code automatically checks for null values and avoid null pointer exceptions. For example, in the expression @{user.name} ...
Read more >
Databinding - data object is null on API 15-18 - Issue Tracker
while setting the dirty flags (which we internally use to control boolean logic), it fails to check whether the field is null. On...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found