瀏覽代碼

Delay onDisplay until react finishes layout cycle

Apparently runOnPreDraw is not enough anymore, possibly broke in RN 0.51
Guy Carmeli 6 年之前
父節點
當前提交
90b47f7910
共有 1 個檔案被更改,包括 12 行新增7 行删除
  1. 12
    7
      android/app/src/main/java/com/reactnativenavigation/views/ContentView.java

+ 12
- 7
android/app/src/main/java/com/reactnativenavigation/views/ContentView.java 查看文件

@@ -81,16 +81,21 @@ public class ContentView extends ReactRootView {
81 81
         detectContentViewVisible(child);
82 82
     }
83 83
 
84
-    private void detectContentViewVisible(View child) {
84
+    private void detectContentViewVisible(final View child) {
85 85
         if (onDisplayListener != null) {
86
-            ViewUtils.runOnPreDraw(child, new Runnable() {
86
+            post(new Runnable() {
87 87
                 @Override
88 88
                 public void run() {
89
-                    if (!isContentVisible) {
90
-                        isContentVisible = true;
91
-                        onDisplayListener.onDisplay();
92
-                        onDisplayListener = null;
93
-                    }
89
+                    ViewUtils.runOnPreDraw(child, new Runnable() {
90
+                        @Override
91
+                        public void run() {
92
+                            if (!isContentVisible) {
93
+                                isContentVisible = true;
94
+                                onDisplayListener.onDisplay();
95
+                                onDisplayListener = null;
96
+                            }
97
+                        }
98
+                    });
94 99
                 }
95 100
             });
96 101
         }