Skip to content

Commit

Permalink
fix(android): memory leak of RecyclerViewEventHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
iPel authored and hippy-actions[bot] committed Apr 19, 2023
1 parent c481eb4 commit a2bd080
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ public void sendOnScrollEvent() {
}

private void observePreDraw() {
if (!isInitialListReadyNotified && viewTreeObserver == null) {
viewTreeObserver = hippyRecyclerView.getViewTreeObserver();
if (!isInitialListReadyNotified) {
if (viewTreeObserver == null) {
viewTreeObserver = hippyRecyclerView.getViewTreeObserver();
}
viewTreeObserver.addOnPreDrawListener(preDrawListener);
}
}
Expand Down Expand Up @@ -396,7 +398,9 @@ public void onViewAttachedToWindow(View v) {

@Override
public void onViewDetachedFromWindow(View v) {

if (!isInitialListReadyNotified && viewTreeObserver != null) {
viewTreeObserver.removeOnPreDrawListener(preDrawListener);
}
}

@Override
Expand Down

0 comments on commit a2bd080

Please sign in to comment.