Participe do evento ⁠#Android11: apresentação de lançamento da versão Beta no dia 3 de junho.

MergeAdapter.Config

public static class MergeAdapter.Config
extends Object

java.lang.Object
   ↳ androidx.recyclerview.widget.MergeAdapter.Config


The configuration object for a MergeAdapter.

Summary

Nested classes

class MergeAdapter.Config.Builder

The builder for MergeAdapter.Config class. 

enum MergeAdapter.Config.StableIdMode

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

Fields

public static final MergeAdapter.Config DEFAULT

public final boolean isolateViewTypes

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 RecyclerView.ViewHolders.

public final MergeAdapter.Config.StableIdMode stableIdMode

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

Inherited methods

Fields

DEFAULT

public static final MergeAdapter.Config DEFAULT

isolateViewTypes

public final boolean isolateViewTypes

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 RecyclerView.ViewHolders.

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

stableIdMode

public final MergeAdapter.Config.StableIdMode stableIdMode

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

There are 3 possible options: MergeAdapter.Config.StableIdMode.NO_STABLE_IDS: In this mode, MergeAdapter ignores the stable ids reported by sub adapters. This is the default mode. MergeAdapter.Config.StableIdMode.ISOLATED_STABLE_IDS: In this mode, MergeAdapter will return true from RecyclerView.Adapter.hasStableIds() and will require all added RecyclerView.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 RecyclerView.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 RecyclerView.ViewHolder.getItemId() might differ from the value returned from RecyclerView.Adapter.getItemId(int). MergeAdapter.Config.StableIdMode.SHARED_STABLE_IDS: In this mode, MergeAdapter will return true from RecyclerView.Adapter.hasStableIds() and will require all added RecyclerView.Adapters to have stable ids. Unlike MergeAdapter.Config.StableIdMode.ISOLATED_STABLE_IDS, MergeAdapter will not override the returned item ids. In this mode, child RecyclerView.Adapters must be aware of each-other and never return the same id unless an item is moved between RecyclerView.Adapters. Default value is MergeAdapter.Config.StableIdMode.NO_STABLE_IDS.