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-15015-added support for setting header and footer view after setda... #5122

Merged
merged 2 commits into from
Feb 5, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
}
} else if (TiC.PROPERTY_MIN_ROW_HEIGHT.equals(key)) {
updateView();
} else if (TiC.PROPERTY_HEADER_VIEW.equals(key)) {
if (oldValue != null) {
tableView.removeHeaderView((TiViewProxy) oldValue);
}
tableView.setHeaderView();
} else if (TiC.PROPERTY_FOOTER_VIEW.equals(key)) {
if (oldValue != null) {
tableView.removeFooterView((TiViewProxy) oldValue);
}
tableView.setFooterView();
} else {
super.propertyChanged(key, oldValue, newValue, proxy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,43 @@ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, l
});
addView(listView);
}

public void removeHeaderView(TiViewProxy viewProxy)
{
View outerView = (viewProxy.peekView() == null) ? null : viewProxy.peekView().getOuterView();
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use a variable for peekView() so you don't have to call it twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

if (outerView != null) {
listView.removeHeaderView(outerView);
}
}

public void setHeaderView()
{
if (proxy.hasProperty(TiC.PROPERTY_HEADER_VIEW)) {
listView.setAdapter(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to reset the adapter here?

TiViewProxy view = (TiViewProxy) proxy.getProperty(TiC.PROPERTY_HEADER_VIEW);
listView.addHeaderView(layoutHeaderOrFooter(view).getOuterView(), null, false);
listView.setAdapter(adapter);
}
}

public void removeFooterView(TiViewProxy viewProxy)
{
View outerView = (viewProxy.peekView() == null) ? null : viewProxy.peekView().getOuterView();
Copy link
Contributor

Choose a reason for hiding this comment

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

see above comment regarding peekView()

if (outerView != null) {
listView.removeFooterView(outerView);
}
}

public void setFooterView()
{
if (proxy.hasProperty(TiC.PROPERTY_FOOTER_VIEW)) {
listView.setAdapter(null);
TiViewProxy view = (TiViewProxy) proxy.getProperty(TiC.PROPERTY_FOOTER_VIEW);
listView.addFooterView(layoutHeaderOrFooter(view).getOuterView(), null, false);
listView.setAdapter(adapter);
}
}

public TiTableView(TiContext tiContext, TableViewProxy proxy)
{
this(proxy);
Expand Down