Google is committed to advancing racial equity for Black communities. See how.

StableIdMode

class StableIdMode
kotlin.Any
   ↳ kotlin.Enum<androidx.recyclerview.widget.MergeAdapter.Config.StableIdMode>
   ↳ androidx.recyclerview.widget.MergeAdapter.Config.StableIdMode

Defines how MergeAdapter handle stable ids (Adapter#hasStableIds()).

Summary

Enum values

In this mode, MergeAdapter will return true from MergeAdapter#hasStableIds() and will require all added Adapters to have stable ids.

In this mode, MergeAdapter ignores the stable ids reported by sub adapters.

In this mode, MergeAdapter will return true from MergeAdapter#hasStableIds() and will require all added Adapters to have stable ids.

Enum values

ISOLATED_STABLE_IDS

enum val ISOLATED_STABLE_IDS : MergeAdapter.Config.StableIdMode

In this mode, MergeAdapter will return true from MergeAdapter#hasStableIds() and will require all added Adapters to have stable ids. As two different adapters may return same stable ids because they are unaware of each-other, MergeAdapter will isolate each Adapter's id pool from each other such that it will overwrite the reported stable id before reporting back to the RecyclerView. In this mode, the value returned from ViewHolder#getItemId() might differ from the value returned from Adapter#getItemId(int). Adding an adapter without stable ids will result in an IllegalArgumentException.

NO_STABLE_IDS

enum val NO_STABLE_IDS : MergeAdapter.Config.StableIdMode

In this mode, MergeAdapter ignores the stable ids reported by sub adapters. This is the default mode. Adding an Adapter with stable ids will result in a warning as it will be ignored.

SHARED_STABLE_IDS

enum val SHARED_STABLE_IDS : MergeAdapter.Config.StableIdMode

In this mode, MergeAdapter will return true from MergeAdapter#hasStableIds() and will require all added Adapters to have stable ids. Unlike StableIdMode#ISOLATED_STABLE_IDS, MergeAdapter will not override the returned item ids. In this mode, child Adapters must be aware of each-other and never return the same id unless and item is moved between Adapters. Adding an adapter without stable ids will result in an IllegalArgumentException.