[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[Android] fix scroller memory leack because of OnAttachedListener (#1774
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yxping authored and YorkShen committed Nov 22, 2018
1 parent caff581 commit 4e27e0d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public class WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewL
private int pageSize = 0;
private boolean pageEnable = false;
private boolean mIsHostAttachedToWindow = false;
private View.OnAttachStateChangeListener mOnAttachStateChangeListener;

public static class Creator implements ComponentCreator {
@Override
Expand Down Expand Up @@ -376,6 +377,9 @@ public void destroy() {
if (mStickyMap != null) {
mStickyMap.clear();
}
if (mOnAttachStateChangeListener != null && getInnerView() != null) {
getInnerView().removeOnAttachStateChangeListener(mOnAttachStateChangeListener);
}
if (getInnerView() != null && getInnerView() instanceof IWXScroller) {
((IWXScroller) getInnerView()).destroy();
}
Expand Down Expand Up @@ -608,7 +612,7 @@ public void onGlobalLayout() {
}
}
});
host.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
mIsHostAttachedToWindow = true;
Expand All @@ -620,7 +624,8 @@ public void onViewDetachedFromWindow(View v) {
mIsHostAttachedToWindow = false;
dispatchDisappearEvent();
}
});
};
host.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
return host;
}

Expand Down

0 comments on commit 4e27e0d

Please sign in to comment.