Updated SelectSignKeyAdapter.java from recycler-view
This commit is contained in:
committed by
Dominik Schürmann
parent
704151cbed
commit
d7ed998a40
@@ -35,12 +35,12 @@ public class SelectSignKeyAdapter extends KeyCursorAdapter<CursorAdapter.KeyCurs
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return super.getItemCount() + 1;
|
return super.getItemCount() + 1; // received items + 1 dummy key
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int pos) {
|
public long getItemId(int pos) {
|
||||||
if(pos < super.getItemCount()) {
|
if(pos < (super.getItemCount() - 1)) {
|
||||||
return super.getItemId(pos);
|
return super.getItemId(pos);
|
||||||
} else {
|
} else {
|
||||||
return 0L;
|
return 0L;
|
||||||
@@ -49,7 +49,7 @@ public class SelectSignKeyAdapter extends KeyCursorAdapter<CursorAdapter.KeyCurs
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
return position == getItemCount() -1 ?
|
return position == super.getItemCount() ?
|
||||||
VIEW_TYPE_DUMMY : VIEW_TYPE_KEY;
|
VIEW_TYPE_DUMMY : VIEW_TYPE_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class SelectSignKeyAdapter extends KeyCursorAdapter<CursorAdapter.KeyCurs
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||||
if(holder.getItemViewType() == VIEW_TYPE_KEY) {
|
if(holder.getItemViewType() == VIEW_TYPE_KEY) {
|
||||||
super.onBindViewHolder(holder, position - 1);
|
super.onBindViewHolder(holder, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user