Some null checks#20
Conversation
Some apps might not have the programs for a given channel. In that case, they might return a null on getProgramsForChannel(). Verify that it the list of programs is correct before continuing.
| .setChannelId(channelMap.valueAt(i).getId()) | ||
| .build()); | ||
|
|
||
| if (programs != null) { |
There was a problem hiding this comment.
Will there be cases when the program list will be null while using the library?
There was a problem hiding this comment.
In my case, the provider doesn't have all programs for a given channel in the EPG's XMLTV. Surely enough, I could simply pass an empty list instead of returning null on when getProgramsForChannel() is called.
| .setTitle(title) | ||
| .setDescription(description) | ||
| .setPosterArtUri(icon.src) | ||
| .setPosterArtUri(icon != null ? icon.src : null) |
There was a problem hiding this comment.
Again, will there be cases when the icon will be null using the library?
There was a problem hiding this comment.
Same as above, since I can't control the the info put by the provider, some channels doesn't have an icon. This could be somehow bypassed by simply creating a "dummy" icon but it doesn't quite solve the problem.
|
I suppose a big question is around the philosophy of this library. To what extent should it assume properties exist and what should it try to handle? If the former, then we should add @nonnull to those properties. If the latter, then your PR would be useful. |
|
I believe that both of the solutions proposed can be used for this PR. Here's my take on this:
Either solutions can be interchangeable but it depends on the level of control that the user have over the library. The open source variant can be changed easily to tailor the required needs. However, the packaged one could be a bit harder to play with. |
Since it might not be possible to control the content coming from an XMLTV provider, if a program isn't valid after being parsed, simply skip it. Notify the user about the faulty program in case.
Checks for possible NPE's when importing channels/programs.