Skip to content

Commit

Permalink
Cleanup unused methods of view recycling in Android (#36906)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #36906

There are some unused methods of view recycling in Android

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: cortinico, genkikondo

Differential Revision: D44677790

fbshipit-source-id: 59bdbbee4f739c6427112c5a4b07c42d05e65d90
  • Loading branch information
mdvacca authored and facebook-github-bot committed Apr 19, 2023
1 parent 4768a27 commit 65bf785
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public abstract class ViewManager<T extends View, C extends ReactShadowNode>
extends BaseJavaModule {

private static String NAME = ViewManager.class.getSimpleName();
private static final String NAME = ViewManager.class.getSimpleName();

/**
* For View recycling: we store a Stack of unused, dead Views. This is null by default, and when
Expand All @@ -46,21 +46,13 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
*/
@Nullable private HashMap<Integer, Stack<T>> mRecyclableViews = null;

private int mRecyclableViewsBufferSize = 1024;

/** Call in constructor of concrete ViewManager class to enable. */
protected void setupViewRecycling() {
if (ReactFeatureFlags.enableViewRecycling) {
mRecyclableViews = new HashMap<>();
}
}

/** Call in constructor of concrete ViewManager class to enable. */
protected void setupViewRecycling(int bufferSize) {
mRecyclableViewsBufferSize = bufferSize;
setupViewRecycling();
}

private @Nullable Stack<T> getRecyclableViewStack(int surfaceId) {
if (mRecyclableViews == null) {
return null;
Expand Down Expand Up @@ -224,11 +216,7 @@ public void onDropViewInstance(@NonNull T view) {
ThemedReactContext themedReactContext = (ThemedReactContext) viewContext;
int surfaceId = themedReactContext.getSurfaceId();
@Nullable Stack<T> recyclableViews = getRecyclableViewStack(surfaceId);

// Any max buffer size <0 results in an infinite buffer size
if (recyclableViews != null
&& (mRecyclableViewsBufferSize < 0
|| recyclableViews.size() < mRecyclableViewsBufferSize)) {
if (recyclableViews != null) {
recyclableViews.push(prepareToRecycleView(themedReactContext, view));
}
}
Expand Down

0 comments on commit 65bf785

Please sign in to comment.