Skip to content

Commit

Permalink
Merge pull request tidev#5306 from salachi/TIMOB-16266
Browse files Browse the repository at this point in the history
[TIMOB-16266] exposed sections
  • Loading branch information
vishalduggal committed Mar 7, 2014
2 parents 59512ba + e79e0ba commit 9a53ffb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
TiC.PROPERTY_FOOTER_TITLE,
TiC.PROPERTY_DEFAULT_ITEM_TEMPLATE,
TiC.PROPERTY_SHOW_VERTICAL_SCROLL_INDICATOR,
TiC.PROPERTY_SECTIONS,
TiC.PROPERTY_SEPARATOR_COLOR,
TiC.PROPERTY_SEARCH_TEXT,
TiC.PROPERTY_SEARCH_VIEW,
Expand All @@ -51,6 +50,7 @@ public class ListViewProxy extends TiViewProxy {
private static final int MSG_INSERT_SECTION_AT = MSG_FIRST_ID + 402;
private static final int MSG_DELETE_SECTION_AT = MSG_FIRST_ID + 403;
private static final int MSG_REPLACE_SECTION_AT = MSG_FIRST_ID + 404;
private static final int MSG_SECTIONS = MSG_FIRST_ID + 405;


//indicate if user attempts to add/modify/delete sections before TiListView is created
Expand Down Expand Up @@ -211,6 +211,13 @@ public boolean handleMessage(final Message msg) {
handleReplaceSectionAt(index, section);
return true;
}

case MSG_SECTIONS: {
AsyncResult result = (AsyncResult)msg.obj;
result.setResult(handleSections());
return true;
}

default:
return super.handleMessage(msg);
}
Expand Down Expand Up @@ -324,6 +331,33 @@ private void handleReplaceSectionAt(int index, Object section) {

}
}

@Kroll.method @Kroll.getProperty
public ListSectionProxy[] getSections()
{
if (TiApplication.isUIThread()) {
return handleSections();
} else {
return (ListSectionProxy[]) TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SECTIONS));
}
}

@Kroll.setProperty(retain=false) @Kroll.method
public void setSections(Object sections)
{
setPropertyAndFire(TiC.PROPERTY_SECTIONS, sections);
}

private ListSectionProxy[] handleSections()
{
TiUIView listView = peekView();

if (listView != null) {
return ((TiListView) listView).getSections();
}
ArrayList<ListSectionProxy> preloadedSections = getPreloadSections();
return preloadedSections.toArray(new ListSectionProxy[preloadedSections.size()]);
}

@Override
public String getApiName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,4 +827,9 @@ public void filterBy(String text)
reFilter(text);
}

public ListSectionProxy[] getSections()
{
return sections.toArray(new ListSectionProxy[sections.size()]);
}

}

0 comments on commit 9a53ffb

Please sign in to comment.