Skip to content

Commit

Permalink
Refactoring of empty header system. Manage null headerItem
Browse files Browse the repository at this point in the history
  • Loading branch information
DayS committed Sep 23, 2012
1 parent 948ac20 commit 63b1fd8
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,19 @@ public int getCount() {
public Object getItem(int position) {
IndexPath indexPath = retrieveIndexPathByPosition(position);
if (indexPath == null) {
return null;
throw new NullPointerException("Unable to retrieve index path for position " + position);
} else if (indexPath.isHeader()) {
return tableViewAdapter.headerItemForGroup(context, indexPath);
return getHeaderItem(indexPath);
} else {
return tableViewAdapter.cellItemForRow(context, indexPath);
}
}

public UITableHeaderItem getHeaderItem(IndexPath indexPath) {
UITableHeaderItem headerItem = tableViewAdapter.headerItemForGroup(context, indexPath);
return headerItem != null ? headerItem : new UITableHeaderItem();
}

@Override
public long getItemId(int position) {
return position;
Expand All @@ -86,7 +91,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
IndexPath indexPath = retrieveIndexPathByPosition(position);

if (indexPath == null) {
return null;
throw new NullPointerException("Unable to retrieve index path for position " + position);
} else if (indexPath.isHeader()) {
if (!(convertView instanceof UITableHeaderView)) {
convertView = null;
Expand All @@ -95,7 +100,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
UITableHeaderView tableHeaderView = (UITableHeaderView) convertView;
tableHeaderView.setIndexPath(indexPath);
}
UITableHeaderItem headerItem = tableViewAdapter.headerItemForGroup(context, indexPath);
UITableHeaderItem headerItem = getHeaderItem(indexPath);
UITableHeaderView headerView = tableViewAdapter.headerViewForGroup(context, indexPath, headerItem, (UITableHeaderView) convertView);
return headerView;
} else {
Expand Down

0 comments on commit 63b1fd8

Please sign in to comment.