|
@@ -27,7 +27,7 @@ import com.reactnativenavigation.views.element.Element;
|
27
|
27
|
import java.util.Collections;
|
28
|
28
|
import java.util.List;
|
29
|
29
|
|
30
|
|
-public abstract class ViewController<T extends ViewGroup> implements ViewTreeObserver.OnGlobalLayoutListener {
|
|
30
|
+public abstract class ViewController<T extends ViewGroup> implements ViewTreeObserver.OnGlobalLayoutListener, ViewGroup.OnHierarchyChangeListener {
|
31
|
31
|
|
32
|
32
|
private Runnable onAppearedListener;
|
33
|
33
|
private boolean appearEventPosted;
|
|
@@ -155,6 +155,7 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
|
155
|
155
|
throw new RuntimeException("Tried to create view after it has already been destroyed");
|
156
|
156
|
}
|
157
|
157
|
view = createView();
|
|
158
|
+ view.setOnHierarchyChangeListener(this);
|
158
|
159
|
view.getViewTreeObserver().addOnGlobalLayoutListener(this);
|
159
|
160
|
}
|
160
|
161
|
return view;
|
|
@@ -226,6 +227,7 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
|
226
|
227
|
}
|
227
|
228
|
if (view != null) {
|
228
|
229
|
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
230
|
+ view.setOnHierarchyChangeListener(null);
|
229
|
231
|
if (view.getParent() instanceof ViewGroup) {
|
230
|
232
|
((ViewManager) view.getParent()).removeView(view);
|
231
|
233
|
}
|
|
@@ -253,6 +255,24 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
|
253
|
255
|
}
|
254
|
256
|
}
|
255
|
257
|
|
|
258
|
+ @Override
|
|
259
|
+ public void onChildViewAdded(View parent, View child) {
|
|
260
|
+ if (parent instanceof ViewGroup &&
|
|
261
|
+ child instanceof ViewGroup &&
|
|
262
|
+ YellowBoxHelper.isYellowBox((ViewGroup) parent, (ViewGroup) child)) {
|
|
263
|
+ onYellowBoxAdded(child);
|
|
264
|
+ }
|
|
265
|
+ }
|
|
266
|
+
|
|
267
|
+ @Override
|
|
268
|
+ public void onChildViewRemoved(View view, View view1) {
|
|
269
|
+
|
|
270
|
+ }
|
|
271
|
+
|
|
272
|
+ protected void onYellowBoxAdded(View yellowBox) {
|
|
273
|
+
|
|
274
|
+ }
|
|
275
|
+
|
256
|
276
|
void runOnPreDraw(Task<T> task) {
|
257
|
277
|
UiUtils.runOnPreDrawOnce(getView(), () -> task.run(getView()));
|
258
|
278
|
}
|