Fix null crash when using maintainVisibleContentPosition on Android (#38891)

Summary:
`mFirstVisibleView` is a weak ref so it can also be null when dereferencing.

This was reported on the original PR here https://github.com/facebook/react-native/pull/35049#discussion_r1288195469

## Changelog:

[ANDROID] [FIXED] - Fix null crash when using maintainVisibleContentPosition on Android

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

Test Plan: Not sure exactly in what cases this can happen, but the fix is trivial and makes sense.

Reviewed By: cortinico

Differential Revision: D48192154

Pulled By: rshest

fbshipit-source-id: 57a38a22a0e216a33603438355bde0013c014fbf
This commit is contained in:
Janic Duplessis
2023-08-10 11:23:06 -07:00
committed by fortmarek
parent 1794832a26
commit 7aeadbc249
@@ -103,6 +103,10 @@ public class MaintainVisibleScrollPositionHelper<ScrollViewT extends ViewGroup &
}
View firstVisibleView = mFirstVisibleView.get();
if (firstVisibleView == null) {
return;
}
Rect newFrame = new Rect();
firstVisibleView.getHitRect(newFrame);