Skip to content

Conversation

@lemonboston
Copy link
Contributor

No description provided.

mAfterContentValues = values;
// also create mAfterKeys
mAfterKeys = new HashSet<String>();
mAfterKeys = new HashSet<>();
Copy link
Owner

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.

Copy link
Contributor Author

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.



public void addOnChangeListener(OnContentChangeListener listener, String key, boolean notify)
public void addOnChangeListener(@NonNull OnContentChangeListener listener, @Nullable String key, boolean notify)
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

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?

Copy link
Contributor Author

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.



public void removeOnChangeListener(OnContentChangeListener listener, String key)
public void removeOnChangeListener(@NonNull OnContentChangeListener listener, @Nullable String key)
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants