summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorYigit Boyar <yboyar@google.com>2017-12-27 12:03:54 -0800
committerYigit Boyar <yboyar@google.com>2017-12-27 12:03:54 -0800
commit6bf7bc3ff096ba750ae3e1534443a6b9385fb988 (patch)
tree137a7141fcb1993e8a599b08cfeb45e7b960bdab /extensions
parent5892a7f6ef92009d9b9ff126346ce9b091f71a88 (diff)
downloaddata-binding-6bf7bc3ff096ba750ae3e1534443a6b9385fb988.tar.gz
Remove unexpected nullable annotations from DataBindingUtil
Most DataBindingUtil methods return nullable to make it easy for generic adapters to inflate them. This becomes an issue if you are using it with kotlin because thet are unlikely to be null (similar case: Fragment#getActivity). Based on advice from kotlin team, we'll remove this annotation. Bug: n/a Test: n/a Change-Id: I445ac93cf941dacf11c27cc5d083123f7b3f31ea
Diffstat (limited to 'extensions')
-rw-r--r--extensions/library/src/main/java/android/databinding/DataBindingUtil.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/extensions/library/src/main/java/android/databinding/DataBindingUtil.java b/extensions/library/src/main/java/android/databinding/DataBindingUtil.java
index 1d25895e..c7c39353 100644
--- a/extensions/library/src/main/java/android/databinding/DataBindingUtil.java
+++ b/extensions/library/src/main/java/android/databinding/DataBindingUtil.java
@@ -88,7 +88,8 @@ public class DataBindingUtil {
* @throws InflateException When a merge layout was used and attachToParent was false.
* @see #setDefaultComponent(DataBindingComponent)
*/
- @Nullable
+ // @Nullable don't annotate with Nullable. It is unlikely to be null and makes using it from
+ // kotlin really ugly. We cannot make it NonNull w/o breaking backward compatibility.
public static <T extends ViewDataBinding> T inflate(@NonNull LayoutInflater inflater,
int layoutId, @Nullable ViewGroup parent, boolean attachToParent) {
return inflate(inflater, layoutId, parent, attachToParent, sDefaultComponent);
@@ -115,7 +116,8 @@ public class DataBindingUtil {
* the layoutId wasn't for a binding layout.
* @throws InflateException When a merge layout was used and attachToParent was false.
*/
- @Nullable
+ // @Nullable don't annotate with Nullable. It is unlikely to be null and makes using it from
+ // kotlin really ugly. We cannot make it NonNull w/o breaking backward compatibility.
public static <T extends ViewDataBinding> T inflate(
@NonNull LayoutInflater inflater, int layoutId, @Nullable ViewGroup parent,
boolean attachToParent, @Nullable DataBindingComponent bindingComponent) {
@@ -275,7 +277,8 @@ public class DataBindingUtil {
* @return The binding associated with the inflated content view or {@code null} if the
* layoutId is not a data binding layout.
*/
- @Nullable
+ // @Nullable don't annotate with Nullable. It is unlikely to be null and makes using it from
+ // kotlin really ugly. We cannot make it NonNull w/o breaking backward compatibility.
public static <T extends ViewDataBinding> T setContentView(@NonNull Activity activity,
int layoutId) {
return setContentView(activity, layoutId, sDefaultComponent);
@@ -293,7 +296,8 @@ public class DataBindingUtil {
* @return The binding associated with the inflated content view or {@code null} if the
* layoutId is not a data binding layout.
*/
- @Nullable
+ // @Nullable don't annotate with Nullable. It is unlikely to be null and makes using it from
+ // kotlin really ugly. We cannot make it NonNull w/o breaking backward compatibility.
public static <T extends ViewDataBinding> T setContentView(@NonNull Activity activity,
int layoutId, @Nullable DataBindingComponent bindingComponent) {
activity.setContentView(layoutId);