|
21 | 21 |
|
22 | 22 | import com.facebook.common.logging.FLog;
|
23 | 23 | import com.facebook.react.bridge.ReactContext;
|
| 24 | +import com.facebook.react.bridge.UiThreadUtil; |
24 | 25 | import com.facebook.react.common.ReactConstants;
|
25 | 26 |
|
26 | 27 | import javax.annotation.Nullable;
|
@@ -94,25 +95,30 @@ public DebugOverlayController(ReactContext reactContext) {
|
94 | 95 | mWindowManager = (WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE);
|
95 | 96 | }
|
96 | 97 |
|
97 |
| - public void setFpsDebugViewVisible(boolean fpsDebugViewVisible) { |
98 |
| - if (fpsDebugViewVisible && mFPSDebugViewContainer == null) { |
99 |
| - if (!permissionCheck(mReactContext)) { |
100 |
| - FLog.d(ReactConstants.TAG, "Wait for overlay permission to be set"); |
101 |
| - return; |
102 |
| - } |
103 |
| - mFPSDebugViewContainer = new FpsView(mReactContext); |
104 |
| - WindowManager.LayoutParams params = new WindowManager.LayoutParams( |
105 |
| - WindowManager.LayoutParams.MATCH_PARENT, |
106 |
| - WindowManager.LayoutParams.MATCH_PARENT, |
107 |
| - WindowOverlayCompat.TYPE_SYSTEM_OVERLAY, |
108 |
| - WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 98 | + public void setFpsDebugViewVisible(final boolean fpsDebugViewVisible) { |
| 99 | + UiThreadUtil.runOnUiThread(new Runnable() { |
| 100 | + @Override |
| 101 | + public void run() { |
| 102 | + if (fpsDebugViewVisible && mFPSDebugViewContainer == null) { |
| 103 | + if (!permissionCheck(mReactContext)) { |
| 104 | + FLog.d(ReactConstants.TAG, "Wait for overlay permission to be set"); |
| 105 | + return; |
| 106 | + } |
| 107 | + mFPSDebugViewContainer = new FpsView(mReactContext); |
| 108 | + WindowManager.LayoutParams params = new WindowManager.LayoutParams( |
| 109 | + WindowManager.LayoutParams.MATCH_PARENT, |
| 110 | + WindowManager.LayoutParams.MATCH_PARENT, |
| 111 | + WindowOverlayCompat.TYPE_SYSTEM_OVERLAY, |
| 112 | + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
109 | 113 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
|
110 |
| - PixelFormat.TRANSLUCENT); |
111 |
| - mWindowManager.addView(mFPSDebugViewContainer, params); |
112 |
| - } else if (!fpsDebugViewVisible && mFPSDebugViewContainer != null) { |
113 |
| - mFPSDebugViewContainer.removeAllViews(); |
114 |
| - mWindowManager.removeView(mFPSDebugViewContainer); |
115 |
| - mFPSDebugViewContainer = null; |
116 |
| - } |
| 114 | + PixelFormat.TRANSLUCENT); |
| 115 | + mWindowManager.addView(mFPSDebugViewContainer, params); |
| 116 | + } else if (!fpsDebugViewVisible && mFPSDebugViewContainer != null) { |
| 117 | + mFPSDebugViewContainer.removeAllViews(); |
| 118 | + mWindowManager.removeView(mFPSDebugViewContainer); |
| 119 | + mFPSDebugViewContainer = null; |
| 120 | + } |
| 121 | + } |
| 122 | + }); |
117 | 123 | }
|
118 | 124 | }
|
0 commit comments