-
Notifications
You must be signed in to change notification settings - Fork 14
New APIs for footer/header view manipulation #9
Conversation
* @return true if footer was added/replaced, false otherwise. | ||
*/ | ||
public boolean addFooter(@LayoutRes int footerViewId, boolean shouldReplace) { | ||
if (!hasFooter() || hasFooter() && shouldReplace) { |
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 would reverse this logic to make it a bit cleaner.
if (shouldReplace || !hasFooter()) {
}
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.
By reversing the logic - you always have to set shouldReplace value to true. If we stick to the current solution - you can try to add the footer with shouldReplace set to false and it can silently fail if we already have footer view.
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.
Are you sure about this? If you set shouldReplace to false this condition will move to !hasFooter() and it will silently fail if footer view is already added. If you set shouldReplace to true, it will never check if footer already exists.
Maybe there is a use-case which I am missing.
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.
We've discussed about this on Slack, you are right.
* @return true if footer was added/replaced, false otherwise. | ||
*/ | ||
public boolean addFooter(View footerView, boolean shouldReplace) { | ||
if (!hasFooter() || hasFooter() && shouldReplace) { |
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.
The same as the comment for addFooter(@LayoutRes int footerViewId, boolean shouldReplace) method
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 comment as above
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 comment as above
* @return true if header was added/replaced, false otherwise. | ||
*/ | ||
public boolean addHeader(@LayoutRes int headerViewId, boolean shouldReplace) { | ||
if (!hasHeader() || hasHeader() && shouldReplace) { |
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
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 comment as above
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 comment as above
* @return true if header was added/replaced, false otherwise. | ||
*/ | ||
public boolean addHeader(View headerView, boolean shouldReplace) { | ||
if (!hasHeader() || hasHeader() && shouldReplace) { |
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.
And here
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 comment as above
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 comment as above
Defined new methods for footer/header view manipulation.