-
Notifications
You must be signed in to change notification settings - Fork 251
Add nullability annotations to ContentSet methods. #650 #651
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
base: master
Are you sure you want to change the base?
Conversation
@@ -336,13 +340,13 @@ private ContentValues ensureAfter() | |||
values = new ContentValues(); | |||
mAfterContentValues = values; | |||
// also create mAfterKeys | |||
mAfterKeys = new HashSet<String>(); | |||
mAfterKeys = new HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove mAfterKeys
while you're at it. It was only a workaround for the absence of ContentValues.keySet()
on Android 2.x. Since we don't support Android 2 any more you can remove it in most places and replace by mAfterContentValues.keySet()
where it's being read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've removed mAfterKeys
.
@@ -544,7 +553,7 @@ else if (mBeforeContentValues != null && mBeforeContentValues.get(key) != null) | |||
} | |||
|
|||
|
|||
public void addOnChangeListener(OnContentChangeListener listener, String key, boolean notify) | |||
public void addOnChangeListener(@NonNull OnContentChangeListener listener, @Nullable String key, boolean notify) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't make sense to add a listener for changes to a null
key. So key
should be @NonNull
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are usages of these methods with null
key, so that's why I used Nullable
. I've checked now and null
actually has a special usage here, see:
/** | |
* A {@link Map} for the {@link OnContentChangeListener}s. A listener registers for a specific key in a content set or for <code>null</code> to e notified | |
* of full reloads. | |
*/ | |
private final Map<String, Set<OnContentChangeListener>> mOnChangeListeners = new HashMap<String, Set<OnContentChangeListener>>(); |
So now I've just added some javadoc to the methods about the key parameter.
Let me know if you'd prefer it to be changed somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I right, I forgot about that. Passing null will cause the listener to be called for any update on any key. Did you check if we actually use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are called with null
key from ViewTaskFragment
and EditTaskFragment
.
@@ -563,7 +572,7 @@ public void addOnChangeListener(OnContentChangeListener listener, String key, bo | |||
} | |||
|
|||
|
|||
public void removeOnChangeListener(OnContentChangeListener listener, String key) | |||
public void removeOnChangeListener(@NonNull OnContentChangeListener listener, @Nullable String key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, key
is @NonNull
.
No description provided.