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

Commit with Family view row removed as an example #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 2 additions & 51 deletions samples/src/com/inqbarna/tablefixheaders/samples/FamilyTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ public class FamilyNexusAdapter extends BaseTableAdapter {
private final float density;

public FamilyNexusAdapter(Context context) {
familys = new NexusTypes[] {
new NexusTypes("Mobiles"),
new NexusTypes("Tablets"),
new NexusTypes("Others"),
};
familys = new NexusTypes("Mobiles");

density = context.getResources().getDisplayMetrics().density;

Expand Down Expand Up @@ -130,9 +126,6 @@ public View getView(int row, int column, View convertView, ViewGroup parent) {
case 3:
view = getBody(row, column, convertView, parent);
break;
case 4:
view = getFamilyView(row, column, convertView, parent);
break;
default:
throw new RuntimeException("wtf?");
}
Expand Down Expand Up @@ -173,20 +166,6 @@ private View getBody(int row, int column, View convertView, ViewGroup parent) {
return convertView;
}

private View getFamilyView(int row, int column, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.item_table_family, parent, false);
}
final String string;
if (column == -1) {
string = getFamily(row).name;
} else {
string = "";
}
((TextView) convertView.findViewById(android.R.id.text1)).setText(string);
return convertView;
}

@Override
public int getWidth(int column) {
return Math.round(widths[column + 1] * density);
Expand All @@ -197,8 +176,6 @@ public int getHeight(int row) {
final int height;
if (row == -1) {
height = 35;
} else if (isFamily(row)) {
height = 25;
} else {
height = 45;
}
Expand All @@ -212,8 +189,6 @@ public int getItemViewType(int row, int column) {
itemViewType = 0;
} else if (row == -1) {
itemViewType = 1;
} else if (isFamily(row)) {
itemViewType = 4;
} else if (column == -1) {
itemViewType = 2;
} else {
Expand All @@ -222,32 +197,8 @@ public int getItemViewType(int row, int column) {
return itemViewType;
}

private boolean isFamily(int row) {
int family = 0;
while (row > 0) {
row -= familys[family].size() + 1;
family++;
}
return row == 0;
}

private NexusTypes getFamily(int row) {
int family = 0;
while (row >= 0) {
row -= familys[family].size() + 1;
family++;
}
return familys[family - 1];
}

private Nexus getDevice(int row) {
int family = 0;
while (row >= 0) {
row -= familys[family].size() + 1;
family++;
}
family--;
return familys[family].get(row + familys[family].size());
return familys.get(row);
}

@Override
Expand Down