| 
				
			 | 
			
			
				@@ -1,6 +1,7 @@ 
			 | 
		
	
		
			
			| 
				1
			 | 
			
				1
			 | 
			
			
				 package com.reactnativenavigation.views.collapsingToolbar; 
			 | 
		
	
		
			
			| 
				2
			 | 
			
				2
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				 import android.content.Context; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4
			 | 
			
			
				+import android.support.annotation.Nullable; 
			 | 
		
	
		
			
			| 
				4
			 | 
			
				5
			 | 
			
			
				 import android.view.MotionEvent; 
			 | 
		
	
		
			
			| 
				5
			 | 
			
				6
			 | 
			
			
				 import android.view.View; 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				7
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -8,12 +9,14 @@ import com.reactnativenavigation.params.CollapsingTopBarParams; 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				9
			 | 
			
			
				 import com.reactnativenavigation.params.StyleParams; 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				10
			 | 
			
			
				 import com.reactnativenavigation.utils.ViewUtils; 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				11
			 | 
			
			
				 import com.reactnativenavigation.views.TitleBar; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				+import com.reactnativenavigation.views.TranslucentAndSolidTitleBarBackground; 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				13
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				12
			 | 
			
				14
			 | 
			
			
				 public class CollapsingTitleBar extends TitleBar implements View.OnTouchListener { 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				15
			 | 
			
			
				     private CollapsingTextView title; 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				16
			 | 
			
			
				     private int collapsedHeight; 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				17
			 | 
			
			
				     private final ScrollListener scrollListener; 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				18
			 | 
			
			
				     private final CollapsingTopBarParams params; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				+    private @Nullable TranslucentAndSolidTitleBarBackground titleBarBackground; 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				20
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				18
			 | 
			
				21
			 | 
			
			
				     public CollapsingTitleBar(Context context, int collapsedHeight, ScrollListener scrollListener, CollapsingTopBarParams params) { 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				22
			 | 
			
			
				         super(context); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -39,6 +42,22 @@ public class CollapsingTitleBar extends TitleBar implements View.OnTouchListener 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				42
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				43
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				44
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+    @Override 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+    public void hideTitle() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+        super.hideTitle(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+        if (titleBarBackground != null) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				49
			 | 
			
			
				+            titleBarBackground.showTranslucentBackground(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+    @Override 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+    public void showTitle() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+        super.showTitle(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+        if (titleBarBackground != null) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+            titleBarBackground.showSolidBackground(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				61
			 | 
			
			
				     private void addCollapsingTitle() { 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				62
			 | 
			
			
				         if (params.hasBackgroundImage()) { 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				63
			 | 
			
			
				             title = new CollapsingTextView(getContext(), collapsedHeight); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -71,6 +90,20 @@ public class CollapsingTitleBar extends TitleBar implements View.OnTouchListener 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				90
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				91
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				92
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+    @Override 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+    protected void setBackground(StyleParams params) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+        if (hasTranslucentAndSolidBackground(params)) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+            titleBarBackground = new TranslucentAndSolidTitleBarBackground(params.collapsingTopBarParams.scrimColor); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+            setBackground(titleBarBackground); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+        } else { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				+            setTranslucent(params); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+    private boolean hasTranslucentAndSolidBackground(StyleParams params) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+        return params.topBarTranslucent && params.collapsingTopBarParams.scrimColor.hasColor(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				107
			 | 
			
			
				     public void collapse(CollapseAmount amount) { 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				108
			 | 
			
			
				         if (amount.hasExactAmount()) { 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				109
			 | 
			
			
				             collapse(amount.get()); 
			 |