@@ -68,52 +68,52 @@ public abstract class FadingActionBarHelperBase implements OffsetMeasure {
6868
6969 public final <T extends FadingActionBarHelperBase > T actionBarBackground (int drawableResId ) {
7070 mActionBarBackgroundResId = drawableResId ;
71- return (T )this ;
71+ return (T ) this ;
7272 }
7373
7474 public final <T extends FadingActionBarHelperBase > T actionBarBackground (Drawable drawable ) {
7575 mActionBarBackgroundDrawable = drawable ;
76- return (T )this ;
76+ return (T ) this ;
7777 }
7878
7979 public final <T extends FadingActionBarHelperBase > T headerLayout (int layoutResId ) {
8080 mHeaderLayoutResId = layoutResId ;
81- return (T )this ;
81+ return (T ) this ;
8282 }
8383
8484 public final <T extends FadingActionBarHelperBase > T headerView (View view ) {
8585 mHeaderView = view ;
86- return (T )this ;
86+ return (T ) this ;
8787 }
8888
8989 public final <T extends FadingActionBarHelperBase > T headerOverlayLayout (int layoutResId ) {
9090 mHeaderOverlayLayoutResId = layoutResId ;
91- return (T )this ;
91+ return (T ) this ;
9292 }
9393
9494 public final <T extends FadingActionBarHelperBase > T headerOverlayView (View view ) {
9595 mHeaderOverlayView = view ;
96- return (T )this ;
96+ return (T ) this ;
9797 }
9898
9999 public final <T extends FadingActionBarHelperBase > T contentLayout (int layoutResId ) {
100100 mContentLayoutResId = layoutResId ;
101- return (T )this ;
101+ return (T ) this ;
102102 }
103103
104- public final <T extends FadingActionBarHelperBase > T contentView (View view ) {
104+ public final <T extends FadingActionBarHelperBase > T contentView (View view ) {
105105 mContentView = view ;
106- return (T )this ;
106+ return (T ) this ;
107107 }
108108
109109 public final <T extends FadingActionBarHelperBase > T lightActionBar (boolean value ) {
110110 mLightActionBar = value ;
111- return (T )this ;
111+ return (T ) this ;
112112 }
113113
114- public final <T extends FadingActionBarHelperBase > T parallax (boolean value ) {
114+ public final <T extends FadingActionBarHelperBase > T parallax (boolean value ) {
115115 mUseParallax = value ;
116- return (T )this ;
116+ return (T ) this ;
117117 }
118118
119119 public final View createView (Context context ) {
@@ -128,9 +128,6 @@ public final View createView(LayoutInflater inflater) {
128128 if (mContentView == null ) {
129129 mContentView = inflater .inflate (mContentLayoutResId , null );
130130 }
131- if (mHeaderView == null ) {
132- mHeaderView = inflater .inflate (mHeaderLayoutResId , null , false );
133- }
134131
135132 //
136133 // See if we are in a ListView, WebView or ScrollView scenario
@@ -139,7 +136,7 @@ public final View createView(LayoutInflater inflater) {
139136 View root ;
140137 if (listView != null ) {
141138 root = createListView (listView );
142- } else if (mContentView instanceof ObservableWebViewWithHeader ){
139+ } else if (mContentView instanceof ObservableWebViewWithHeader ) {
143140 root = createWebView ();
144141 } else {
145142 root = createScrollView ();
@@ -192,13 +189,15 @@ public void reset() {
192189 }
193190
194191 protected abstract int getActionBarHeight ();
192+
195193 protected abstract boolean isActionBarNull ();
194+
196195 protected abstract void setActionBarBackgroundDrawable (Drawable drawable );
197196
198197 protected <T > T getActionBarWithReflection (Activity activity , String methodName ) {
199198 try {
200199 Method method = activity .getClass ().getMethod (methodName );
201- return (T )method .invoke (activity );
200+ return (T ) method .invoke (activity );
202201 } catch (NoSuchMethodException e ) {
203202 e .printStackTrace ();
204203 } catch (IllegalArgumentException e ) {
@@ -208,11 +207,11 @@ protected <T> T getActionBarWithReflection(Activity activity, String methodName)
208207 } catch (InvocationTargetException e ) {
209208 e .printStackTrace ();
210209 } catch (ClassCastException e ) {
211- e .printStackTrace ();
210+ e .printStackTrace ();
212211 }
213212 return null ;
214213 }
215-
214+
216215 private Drawable .Callback mDrawableCallback = new Drawable .Callback () {
217216 @ Override
218217 public void invalidateDrawable (Drawable who ) {
@@ -238,7 +237,7 @@ private View createWebView() {
238237
239238 mHeaderContainer = (FrameLayout ) webViewContainer .findViewById (R .id .fab__header_container );
240239 initializeGradient (mHeaderContainer );
241- mHeaderContainer . addView ( mHeaderView , 0 );
240+ addHeaderView ( mHeaderContainer , mHeaderLayoutResId );
242241
243242 mMarginView = new FrameLayout (webView .getContext ());
244243 mMarginView .setBackgroundColor (Color .TRANSPARENT );
@@ -256,12 +255,12 @@ private View createScrollView() {
256255 mScrollView .setOnScrollChangedCallback (mOnScrollChangedListener );
257256 ViewGroup contentContainer = (ViewGroup ) scrollViewContainer .findViewById (R .id .fab__container );
258257 LinearLayout .LayoutParams layoutParams = new LinearLayout .LayoutParams (
259- LayoutParams .MATCH_PARENT , LayoutParams .MATCH_PARENT );
258+ LayoutParams .MATCH_PARENT , LayoutParams .MATCH_PARENT );
260259 mContentView .setLayoutParams (layoutParams );
261260 contentContainer .addView (mContentView );
262261 mHeaderContainer = (FrameLayout ) scrollViewContainer .findViewById (R .id .fab__header_container );
263262 initializeGradient (mHeaderContainer );
264- mHeaderContainer . addView ( mHeaderView , 0 );
263+ addHeaderView ( mHeaderContainer , mHeaderLayoutResId );
265264 mMarginView = (FrameLayout ) contentContainer .findViewById (R .id .fab__content_top_margin );
266265
267266 return scrollViewContainer ;
@@ -279,7 +278,7 @@ private View createListView(ListView listView) {
279278
280279 mHeaderContainer = (FrameLayout ) contentContainer .findViewById (R .id .fab__header_container );
281280 initializeGradient (mHeaderContainer );
282- mHeaderContainer . addView ( mHeaderView , 0 );
281+ addHeaderView ( mHeaderContainer , mHeaderLayoutResId );
283282
284283 mMarginView = new FrameLayout (listView .getContext ());
285284 mMarginView .setLayoutParams (new AbsListView .LayoutParams (LayoutParams .MATCH_PARENT , 0 ));
@@ -369,4 +368,11 @@ private void initializeGradient(ViewGroup headerContainer) {
369368 }
370369 gradientView .setBackgroundResource (gradient );
371370 }
371+
372+ private void addHeaderView (ViewGroup headerContainer , int headerLayoutResId ) {
373+ if (mHeaderView == null ) {
374+ mHeaderView = mInflater .inflate (headerLayoutResId , headerContainer , false );
375+ }
376+ headerContainer .addView (mHeaderView , 0 );
377+ }
372378}
0 commit comments