Skip to content

Instantly share code, notes, and snippets.

@Firsto
Created April 18, 2017 04:30
Show Gist options
  • Save Firsto/38f735973db60207a939014fc75c1e8c to your computer and use it in GitHub Desktop.
Save Firsto/38f735973db60207a939014fc75c1e8c to your computer and use it in GitHub Desktop.
Endless-like loop fast adapter
class BuildingImageAdapter extends FastItemAdapter<BuildingImageItem> {
@Override
public int getAdapterItemCount() {
return Integer.MAX_VALUE;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
position = position % getItemAdapter().getAdapterItems().size();
super.onBindViewHolder(holder, position);
}
@Override
public int getItemViewType(int position) {
position = position % getItemAdapter().getAdapterItems().size();
return super.getItemViewType(position);
}
@Override
public long getItemId(int position) {
position = position % getItemAdapter().getAdapterItems().size();
return getItem(position).getIdentifier();
}
@Override
public int getItemCount() {
return Integer.MAX_VALUE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment