Skip to content
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

TIMOB-12620 Added setter for TableView.sections property per documentation #3849

Merged
merged 4 commits into from Mar 6, 2013

Conversation

arthurevans
Copy link
Contributor

Also updated documentation with corrected since date and a few typo fixes.

if (args != null && args.length > 0 && args[0] instanceof Object[]) {
data = (Object[]) args[0];
}
for (Object section : args) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be
for (Object section: data)

@ghost ghost assigned pingwang2011 Feb 15, 2013
@arthurevans
Copy link
Contributor Author

Updated. The sections setter now returns without changing the table if any of the objects in the array are not sections (for example, sections = [ row ]).

This checking does not take place when you set sections in the construction dict, which seems consistent with the way we handle "data" in the construction dict. If you think we should reject non-sections in the construction dict as well, I think we could do something like this:

    if (dict.containsKey(TiC.PROPERTY_SECTIONS)) {
      Object o = dict.get(TiC.PROPERTY_SECTIONS);
      if (o != null && o instanceof Object[]) {
        Object[] sections = (Object[]) o;
        boolean validSections = true;
        for (Object section : sections) {
          if (! (section instanceof TableViewSectionProxy)) {
            Log.e(TAG, "Unable to set sections. Invalid type for section: " + section);
            validSections == false;
            break;
          }
        }
        if (validSections) {
          data = (Object[]) o;
        }
        dict.remove(TiC.PROPERTY_SECTIONS); // don't override our data accessor
      }
    }

}
for (Object section : data) {
if (! (section instanceof TableViewSectionProxy)) {
Log.e(TAG, "Unable to set sections. Invalid type for section: " + section);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style is not right here. Should use tab instead of whitespace.

@pingwang2011
Copy link
Contributor

Code reviewed and functionally tested. Looks good. Only one minor comment.

@arthurevans
Copy link
Contributor Author

Updated. Please review.

@pingwang2011
Copy link
Contributor

Accepted

pingwang2011 added a commit that referenced this pull request Mar 6, 2013
TIMOB-12620 Added setter for TableView.sections property per documentation
@pingwang2011 pingwang2011 merged commit f6e0ff7 into tidev:master Mar 6, 2013
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.

None yet

2 participants