Fix NonStaticNestedClass: Make inner class static (#55501)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55501

The BaseVMFocusChangeListener inner class does not reference any members
of its outer class BaseViewManager. Making it static improves memory
efficiency by avoiding the implicit reference to the outer class instance.

Also removed the unused type parameter <V extends View> and changed the
method parameters from T to View since only View interface methods are used.

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D92020879

fbshipit-source-id: a26378ed6f9f5dfcc64c49aaf734559e1e7be09e
This commit is contained in:
David Vacca authored and meta-codesync[bot] committed 2026-02-12 23:24:00 -08:00
1 parent 349cf1595b
commit e803a3499d
1 file changed
+3 -3
@@ -1012,18 +1012,18 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
* especially helpful for views that are recycled so we can retain and restore the original
* listener upon recycling (onDropViewInstance).
*/
private class BaseVMFocusChangeListener<V extends View> implements OnFocusChangeListener {
private static class BaseVMFocusChangeListener implements OnFocusChangeListener {
private @Nullable OnFocusChangeListener mOriginalFocusChangeListener;
public BaseVMFocusChangeListener(@Nullable OnFocusChangeListener originalFocusChangeListener) {
mOriginalFocusChangeListener = originalFocusChangeListener;
}
public void attach(T view) {
public void attach(View view) {
view.setOnFocusChangeListener(this);
}
public void detach(T view) {
public void detach(View view) {
view.setOnFocusChangeListener(mOriginalFocusChangeListener);
}