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 zealotchen0 committed Apr 24, 2023
1 parent 1f4abfd commit 144524f
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 144524f

Please sign in to comment.