Skip to content

Commit

Permalink
Merge pull request #369 from MGaetan89/abtract_table_adapter_default_…
Browse files Browse the repository at this point in the history
…methods

Add default get*ItemViewType implementations to AbstractTableAdapter
  • Loading branch information
evrencoskun authored Mar 15, 2021
2 parents 2a0783e + 2a603a3 commit cd1c561
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static class TestCellViewHolder extends AbstractViewHolder {
}

@NonNull
public AbstractViewHolder onCreateCellViewHolder(ViewGroup parent, int viewType) {
public AbstractViewHolder onCreateCellViewHolder(@NonNull ViewGroup parent, int viewType) {
View layout = LayoutInflater.from(parent.getContext())
.inflate(R.layout.cell_layout, parent, false);
return new TestCellViewHolder(layout);
Expand Down Expand Up @@ -83,7 +83,8 @@ public TestColumnHeaderViewHolder(View itemView) {
}

@NonNull
public AbstractViewHolder onCreateColumnHeaderViewHolder(ViewGroup parent, int viewType) {
public AbstractViewHolder onCreateColumnHeaderViewHolder(@NonNull ViewGroup parent, int
viewType) {
View layout = LayoutInflater.from(parent.getContext())
.inflate(R.layout.column_layout, parent, false);
return new TestColumnHeaderViewHolder(layout);
Expand Down Expand Up @@ -112,7 +113,7 @@ public TestRowHeaderViewHolder(View itemView) {
}

@NonNull
public AbstractViewHolder onCreateRowHeaderViewHolder(ViewGroup parent, int viewType) {
public AbstractViewHolder onCreateRowHeaderViewHolder(@NonNull ViewGroup parent, int viewType) {
View layout = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_layout, parent, false);
return new TestRowHeaderViewHolder(layout);
Expand All @@ -128,12 +129,8 @@ public void onBindRowHeaderViewHolder(@NonNull AbstractViewHolder holder,
}

@NonNull
public View onCreateCornerView(ViewGroup parent) {
public View onCreateCornerView(@NonNull ViewGroup parent) {
return LayoutInflater.from(parent.getContext())
.inflate(R.layout.corner_layout, parent, false);
}

public int getColumnHeaderItemViewType(int position) { return 0; }
public int getRowHeaderItemViewType(int position) { return 0; }
public int getCellItemViewType(int position) { return 0; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static class TestCellViewHolder extends AbstractViewHolder {
}

@NonNull
public AbstractViewHolder onCreateCellViewHolder(ViewGroup parent, int viewType) {
public AbstractViewHolder onCreateCellViewHolder(@NonNull ViewGroup parent, int viewType) {
View layout = LayoutInflater.from(parent.getContext())
.inflate(R.layout.cell_layout, parent, false);
return new TestCellViewHolder(layout);
Expand All @@ -71,7 +71,8 @@ public void onBindCellViewHolder(@NonNull AbstractViewHolder holder, Cell cell,
}

@NonNull
public AbstractViewHolder onCreateColumnHeaderViewHolder(ViewGroup parent, int viewType) {
public AbstractViewHolder onCreateColumnHeaderViewHolder(@NonNull ViewGroup parent, int
viewType) {
View layout = LayoutInflater.from(parent.getContext())
.inflate(R.layout.cell_layout, parent, false);
return new TestCellViewHolder(layout);
Expand All @@ -89,7 +90,7 @@ public void onBindColumnHeaderViewHolder(@NonNull AbstractViewHolder holder,
}

@NonNull
public AbstractViewHolder onCreateRowHeaderViewHolder(ViewGroup parent, int viewType) {
public AbstractViewHolder onCreateRowHeaderViewHolder(@NonNull ViewGroup parent, int viewType) {
View layout = LayoutInflater.from(parent.getContext())
.inflate(R.layout.cell_layout, parent, false);
return new TestCellViewHolder(layout);
Expand All @@ -104,12 +105,8 @@ public void onBindRowHeaderViewHolder(@NonNull AbstractViewHolder holder,
}

@NonNull
public View onCreateCornerView(ViewGroup parent) {
public View onCreateCornerView(@NonNull ViewGroup parent) {
return LayoutInflater.from(parent.getContext())
.inflate(R.layout.cell_layout, parent, false);
}

public int getColumnHeaderItemViewType(int position) { return 0; }
public int getRowHeaderItemViewType(int position) { return 0; }
public int getCellItemViewType(int position) { return 0; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,23 @@ public void setAllItems(@Nullable List<CH> columnHeaderItems, @Nullable List<RH>
}
}

@Override
public int getColumnHeaderItemViewType(int position) {
return 0;
}

@Override
public int getRowHeaderItemViewType(int position) {
return 0;
}

@Override
public int getCellItemViewType(int position) {
return 0;
}

@Nullable
@Override
public View getCornerView() {
return mCornerView;
}
Expand Down Expand Up @@ -357,6 +373,7 @@ private void dispatchCellDataSetChangesToListeners(@NonNull List<List<C>> newCel
*
* @param listener The AdapterDataSetChangedListener listener.
*/
@Override
public void addAdapterDataSetChangedListener(@NonNull AdapterDataSetChangedListener<CH, RH, C> listener) {
if (dataSetChangedListeners == null) {
dataSetChangedListeners = new ArrayList<>();
Expand Down

0 comments on commit cd1c561

Please sign in to comment.