| 
				
			 | 
			
			
				@@ -2,10 +2,13 @@ package com.reactnativenavigation.views; 
			 | 
		
	
		
			
			| 
				2
			 | 
			
				2
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				 import android.content.Context; 
			 | 
		
	
		
			
			| 
				4
			 | 
			
				4
			 | 
			
			
				 import android.os.Bundle; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				5
			 | 
			
			
				+import android.view.View; 
			 | 
		
	
		
			
			| 
				5
			 | 
			
				6
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				6
			 | 
			
				7
			 | 
			
			
				 import com.facebook.react.ReactRootView; 
			 | 
		
	
		
			
			| 
				7
			 | 
			
				8
			 | 
			
			
				 import com.reactnativenavigation.NavigationApplication; 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				9
			 | 
			
			
				 import com.reactnativenavigation.react.ReactViewHacks; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				+import com.reactnativenavigation.screens.SingleScreen; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+import com.reactnativenavigation.utils.ViewUtils; 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				12
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				10
			 | 
			
				13
			 | 
			
			
				 public class ContentView extends ReactRootView { 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				14
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -13,6 +16,9 @@ public class ContentView extends ReactRootView { 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				16
			 | 
			
			
				     private String navigatorEventId; 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				17
			 | 
			
			
				     private final Bundle navigationParams; 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				18
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				+    boolean isContentVisible = false; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				20
			 | 
			
			
				+    private SingleScreen.OnDisplayListener onDisplayListener; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				21
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				22
			 | 
			
			
				     public ContentView(Context context, String screenId, Bundle navigationParams) { 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				23
			 | 
			
			
				         this(context, screenId, navigationParams, null); 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				24
			 | 
			
			
				     } 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -41,7 +47,32 @@ public class ContentView extends ReactRootView { 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				47
			 | 
			
			
				         ReactViewHacks.preventMountAfterReattachedToWindow(this); 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				48
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				49
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+    @Override 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+    public void onViewAdded(final View child) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+        super.onViewAdded(child); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+        detectContentViewVisible(child); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+    private void detectContentViewVisible(View child) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+        if (onDisplayListener != null) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+            ViewUtils.runOnPreDraw(child, new Runnable() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+                @Override 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+                public void run() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+                    if (!isContentVisible) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+                        isContentVisible = true; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+                        onDisplayListener.onDisplay(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+                        onDisplayListener = null; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+                    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+                } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+            }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				71
			 | 
			
			
				     private void attachToJS() { 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				72
			 | 
			
			
				         startReactApplication(NavigationApplication.instance.getReactGateway().getReactInstanceManager(), screenId, navigationParams); 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				73
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+    public void setOnDisplayListener(SingleScreen.OnDisplayListener onDisplayListener) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+        this.onDisplayListener = onDisplayListener; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				78
			 | 
			
			
				 } 
			 |