Last active
August 31, 2016 19:33
-
-
Save diegoy/6d1cbd0c78427d3c02b8a1c791a3f155 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This binder is needed to prevent a NullPointerException cases when | |
* Android's Data Binding Library Binder class tries to bind the value | |
* for rating when the model isn't setted yet. | |
* */ | |
public class RatingBinder { | |
@BindingAdapter({"rating"}) | |
public static void setRating(RatingBar ratingBar, Float rating) { | |
if (rating != null) { | |
ratingBar.setRating(rating); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment