Fix crash when reloading with Perf Monitor enabled
Reviewed By: mdvacca Differential Revision: D7678392 fbshipit-source-id: 5fcf3bda545896f48543a95d4885c6492fac961e
This commit is contained in:
parent
b92b38acf9
commit
4fcd9970bd
|
@ -21,6 +21,7 @@ import android.widget.FrameLayout;
|
|||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -94,25 +95,30 @@ import javax.annotation.Nullable;
|
|||
mWindowManager = (WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
}
|
||||
|
||||
public void setFpsDebugViewVisible(boolean fpsDebugViewVisible) {
|
||||
if (fpsDebugViewVisible && mFPSDebugViewContainer == null) {
|
||||
if (!permissionCheck(mReactContext)) {
|
||||
FLog.d(ReactConstants.TAG, "Wait for overlay permission to be set");
|
||||
return;
|
||||
}
|
||||
mFPSDebugViewContainer = new FpsView(mReactContext);
|
||||
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowOverlayCompat.TYPE_SYSTEM_OVERLAY,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
public void setFpsDebugViewVisible(final boolean fpsDebugViewVisible) {
|
||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (fpsDebugViewVisible && mFPSDebugViewContainer == null) {
|
||||
if (!permissionCheck(mReactContext)) {
|
||||
FLog.d(ReactConstants.TAG, "Wait for overlay permission to be set");
|
||||
return;
|
||||
}
|
||||
mFPSDebugViewContainer = new FpsView(mReactContext);
|
||||
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowOverlayCompat.TYPE_SYSTEM_OVERLAY,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
mWindowManager.addView(mFPSDebugViewContainer, params);
|
||||
} else if (!fpsDebugViewVisible && mFPSDebugViewContainer != null) {
|
||||
mFPSDebugViewContainer.removeAllViews();
|
||||
mWindowManager.removeView(mFPSDebugViewContainer);
|
||||
mFPSDebugViewContainer = null;
|
||||
}
|
||||
PixelFormat.TRANSLUCENT);
|
||||
mWindowManager.addView(mFPSDebugViewContainer, params);
|
||||
} else if (!fpsDebugViewVisible && mFPSDebugViewContainer != null) {
|
||||
mFPSDebugViewContainer.removeAllViews();
|
||||
mWindowManager.removeView(mFPSDebugViewContainer);
|
||||
mFPSDebugViewContainer = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue