ConcatAdapter.Config
public
static
final
class
ConcatAdapter.Config
extends Object
java.lang.Object | |
↳ | androidx.recyclerview.widget.ConcatAdapter.Config |
The configuration object for a ConcatAdapter
.
Summary
Nested classes | |
---|---|
class |
ConcatAdapter.Config.Builder
The builder for |
enum |
ConcatAdapter.Config.StableIdMode
Defines how |
Fields | |
---|---|
public
static
final
ConcatAdapter.Config |
DEFAULT
Default configuration for |
public
final
boolean |
isolateViewTypes
If |
public
final
ConcatAdapter.Config.StableIdMode |
stableIdMode
Defines whether the |
Inherited methods | |
---|---|
Fields
DEFAULT
public static final ConcatAdapter.Config DEFAULT
Default configuration for ConcatAdapter
where isolateViewTypes
is set to true
and stableIdMode
is set to
ConcatAdapter.Config.StableIdMode.NO_STABLE_IDS
.
isolateViewTypes
public final boolean isolateViewTypes
If false
, ConcatAdapter
assumes all assigned adapters share a global
view type pool such that they use the same view types to refer to the same
RecyclerView.ViewHolder
s.
Setting this to false
will allow nested adapters to share RecyclerView.ViewHolder
s 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.ViewHolder
s.
By default, it is set to true
which means ConcatAdapter
will isolate
view types across adapters, preventing them from using the same RecyclerView.ViewHolder
s.
stableIdMode
public final ConcatAdapter.Config.StableIdMode stableIdMode
Defines whether the ConcatAdapter
should support stable ids or not
(RecyclerView.Adapter.hasStableIds()
.
There are 3 possible options:
ConcatAdapter.Config.StableIdMode.NO_STABLE_IDS
: In this mode, ConcatAdapter
ignores the
stable
ids reported by sub adapters. This is the default mode.
ConcatAdapter.Config.StableIdMode.ISOLATED_STABLE_IDS
: In this mode, ConcatAdapter
will return
true
from RecyclerView.Adapter.hasStableIds()
and will require all added
RecyclerView.Adapter
s to have stable ids. As two different adapters may return same stable ids
because they are unaware of each-other, ConcatAdapter
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)
.
ConcatAdapter.Config.StableIdMode.SHARED_STABLE_IDS
: In this mode, ConcatAdapter
will return
true
from RecyclerView.Adapter.hasStableIds()
and will require all added
RecyclerView.Adapter
s to have stable ids. Unlike ConcatAdapter.Config.StableIdMode.ISOLATED_STABLE_IDS
,
ConcatAdapter
will not override the returned item ids. In this mode,
child RecyclerView.Adapter
s must be aware of each-other and never return the same id unless
an item is moved between RecyclerView.Adapter
s.
Default value is ConcatAdapter.Config.StableIdMode.NO_STABLE_IDS
.
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-03-24 UTC.