API check for removeOnGlobalLayoutListener in ReactRootView

Reviewed By: AaaChiuuu

Differential Revision: D5308604

fbshipit-source-id: adf4abbdd59e54c18fcae946f2f7e3af89e7190c
This commit is contained in:
Andrew Y. Chen 2017-06-23 10:19:06 -07:00 committed by Facebook Github Bot
parent a6607968c4
commit ecccd06662
1 changed files with 6 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import javax.annotation.Nullable;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.MotionEvent;
@ -180,7 +181,11 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (mIsAttachedToInstance) {
getViewTreeObserver().removeOnGlobalLayoutListener(getCustomGlobalLayoutListener());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
getViewTreeObserver().removeOnGlobalLayoutListener(getCustomGlobalLayoutListener());
} else {
getViewTreeObserver().removeGlobalOnLayoutListener(getCustomGlobalLayoutListener());
}
}
}