Skip to content

Commit

Permalink
Migrate errorEventHandler to RecyclerBinderConfig
Browse files Browse the repository at this point in the history
Summary: Migrate the `errorEventHandler` to the shared configuration.

Reviewed By: pentiumao

Differential Revision: D51849295

fbshipit-source-id: 976f1871cf8bf787d5f4b0ca9b092cc86c4c8ad9
  • Loading branch information
Fabio Carballo authored and facebook-github-bot committed Dec 9, 2023
1 parent 8ea902a commit 193f2f5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.facebook.litho.sections.widget;

import androidx.annotation.Nullable;
import com.facebook.litho.ErrorEventHandler;
import com.facebook.litho.config.ComponentsConfiguration;
import com.facebook.litho.sections.SectionTree;
import com.facebook.litho.sections.config.SectionsConfiguration;
Expand Down Expand Up @@ -46,7 +45,6 @@ public class RecyclerBinderConfiguration {
private final boolean mIsIncrementalMountEnabled;
private final boolean mIsLayoutDiffingEnabled;
private final boolean mPostToFrontOfQueueForFirstChangeset;
@Nullable private final ErrorEventHandler mErrorEventHandler;

private final RecyclerBinderConfig mRecyclerBinderConfig;
private final boolean mShouldPreallocatePerMountContent;
Expand All @@ -72,7 +70,6 @@ private RecyclerBinderConfiguration(
boolean isIncrementalMountEnabled,
boolean isLayoutDiffingEnabled,
boolean postToFrontOfQueueForFirstChangeset,
@Nullable ErrorEventHandler errorEventHandler,
boolean shouldPreallocatePerMountContent) {
mRangeRatio = rangeRatio;
mLayoutHandlerFactory = layoutHandlerFactory;
Expand All @@ -85,7 +82,6 @@ private RecyclerBinderConfiguration(
mIsIncrementalMountEnabled = isIncrementalMountEnabled;
mIsLayoutDiffingEnabled = isLayoutDiffingEnabled;
mPostToFrontOfQueueForFirstChangeset = postToFrontOfQueueForFirstChangeset;
mErrorEventHandler = errorEventHandler;
mShouldPreallocatePerMountContent = shouldPreallocatePerMountContent;
mRecyclerBinderConfig = recyclerBinderConfig;
}
Expand Down Expand Up @@ -134,10 +130,6 @@ public boolean isPostToFrontOfQueueForFirstChangeset() {
return mPostToFrontOfQueueForFirstChangeset;
}

public @Nullable ErrorEventHandler getErrorEventHandler() {
return mErrorEventHandler;
}

public @Nullable ComponentsConfiguration getComponentsConfiguration() {
return mComponentsConfiguration;
}
Expand Down Expand Up @@ -166,7 +158,6 @@ public static class Builder {
!ComponentsConfiguration.isIncrementalMountGloballyDisabled;
private boolean mIsLayoutDiffingEnabled = ComponentsConfiguration.isLayoutDiffingEnabled;
private boolean mPostToFrontOfQueueForFirstChangeset;
private ErrorEventHandler mErrorEventHandler;
private boolean mShouldPreallocatePerMountContent;

Builder() {}
Expand All @@ -185,7 +176,6 @@ private Builder(RecyclerBinderConfiguration configuration) {
this.mIsLayoutDiffingEnabled = configuration.mIsLayoutDiffingEnabled;
this.mPostToFrontOfQueueForFirstChangeset =
configuration.mPostToFrontOfQueueForFirstChangeset;
this.mErrorEventHandler = configuration.mErrorEventHandler;
mShouldPreallocatePerMountContent = configuration.mShouldPreallocatePerMountContent;
}

Expand Down Expand Up @@ -283,11 +273,6 @@ public Builder postToFrontOfQueueForFirstChangeset(
return this;
}

public Builder errorEventHandler(@Nullable ErrorEventHandler errorEventHandler) {
mErrorEventHandler = errorEventHandler;
return this;
}

/**
* Whether this Recycler children should preallocate mount content after being generated. This
* will only work if the root {@link com.facebook.litho.ComponentTree} has set a preallocation
Expand Down Expand Up @@ -316,7 +301,6 @@ public RecyclerBinderConfiguration build() {
mIsIncrementalMountEnabled,
mIsLayoutDiffingEnabled,
mPostToFrontOfQueueForFirstChangeset,
mErrorEventHandler,
mShouldPreallocatePerMountContent);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ static void createInitialState(
.componentsConfiguration(binderConfiguration.getComponentsConfiguration())
.isReconciliationEnabled(binderConfiguration.isReconciliationEnabled())
.isLayoutDiffingEnabled(binderConfiguration.isLayoutDiffingEnabled())
.errorEventHandler(binderConfiguration.getErrorEventHandler())
.shouldPreallocatePerMountSpec(binderConfiguration.shouldPreallocatePerMountContent())
.startupLogger(startupLogger);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ object ExperimentalRecyclerCollectionComponentSpec {
.componentsConfiguration(binderConfiguration.componentsConfiguration)
.isReconciliationEnabled(binderConfiguration.isReconciliationEnabled)
.isLayoutDiffingEnabled(binderConfiguration.isLayoutDiffingEnabled)
.errorEventHandler(binderConfiguration.errorEventHandler)
.startupLogger(startupLogger)
val recyclerBinder = recyclerBinderBuilder.build(c)
val targetBinder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ object CollectionRecyclerSpec {
isReconciliationEnabled(isReconciliationEnabled)
incrementalMount(isIncrementalMountEnabled)
isLayoutDiffingEnabled(isLayoutDiffingEnabled)
errorEventHandler(errorEventHandler)
}
}
.build(c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ public static class Builder {
private @RecyclingStrategy int recyclingStrategy =
ComponentsConfiguration.recyclerBinderStrategy;
private @Nullable LithoLifecycleProvider lifecycleProvider;
private @Nullable ErrorEventHandler errorEventHandler;
private @Nullable RecyclerBinderAdapterDelegate adapterDelegate = null;

/**
Expand Down Expand Up @@ -681,11 +680,6 @@ public Builder asyncInsertLayoutHandler(RunnableHandler handler) {
return this;
}

public Builder errorEventHandler(@Nullable ErrorEventHandler errorEventHandler) {
this.errorEventHandler = errorEventHandler;
return this;
}

public Builder lithoLifecycleProvider(LithoLifecycleProvider lithoLifecycleProvider) {
this.lifecycleProvider = lithoLifecycleProvider;
return this;
Expand Down Expand Up @@ -903,7 +897,7 @@ private RecyclerBinder(Builder builder) {
mPreallocatePerMountSpec = builder.shouldPreallocatePerMountSpec;
mComponentWarmer = mRecyclerBinderConfig.componentWarmer;
mStartupLogger = builder.startupLogger;
mErrorEventHandler = builder.errorEventHandler;
mErrorEventHandler = mRecyclerBinderConfig.errorEventHandler;
mRecyclingStrategy = builder.recyclingStrategy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.facebook.litho.widget

import com.facebook.kotlin.compilerplugins.dataclassgenerate.annotation.DataClassGenerate
import com.facebook.kotlin.compilerplugins.dataclassgenerate.annotation.Mode
import com.facebook.litho.ErrorEventHandler
import com.facebook.litho.config.LayoutThreadPoolConfiguration

/**
Expand Down Expand Up @@ -110,7 +111,8 @@ data class RecyclerBinderConfig(
* provided, the handler created by the factory will be used instead of the one that would have
* been created by this config.
*/
@JvmField val threadPoolConfig: LayoutThreadPoolConfiguration? = null
@JvmField val threadPoolConfig: LayoutThreadPoolConfiguration? = null,
@JvmField val errorEventHandler: ErrorEventHandler? = null
) {

init {
Expand Down Expand Up @@ -158,6 +160,7 @@ class RecyclerBinderConfigBuilder internal constructor(configuration: RecyclerBi
private var itemViewCacheSize = configuration.itemViewCacheSize
private var hasDynamicItemHeight = configuration.hasDynamicItemHeight
private var threadPoolConfig = configuration.threadPoolConfig
private var errorEventHandler = configuration.errorEventHandler

fun isCircular(isCircular: Boolean) = also { this.isCircular = isCircular }

Expand Down Expand Up @@ -193,6 +196,10 @@ class RecyclerBinderConfigBuilder internal constructor(configuration: RecyclerBi
threadPoolConfig: LayoutThreadPoolConfiguration?
): RecyclerBinderConfigBuilder = also { this.threadPoolConfig = threadPoolConfig }

fun errorEventHandler(errorEventHandler: ErrorEventHandler?): RecyclerBinderConfigBuilder = also {
this.errorEventHandler = errorEventHandler
}

fun build(): RecyclerBinderConfig {
return RecyclerBinderConfig(
isCircular = isCircular,
Expand All @@ -204,6 +211,7 @@ class RecyclerBinderConfigBuilder internal constructor(configuration: RecyclerBi
componentWarmer = componentWarmer,
estimatedViewportCount = estimatedViewportCount,
hasDynamicItemHeight = hasDynamicItemHeight,
threadPoolConfig = threadPoolConfig)
threadPoolConfig = threadPoolConfig,
errorEventHandler = errorEventHandler)
}
}

0 comments on commit 193f2f5

Please sign in to comment.