public static final class RepositoryAdapter.Builder
extends java.lang.Object
RepositoryAdapter.| Modifier and Type | Method and Description |
|---|---|
<T> RepositoryAdapter.Builder |
add(com.google.android.agera.Repository<T> repository,
RepositoryPresenter<T> presenter)
Specifies that the
RepositoryAdapter being built should present the given
repository next (after all previously added repositories, items and static layouts),
using the given presenter for any presentation logic. |
RepositoryAdapter.Builder |
addAdditionalObservable(com.google.android.agera.Observable observable)
Specifies that the
RepositoryAdapter being built should also observe the given
observable during its active time (between RepositoryAdapter.startObserving() and
RepositoryAdapter.stopObserving()), in addition to the repositories added via add(com.google.android.agera.Repository<T>, com.google.android.agera.rvadapter.RepositoryPresenter<T>). |
<T> RepositoryAdapter.Builder |
addItem(T item,
RepositoryPresenter<T> presenter)
Specifies that the
RepositoryAdapter being built should present the given static
item next (after all previously added repositories, static items and layouts),
using the given presenter for any presentation logic. |
RepositoryAdapter.Builder |
addLayout(LayoutPresenter presenter)
Specifies that the
RepositoryAdapter being built should present a static layout with
the given LayoutPresenter next (after all previously added repositories, static items
and layouts). |
RepositoryAdapter |
build()
Builds the
RepositoryAdapter that presents the provided repositories in order and
observes the repositories as well as any additional observables. |
android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder> |
whileResumed(android.app.Activity activity)
Builds the
RepositoryAdapter that presents the provided repositories in order and
observes the repositories as well as any additional observables while the provided
Activity is resumed (between Activity.onResume() and
Activity.onPause()). |
android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder> |
whileStarted(android.app.Activity activity)
Builds the
RepositoryAdapter that presents the provided repositories in order and
observes the repositories as well as any additional observables while the provided
Activity is started (between (between Activity.onStart() and
Activity.onStop()). |
@NonNull public <T> RepositoryAdapter.Builder add(@NonNull com.google.android.agera.Repository<T> repository, @NonNull RepositoryPresenter<T> presenter)
RepositoryAdapter being built should present the given
repository next (after all previously added repositories, items and static layouts),
using the given presenter for any presentation logic.
When the RepositoryAdapter is active (between RepositoryAdapter.startObserving() and
RepositoryAdapter.stopObserving()), updates from the repository will cause the data to be
reloaded, and the presenter may be asked to produce a sequence of fine-grained events
capturing the change of data. For mor details, see RepositoryPresenter.getUpdates(T, T, android.support.v7.util.ListUpdateCallback).
repository - The repository to be presented. This can be the same as a previously added
repository; this makes the resulting RepositoryAdapter present the same data in
different positions and/or different ways.presenter - The repository presenter associated with the repository at this
position of the RepositoryAdapter.@NonNull public <T> RepositoryAdapter.Builder addItem(@NonNull T item, @NonNull RepositoryPresenter<T> presenter)
RepositoryAdapter being built should present the given static
item next (after all previously added repositories, static items and layouts),
using the given presenter for any presentation logic. Added items will be considered
static, in the following semantics:
presenter.getItemCount(item); if this method returns 0 then this item-presenter
pair is not added to the RepositoryAdapter at all.
RepositoryPresenter.getItemId(T, int) will not be called; stable IDs of the presented
item views are generated by internal logic based on the position of this presenter and
the index of the item view within this presenter.
RepositoryPresenter.getUpdates(T, T, android.support.v7.util.ListUpdateCallback) will not be called; if any aspect of the item
presentation need to change following any observable event, then add(com.google.android.agera.Repository<T>, com.google.android.agera.rvadapter.RepositoryPresenter<T>) should be
used instead.
NOTE: adding an item with this method (as with addLayout(com.google.android.agera.rvadapter.LayoutPresenter)) will offset the stable
IDs in other RepositoryPresenters.
item - A static item. This can be the same as a previously added item; this makes the
resulting RepositoryAdapter present the same data in different positions and/or
different ways.presenter - The repository presenter associated with the item at this position
of the RepositoryAdapter.@NonNull public RepositoryAdapter.Builder addLayout(@NonNull LayoutPresenter presenter)
RepositoryAdapter being built should present a static layout with
the given LayoutPresenter next (after all previously added repositories, static items
and layouts). This has a similar semantics with addItem(T, com.google.android.agera.rvadapter.RepositoryPresenter<T>), except that the item view
count is fixed to be 1 and that an item object is not required.
NOTE: adding a layout with this method (as with addItem(T, com.google.android.agera.rvadapter.RepositoryPresenter<T>)) will offset the stable
IDs in other RepositoryPresenters.
presenter - The layout presenter to be presented at this position of the
RepositoryAdapter.@NonNull public RepositoryAdapter.Builder addAdditionalObservable(@NonNull com.google.android.agera.Observable observable)
RepositoryAdapter being built should also observe the given
observable during its active time (between RepositoryAdapter.startObserving() and
RepositoryAdapter.stopObserving()), in addition to the repositories added via add(com.google.android.agera.Repository<T>, com.google.android.agera.rvadapter.RepositoryPresenter<T>). Events
from this observable will trigger updates for all RepositoryPresenters. Use this when
events that could happen without affecting any repository data may affect how the presenters
work.
For details about the effect on fine-grained events, see
RepositoryPresenter.getUpdates(T, T, android.support.v7.util.ListUpdateCallback).
observable - The observable to be observed. This should not be any repository added via
add(com.google.android.agera.Repository<T>, com.google.android.agera.rvadapter.RepositoryPresenter<T>); they will be observed automatically.@NonNull public RepositoryAdapter build()
RepositoryAdapter that presents the provided repositories in order and
observes the repositories as well as any additional observables. If a subclass of
RepositoryAdapter is needed to cover special requirements, client code should create
a new instance of the subclass, passing this builder to the base constructor
RepositoryAdapter.RepositoryAdapter(Builder).@NonNull
public android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder> whileResumed(@NonNull
android.app.Activity activity)
RepositoryAdapter that presents the provided repositories in order and
observes the repositories as well as any additional observables while the provided
Activity is resumed (between Activity.onResume() and
Activity.onPause()).
Note: Can only be called from Activity.onCreate(android.os.Bundle) ()}
@NonNull
public android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder> whileStarted(@NonNull
android.app.Activity activity)
RepositoryAdapter that presents the provided repositories in order and
observes the repositories as well as any additional observables while the provided
Activity is started (between (between Activity.onStart() and
Activity.onStop()).
Note: Can only be called from Activity.onCreate(android.os.Bundle) ()}