Join us for ⁠#Android11: The Beta Launch Show on June 3!

Config

class Config
kotlin.Any
   ↳ androidx.recyclerview.widget.MergeAdapter.Config

The configuration object for a MergeAdapter.

Summary

Nested classes

open

The builder for Config class.

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

Properties

static MergeAdapter.Config

Boolean

If false, MergeAdapter assumes all assigned adapters share a global view type pool such that they use the same view types to refer to the same ViewHolders.

MergeAdapter.Config.StableIdMode

Defines whether the MergeAdapter should support stable ids or not (Adapter#hasStableIds().

Properties

DEFAULT

@NonNull static val DEFAULT: MergeAdapter.Config

isolateViewTypes

val isolateViewTypes: Boolean

If false, MergeAdapter assumes all assigned adapters share a global view type pool such that they use the same view types to refer to the same ViewHolders.

Setting this to false will allow nested adapters to share ViewHolders but it also means these adapters should not have conflicting view types (Adapter#getItemViewType(int)) such that two different adapters return the same view type for different ViewHolders. By default, it is set to true which means MergeAdapter will isolate view types across adapters, preventing them from using the same ViewHolders.

stableIdMode

@NonNull val stableIdMode: MergeAdapter.Config.StableIdMode

Defines whether the MergeAdapter should support stable ids or not (Adapter#hasStableIds().

There are 3 possible options: StableIdMode#NO_STABLE_IDS: In this mode, MergeAdapter ignores the stable ids reported by sub adapters. This is the default mode. StableIdMode#ISOLATED_STABLE_IDS: 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). StableIdMode#SHARED_STABLE_IDS: 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 an item is moved between Adapters. Default value is StableIdMode#NO_STABLE_IDS.