Skip to content

Commit

Permalink
#2 - Add param 'total' items to Binder interface
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelbcr committed Jun 25, 2016
1 parent 442add5 commit bb519d9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/app/recycler_view/ItemViewGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ItemViewGroup(Context context) {
}

@Bind(R.id.tv_value) TextView tv_value;
@Override public void bind(Item item, int position) {
@Override public void bind(Item item, int position, int total) {
tv_value.setText(item.toString());
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/app/spinner/ItemSpinnerViewGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public ItemSpinnerViewGroup(Context context) {
}

@Override
public void bindDropDownView(Item item, int position) {
public void bindDropDownView(Item item, int position, int total) {
tv_value.setText(item.toString());
tv_value.setBackgroundResource(R.color.colorPrimary);
}

@Override
public void bindView(Item item, int position) {
public void bindView(Item item, int position, int total) {
tv_value.setText(item.toString());
tv_value.setBackgroundResource(R.color.colorAccent);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/app/stack_view/ItemViewGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ItemViewGroup(Context context) {
}

@Bind(R.id.tv_value) TextView tv_value;
@Override public void bind(Item item, int position) {
@Override public void bind(Item item, int position, int total) {
tv_value.setText(item.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public abstract class OkBaseAdapter<T, V extends View & OkBaseAdapter.Binder<T>>
holder = (ViewHolder) view.getTag();
}

holder.getView().bind(item, position);
holder.getView().bind(item, position, getCount());

return view;
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public V getView() {
}

public interface Binder<T> {
void bind(T item, int position);
void bind(T item, int position, int total);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public abstract class OkRecyclerViewAdapter<T, V extends View & OkRecyclerViewAd
final T item = items.get(position);

final V view = viewHolder.getView();
view.bind(item, position);
view.bind(item, position, getItemCount());

if (listener != null) view.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Expand Down Expand Up @@ -115,7 +115,7 @@ public interface Listener<T, V> {
}

public interface Binder<T> {
void bind(T data, int position);
void bind(T data, int position, int total);
}

public SwipeRemoveAction<T> swipeToRemoveItemOn(final RecyclerView recyclerView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public abstract class OkSpinnerAdapter<T, V extends View & OkSpinnerAdapter.Bind
protected List<T> items = new ArrayList<>();

public interface Binder<T> {
void bindView(T item, int position);
void bindView(T item, int position, int total);
}

public interface BinderDropDown<T> {
void bindDropDownView(T item, int position);
void bindDropDownView(T item, int position, int total);
}

public abstract V inflateView();
Expand All @@ -44,7 +44,7 @@ public View getDropDownView(final int position, View convertView, ViewGroup pare
final VD view = (convertView == null) ? inflateDropDownView() : (VD) convertView;

convertView = view;
view.bindDropDownView(item, position);
view.bindDropDownView(item, position, getCount());

return convertView;
}
Expand All @@ -55,7 +55,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
final V view = (convertView == null) ? inflateView() : (V) convertView;

convertView = view;
view.bindView(item, position);
view.bindView(item, position, getCount());

return convertView;
}
Expand Down

0 comments on commit bb519d9

Please sign in to comment.