Skip to content

INameableAdapter has undefined behaviour on empty list #87

@dstd

Description

@dstd

RecyclerView always calls the adapter with position within a data set bounds, so that when a data set is empty getItemViewType and onBindViewHolder won't be called.

According to the source code INameableAdapter could be called even if the list is empty, while the doc has nothing about this behaviour. Actually even the demo application is crashing if activity.getPackageManager().getInstalledApplications (AppData.java:AppData.processApps) returns an empty list, making testAdapter to try to reach a first element of empty list leading to OOB exception.

So I see two ways to solve this:

  1. make it clear that INameableAdapter.getCharacterForElement could be called with invalid index
  2. don't call this method when the list is empty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions