diff --git a/litho-widget/src/main/java/com/facebook/litho/widget/RecyclerBinder.java b/litho-widget/src/main/java/com/facebook/litho/widget/RecyclerBinder.java index ef85945cadf..1c019129816 100644 --- a/litho-widget/src/main/java/com/facebook/litho/widget/RecyclerBinder.java +++ b/litho-widget/src/main/java/com/facebook/litho/widget/RecyclerBinder.java @@ -1122,6 +1122,25 @@ private void addToCurrentBatch(AsyncOperation operation) { mCurrentBatch.mOperations.add(operation); } + /** + * Replaces all items in the {@link RecyclerBinder} with the provided {@link RenderInfo}s. + */ + @UiThread + public final void replaceAll(List renderInfos) { + synchronized (this) { + if (mHasAsyncOperations) { + throw new RuntimeException( + "Trying to do a sync replaceAll when using asynchronous mutations!"); + } + mComponentTreeHolders.clear(); + for (RenderInfo renderInfo : renderInfos) { + mComponentTreeHolders.add(createComponentTreeHolder(renderInfo)); + } + } + mInternalAdapter.notifyDataSetChanged(); + mViewportManager.setShouldUpdate(true); + } + /** * See {@link RecyclerBinder#appendItem(RenderInfo)}. */