├── .gitattributes ├── .gitignore ├── Header2ActionBar ├── .gitignore ├── build.gradle ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── achep │ └── header2actionbar │ ├── FadingActionBarHelper.java │ ├── HeaderFragment.java │ └── NotifyingScrollView.java ├── LICENSE ├── README.md ├── art └── google_plus.png ├── build.gradle ├── downloads ├── Header2ActionBar-0.2.1.jar └── Header2ActionBar-0.2.jar ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample └── Header2ActionBarDemo │ ├── .gitignore │ ├── Header2ActionBarDemo.apk │ ├── build.gradle │ ├── proguard-rules.txt │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── achep │ │ └── header2actionbardemo │ │ ├── ListViewFragment.java │ │ ├── MainActivity.java │ │ └── Project.java │ ├── libs │ └── Header2ActionBar-0.2.1.jar │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── drawable │ ├── header_ab_shadow.xml │ └── header_bg.png │ ├── layout │ ├── activity_main.xml │ ├── fragment_header.xml │ └── fragment_listview.xml │ ├── menu │ └── main.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── drawables.xml │ ├── strings.xml │ └── styles.xml ├── screenshots ├── device-2013-12-05-115925.png └── device-2013-12-05-115955.png └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | 217 | #Idea 218 | *.iml 219 | .idea/ 220 | 221 | #gradle 222 | .gradle/ 223 | -------------------------------------------------------------------------------- /Header2ActionBar/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Header2ActionBar/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:0.6.+' 7 | } 8 | } 9 | apply plugin: 'android-library' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | android { 16 | compileSdkVersion 19 17 | buildToolsVersion "19.0.0" 18 | 19 | defaultConfig { 20 | minSdkVersion 14 21 | targetSdkVersion 19 22 | } 23 | release { 24 | runProguard false 25 | proguardFile 'proguard-rules.txt' 26 | proguardFile getDefaultProguardFile('proguard-android.txt') 27 | } 28 | } 29 | 30 | dependencies { 31 | } 32 | 33 | task clearJar(type: Delete) { 34 | delete 'build/libs/Header2ActionBar.jar' 35 | } 36 | 37 | task makeJar(type: Copy) { 38 | from('build/bundles/release/') 39 | into('build/libs/') 40 | include('classes.jar') 41 | rename ('classes.jar', 'Header2ActionBar.jar') 42 | } 43 | 44 | makeJar.dependsOn(clearJar, build) 45 | -------------------------------------------------------------------------------- /Header2ActionBar/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in F:/Android/android-studio/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /Header2ActionBar/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Header2ActionBar/src/main/java/com/achep/header2actionbar/FadingActionBarHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 AChep@xda 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.achep.header2actionbar; 18 | 19 | import android.app.ActionBar; 20 | import android.graphics.drawable.Drawable; 21 | import android.os.Build; 22 | import android.util.Log; 23 | 24 | /** 25 | * Created by AChep@xda 26 | */ 27 | public class FadingActionBarHelper { 28 | 29 | private static final String TAG = "FadingActionBarHelper"; 30 | 31 | private int mAlpha = 255; 32 | private Drawable mDrawable; 33 | private boolean isAlphaLocked; 34 | 35 | private final ActionBar mActionBar; 36 | 37 | public FadingActionBarHelper(final ActionBar actionBar) { 38 | mActionBar = actionBar; 39 | } 40 | 41 | public FadingActionBarHelper(final ActionBar actionBar, final Drawable drawable) { 42 | mActionBar = actionBar; 43 | setActionBarBackgroundDrawable(drawable); 44 | } 45 | 46 | public void setActionBarBackgroundDrawable(Drawable drawable) { 47 | setActionBarBackgroundDrawable(drawable, true); 48 | } 49 | 50 | public void setActionBarBackgroundDrawable(Drawable drawable, boolean mutate) { 51 | mDrawable = mutate ? drawable.mutate() : drawable; 52 | mActionBar.setBackgroundDrawable(mDrawable); 53 | 54 | if (mAlpha == 255) { 55 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) 56 | mAlpha = mDrawable.getAlpha(); 57 | } else { 58 | setActionBarAlpha(mAlpha); 59 | } 60 | } 61 | 62 | /** 63 | * An {@link android.app.ActionBar} background drawable. 64 | * 65 | * @see #setActionBarBackgroundDrawable(android.graphics.drawable.Drawable) 66 | * @see #setActionBarAlpha(int) 67 | */ 68 | public Drawable getActionBarBackgroundDrawable() { 69 | return mDrawable; 70 | } 71 | 72 | /** 73 | * Please use this method for global changes only! 74 | * This is helpful when you need to provide something like 75 | * Navigation drawer: lock ActionBar and set 76 | * {@link android.graphics.drawable.Drawable#setAlpha(int)} 77 | * to {@link #getActionBarBackgroundDrawable()} directly. 78 | * 79 | * @param alpha a value from 0 to 255 80 | * @see #getActionBarBackgroundDrawable() 81 | * @see #getActionBarAlpha() 82 | */ 83 | public void setActionBarAlpha(int alpha) { 84 | if (mDrawable == null) { 85 | Log.w(TAG, "Set action bar background before setting the alpha level!"); 86 | return; 87 | } 88 | if (!isAlphaLocked) mDrawable.setAlpha(alpha); 89 | mAlpha = alpha; 90 | } 91 | 92 | public int getActionBarAlpha() { 93 | return mAlpha; 94 | } 95 | 96 | /** 97 | * When ActionBar's alpha is locked {@link #setActionBarAlpha(int)} 98 | * won't change drawable\'s alpha (but will change {@link #getActionBarAlpha()} level) 99 | * 100 | * @param lock 101 | */ 102 | public void setActionBarAlphaLocked(boolean lock) { 103 | 104 | // Update alpha level on unlock 105 | if (isAlphaLocked != (isAlphaLocked = lock) && !isAlphaLocked) { 106 | setActionBarAlpha(mAlpha); 107 | } 108 | } 109 | 110 | public boolean isActionBarAlphaLocked() { 111 | return isAlphaLocked; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Header2ActionBar/src/main/java/com/achep/header2actionbar/HeaderFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 AChep@xda 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.achep.header2actionbar; 18 | 19 | import android.app.Activity; 20 | import android.app.Fragment; 21 | import android.os.Bundle; 22 | import android.view.LayoutInflater; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.widget.AbsListView; 26 | import android.widget.FrameLayout; 27 | import android.widget.LinearLayout; 28 | import android.widget.ListAdapter; 29 | import android.widget.ListView; 30 | import android.widget.ScrollView; 31 | import android.widget.Space; 32 | 33 | /** 34 | * Little header fragment. 35 | *

36 | * Important: Use {@link android.R.id#background} to specify background view and 37 | * {@link android.R.id#title} to specify view on top of the header 38 | * (for example: a shadow for {@code ActionBar}). 39 | *

40 | * Created by AChep@xda 41 | */ 42 | // let's \'/ 43 | // remember -= * =- 44 | // happy {.} 45 | // 2013 {.-'} 46 | // year! {`_.-'} 47 | // It was {-` _.-'} 48 | // amazing! `":=:"` 49 | // `---` 50 | public abstract class HeaderFragment extends Fragment { 51 | 52 | private static final String TAG = "HeaderFragment"; 53 | 54 | public static final int HEADER_BACKGROUND_SCROLL_NORMAL = 0; 55 | public static final int HEADER_BACKGROUND_SCROLL_PARALLAX = 1; 56 | public static final int HEADER_BACKGROUND_SCROLL_STATIC = 2; 57 | 58 | private FrameLayout mFrameLayout; 59 | private View mContentOverlay; 60 | 61 | // header 62 | private View mHeader; 63 | private View mHeaderHeader; 64 | private View mHeaderBackground; 65 | private int mHeaderHeight; 66 | private int mHeaderScroll; 67 | 68 | private int mHeaderBackgroundScrollMode = HEADER_BACKGROUND_SCROLL_NORMAL; 69 | 70 | private Space mFakeHeader; 71 | private boolean isListViewEmpty; 72 | 73 | // listeners 74 | private AbsListView.OnScrollListener mOnScrollListener; 75 | private OnHeaderScrollChangedListener mOnHeaderScrollChangedListener; 76 | 77 | public interface OnHeaderScrollChangedListener { 78 | public void onHeaderScrollChanged(float progress, int height, int scroll); 79 | } 80 | 81 | public void setOnHeaderScrollChangedListener(OnHeaderScrollChangedListener listener) { 82 | mOnHeaderScrollChangedListener = listener; 83 | } 84 | 85 | public void setHeaderBackgroundScrollMode(int scrollMode) { 86 | mHeaderBackgroundScrollMode = scrollMode; 87 | } 88 | 89 | @Override 90 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 91 | final Activity activity = getActivity(); 92 | assert activity != null; 93 | mFrameLayout = new FrameLayout(activity); 94 | 95 | mHeader = onCreateHeaderView(inflater, mFrameLayout); 96 | mHeaderHeader = mHeader.findViewById(android.R.id.title); 97 | mHeaderBackground = mHeader.findViewById(android.R.id.background); 98 | assert mHeader.getLayoutParams() != null; 99 | mHeaderHeight = mHeader.getLayoutParams().height; 100 | 101 | mFakeHeader = new Space(activity); 102 | mFakeHeader.setLayoutParams( 103 | new ListView.LayoutParams(0, mHeaderHeight)); 104 | 105 | View content = onCreateContentView(inflater, mFrameLayout); 106 | if (content instanceof ListView) { 107 | isListViewEmpty = true; 108 | 109 | final ListView listView = (ListView) content; 110 | listView.addHeaderView(mFakeHeader); 111 | listView.setOnScrollListener(new AbsListView.OnScrollListener() { 112 | 113 | @Override 114 | public void onScrollStateChanged(AbsListView absListView, int scrollState) { 115 | if (mOnScrollListener != null) { 116 | mOnScrollListener.onScrollStateChanged(absListView, scrollState); 117 | } 118 | } 119 | 120 | @Override 121 | public void onScroll(AbsListView absListView, int firstVisibleItem, 122 | int visibleItemCount, int totalItemCount) { 123 | if (mOnScrollListener != null) { 124 | mOnScrollListener.onScroll( 125 | absListView, firstVisibleItem, 126 | visibleItemCount, totalItemCount); 127 | } 128 | 129 | if (isListViewEmpty) { 130 | scrollHeaderTo(0); 131 | } else { 132 | final View child = absListView.getChildAt(0); 133 | assert child != null; 134 | scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight); 135 | } 136 | } 137 | }); 138 | } else { 139 | 140 | // Merge fake header view and content view. 141 | final LinearLayout view = new LinearLayout(activity); 142 | view.setLayoutParams(new ViewGroup.LayoutParams( 143 | ViewGroup.LayoutParams.MATCH_PARENT, 144 | ViewGroup.LayoutParams.MATCH_PARENT)); 145 | view.setOrientation(LinearLayout.VERTICAL); 146 | view.addView(mFakeHeader); 147 | view.addView(content); 148 | 149 | // Put merged content to ScrollView 150 | final NotifyingScrollView scrollView = new NotifyingScrollView(activity); 151 | scrollView.addView(view); 152 | scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() { 153 | @Override 154 | public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { 155 | scrollHeaderTo(-t); 156 | } 157 | }); 158 | content = scrollView; 159 | } 160 | 161 | mFrameLayout.addView(content); 162 | mFrameLayout.addView(mHeader); 163 | 164 | // Content overlay view always shows at the top of content. 165 | if ((mContentOverlay = onCreateContentOverlayView(inflater, mFrameLayout)) != null) { 166 | mFrameLayout.addView(mContentOverlay, new FrameLayout.LayoutParams( 167 | ViewGroup.LayoutParams.MATCH_PARENT, 168 | ViewGroup.LayoutParams.MATCH_PARENT)); 169 | } 170 | 171 | // Post initial scroll 172 | mFrameLayout.post(new Runnable() { 173 | @Override 174 | public void run() { 175 | scrollHeaderTo(0, true); 176 | } 177 | }); 178 | 179 | return mFrameLayout; 180 | } 181 | 182 | private void scrollHeaderTo(int scrollTo) { 183 | scrollHeaderTo(scrollTo, false); 184 | } 185 | 186 | private void scrollHeaderTo(int scrollTo, boolean forceChange) { 187 | scrollTo = Math.min(Math.max(scrollTo, -mHeaderHeight), 0); 188 | if (mHeaderScroll == (mHeaderScroll = scrollTo) & !forceChange) return; 189 | 190 | setViewTranslationY(mHeader, scrollTo); 191 | setViewTranslationY(mHeaderHeader, -scrollTo); 192 | 193 | switch (mHeaderBackgroundScrollMode) { 194 | case HEADER_BACKGROUND_SCROLL_NORMAL: 195 | setViewTranslationY(mHeaderBackground, 0); 196 | break; 197 | case HEADER_BACKGROUND_SCROLL_PARALLAX: 198 | setViewTranslationY(mHeaderBackground, -scrollTo / 1.6f); 199 | break; 200 | case HEADER_BACKGROUND_SCROLL_STATIC: 201 | setViewTranslationY(mHeaderBackground, -scrollTo); 202 | break; 203 | } 204 | 205 | if (mContentOverlay != null) { 206 | final ViewGroup.LayoutParams lp = mContentOverlay.getLayoutParams(); 207 | final int delta = mHeaderHeight + scrollTo; 208 | lp.height = mFrameLayout.getHeight() - delta; 209 | mContentOverlay.setLayoutParams(lp); 210 | mContentOverlay.setTranslationY(delta); 211 | } 212 | 213 | notifyOnHeaderScrollChangeListener( 214 | (float) -scrollTo / mHeaderHeight, 215 | mHeaderHeight, 216 | -scrollTo); 217 | } 218 | 219 | private void setViewTranslationY(View view, float translationY) { 220 | if (view != null) view.setTranslationY(translationY); 221 | } 222 | 223 | private void notifyOnHeaderScrollChangeListener(float progress, int height, int scroll) { 224 | if (mOnHeaderScrollChangedListener != null) { 225 | mOnHeaderScrollChangedListener.onHeaderScrollChanged(progress, height, scroll); 226 | } 227 | } 228 | 229 | public abstract View onCreateHeaderView(LayoutInflater inflater, ViewGroup container); 230 | 231 | public abstract View onCreateContentView(LayoutInflater inflater, ViewGroup container); 232 | 233 | public abstract View onCreateContentOverlayView(LayoutInflater inflater, ViewGroup container); 234 | 235 | public void setListViewAdapter(ListView listView, ListAdapter adapter) { 236 | isListViewEmpty = adapter == null; 237 | listView.setAdapter(null); 238 | listView.removeHeaderView(mFakeHeader); 239 | listView.addHeaderView(mFakeHeader); 240 | listView.setAdapter(adapter); 241 | } 242 | 243 | /** 244 | * {@inheritDoc AbsListView#setOnScrollChangedListener} 245 | */ 246 | public void setListViewOnScrollChangedListener(AbsListView.OnScrollListener listener) { 247 | mOnScrollListener = listener; 248 | } 249 | 250 | // ////////////////////////////////////////// 251 | // //////////// -- GETTERS -- /////////////// 252 | // ////////////////////////////////////////// 253 | 254 | public View getHeaderView() { 255 | return mHeader; 256 | } 257 | 258 | public View getHeaderHeaderView() { 259 | return mHeaderHeader; 260 | } 261 | 262 | public View getHeaderBackgroundView() { 263 | return mHeaderBackground; 264 | } 265 | 266 | public int getHeaderBackgroundScrollMode() { 267 | return mHeaderBackgroundScrollMode; 268 | } 269 | 270 | } 271 | -------------------------------------------------------------------------------- /Header2ActionBar/src/main/java/com/achep/header2actionbar/NotifyingScrollView.java: -------------------------------------------------------------------------------- 1 | package com.achep.header2actionbar; 2 | 3 | import android.content.Context; 4 | import android.os.Build; 5 | import android.util.AttributeSet; 6 | import android.widget.ScrollView; 7 | 8 | /** 9 | * @author Cyril Mottier with modifications from Manuel Peinado 10 | */ 11 | public class NotifyingScrollView extends ScrollView { 12 | // Edge-effects don't mix well with the translucent action bar in Android 2.X 13 | private boolean mDisableEdgeEffects = true; 14 | 15 | /** 16 | * @author Cyril Mottier 17 | */ 18 | public interface OnScrollChangedListener { 19 | void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt); 20 | } 21 | 22 | private OnScrollChangedListener mOnScrollChangedListener; 23 | 24 | public NotifyingScrollView(Context context) { 25 | super(context); 26 | } 27 | 28 | public NotifyingScrollView(Context context, AttributeSet attrs) { 29 | super(context, attrs); 30 | } 31 | 32 | public NotifyingScrollView(Context context, AttributeSet attrs, int defStyle) { 33 | super(context, attrs, defStyle); 34 | } 35 | 36 | @Override 37 | protected void onScrollChanged(int l, int t, int oldl, int oldt) { 38 | super.onScrollChanged(l, t, oldl, oldt); 39 | if (mOnScrollChangedListener != null) { 40 | mOnScrollChangedListener.onScrollChanged(this, l, t, oldl, oldt); 41 | } 42 | } 43 | 44 | public void setOnScrollChangedListener(OnScrollChangedListener listener) { 45 | mOnScrollChangedListener = listener; 46 | } 47 | 48 | @Override 49 | protected float getTopFadingEdgeStrength() { 50 | // http://stackoverflow.com/a/6894270/244576 51 | if (mDisableEdgeEffects && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { 52 | return 0.0f; 53 | } 54 | return super.getTopFadingEdgeStrength(); 55 | } 56 | 57 | @Override 58 | protected float getBottomFadingEdgeStrength() { 59 | // http://stackoverflow.com/a/6894270/244576 60 | if (mDisableEdgeEffects && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { 61 | return 0.0f; 62 | } 63 | return super.getBottomFadingEdgeStrength(); 64 | } 65 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Header2ActionBar 2 | ========== 3 | Header2ActionBar is a library which implements the fading action bar effect that can be seen in the new Play Music and Google Newspaper apps. 4 | 5 | ![My image][1] ![My image][2] 6 | 7 | Usage 8 | ----- 9 | 10 | Using the library is really simple, just [look at the source code of the provided samples][3]. 11 | 12 | Developed By 13 | -------------------- 14 | 15 | Artem Chepurnoy - 16 | 17 | 18 | Follow me on Google+ 20 | 21 | 22 | License 23 | ----------- 24 | 25 | Copyright (C) 2013 AChep@xda 26 | 27 | Licensed under the Apache License, Version 2.0 (the "License"); 28 | you may not use this file except in compliance with the License. 29 | You may obtain a copy of the License at 30 | 31 | http://www.apache.org/licenses/LICENSE-2.0 32 | 33 | Unless required by applicable law or agreed to in writing, software 34 | distributed under the License is distributed on an "AS IS" BASIS, 35 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 36 | See the License for the specific language governing permissions and 37 | limitations under the License. 38 | 39 | 40 | 41 | [1]: https://github.com/AChep/Header2ActionBar/raw/master/screenshots/device-2013-12-05-115925.png 42 | [2]: https://github.com/AChep/Header2ActionBar/raw/master/screenshots/device-2013-12-05-115955.png 43 | [3]: https://github.com/AChep/Header2ActionBar/tree/master/sample/Header2ActionBarDemo/src/main/java/com/achep/header2actionbardemo -------------------------------------------------------------------------------- /art/google_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/art/google_plus.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. -------------------------------------------------------------------------------- /downloads/Header2ActionBar-0.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/downloads/Header2ActionBar-0.2.1.jar -------------------------------------------------------------------------------- /downloads/Header2ActionBar-0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/downloads/Header2ActionBar-0.2.jar -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/Header2ActionBarDemo.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/sample/Header2ActionBarDemo/Header2ActionBarDemo.apk -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:0.6.+' 7 | } 8 | } 9 | apply plugin: 'android' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | android { 16 | compileSdkVersion 19 17 | buildToolsVersion '19.0.0' 18 | 19 | defaultConfig { 20 | minSdkVersion 14 21 | targetSdkVersion 19 22 | } 23 | buildTypes { 24 | release { 25 | runProguard false 26 | proguardFile getDefaultProguardFile('proguard-android.txt') 27 | } 28 | } 29 | productFlavors { 30 | defaultFlavor { 31 | proguardFile 'proguard-rules.txt' 32 | } 33 | } 34 | } 35 | 36 | dependencies { 37 | compile files('src/main/libs/Header2ActionBar-0.2.1.jar') 38 | } 39 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in F:/Android/android-studio/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/sample/Header2ActionBarDemo/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/java/com/achep/header2actionbardemo/ListViewFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 AChep@xda 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.achep.header2actionbardemo; 17 | 18 | import android.app.Activity; 19 | import android.app.Fragment; 20 | import android.os.AsyncTask; 21 | import android.util.Log; 22 | import android.view.Gravity; 23 | import android.view.LayoutInflater; 24 | import android.view.View; 25 | import android.view.ViewGroup; 26 | import android.widget.ArrayAdapter; 27 | import android.widget.FrameLayout; 28 | import android.widget.ListView; 29 | import android.widget.ProgressBar; 30 | 31 | import com.achep.header2actionbar.HeaderFragment; 32 | 33 | import java.lang.ref.WeakReference; 34 | 35 | /** 36 | * Created by Artem on 06.12.13. 37 | */ 38 | public class ListViewFragment extends HeaderFragment { 39 | 40 | private ListView mListView; 41 | private String[] mListViewTitles; 42 | private boolean mLoaded; 43 | 44 | private AsyncLoadSomething mAsyncLoadSomething; 45 | private FrameLayout mContentOverlay; 46 | 47 | @Override 48 | public void onAttach(Activity activity) { 49 | super.onAttach(activity); 50 | 51 | setHeaderBackgroundScrollMode(HEADER_BACKGROUND_SCROLL_PARALLAX); 52 | setOnHeaderScrollChangedListener(new OnHeaderScrollChangedListener() { 53 | @Override 54 | public void onHeaderScrollChanged(float progress, int height, int scroll) { 55 | height -= getActivity().getActionBar().getHeight(); 56 | 57 | progress = (float) scroll / height; 58 | if (progress > 1f) progress = 1f; 59 | 60 | // * 61 | // `* 62 | // ```* 63 | // ``````* 64 | // ````````* 65 | // `````````* 66 | progress = (1 - (float) Math.cos(progress * Math.PI)) * 0.5f; 67 | 68 | ((MainActivity) getActivity()) 69 | .getFadingActionBarHelper() 70 | .setActionBarAlpha((int) (255 * progress)); 71 | } 72 | }); 73 | 74 | cancelAsyncTask(mAsyncLoadSomething); 75 | mAsyncLoadSomething = new AsyncLoadSomething(this); 76 | mAsyncLoadSomething.execute(); 77 | } 78 | 79 | @Override 80 | public void onDetach() { 81 | cancelAsyncTask(mAsyncLoadSomething); 82 | super.onDetach(); 83 | } 84 | 85 | @Override 86 | public View onCreateHeaderView(LayoutInflater inflater, ViewGroup container) { 87 | return inflater.inflate(R.layout.fragment_header, container, false); 88 | } 89 | 90 | @Override 91 | public View onCreateContentView(LayoutInflater inflater, ViewGroup container) { 92 | mListView = (ListView) inflater.inflate(R.layout.fragment_listview, container, false); 93 | if (mLoaded) setListViewTitles(mListViewTitles); 94 | return mListView; 95 | } 96 | 97 | @Override 98 | public View onCreateContentOverlayView(LayoutInflater inflater, ViewGroup container) { 99 | ProgressBar progressBar = new ProgressBar(getActivity()); 100 | mContentOverlay = new FrameLayout(getActivity()); 101 | mContentOverlay.addView(progressBar, new FrameLayout.LayoutParams( 102 | ViewGroup.LayoutParams.WRAP_CONTENT, 103 | ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); 104 | if (mLoaded) mContentOverlay.setVisibility(View.GONE); 105 | return mContentOverlay; 106 | } 107 | 108 | private void setListViewTitles(String[] titles) { 109 | mLoaded = true; 110 | mListViewTitles = titles; 111 | if (mListView == null) return; 112 | 113 | mListView.setVisibility(View.VISIBLE); 114 | setListViewAdapter(mListView, new ArrayAdapter( 115 | getActivity(), android.R.layout.simple_list_item_1, 116 | mListViewTitles)); 117 | } 118 | 119 | private void cancelAsyncTask(AsyncTask task) { 120 | if (task != null) task.cancel(false); 121 | } 122 | 123 | // ////////////////////////////////////////// 124 | // ///////////// -- LOADER -- /////////////// 125 | // ////////////////////////////////////////// 126 | 127 | private static class AsyncLoadSomething extends AsyncTask { 128 | 129 | private static final String TAG = "AsyncLoadSomething"; 130 | 131 | final WeakReference weakFragment; 132 | 133 | public AsyncLoadSomething(ListViewFragment fragment) { 134 | this.weakFragment = new WeakReference(fragment); 135 | } 136 | 137 | @Override 138 | protected void onPreExecute() { 139 | super.onPreExecute(); 140 | 141 | final ListViewFragment audioFragment = weakFragment.get(); 142 | if (audioFragment.mListView != null) audioFragment.mListView.setVisibility(View.INVISIBLE); 143 | if (audioFragment.mContentOverlay != null) audioFragment.mContentOverlay.setVisibility(View.VISIBLE); 144 | } 145 | 146 | @Override 147 | protected String[] doInBackground(Void... voids) { 148 | 149 | try { 150 | // Emulate long downloading 151 | Thread.sleep(2000); 152 | } catch (InterruptedException e) { 153 | e.printStackTrace(); 154 | } 155 | 156 | return new String[]{"Placeholder", "Placeholder", "Placeholder", "Placeholder", 157 | "Placeholder", "Placeholder", "Placeholder", "Placeholder", 158 | "Placeholder", "Placeholder", "Placeholder", "Placeholder", 159 | "Placeholder", "Placeholder", "Placeholder", "Placeholder", 160 | "Placeholder", "Placeholder", "Placeholder", "Placeholder", 161 | "Placeholder", "Placeholder", "Placeholder", "Placeholder"}; 162 | } 163 | 164 | @Override 165 | protected void onPostExecute(String[] titles) { 166 | super.onPostExecute(titles); 167 | final ListViewFragment audioFragment = weakFragment.get(); 168 | if (audioFragment == null) { 169 | if (Project.DEBUG) Log.d(TAG, "Skipping.., because there is no fragment anymore."); 170 | return; 171 | } 172 | 173 | if (audioFragment.mContentOverlay != null) audioFragment.mContentOverlay.setVisibility(View.GONE); 174 | audioFragment.setListViewTitles(titles); 175 | } 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/java/com/achep/header2actionbardemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 AChep@xda 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.achep.header2actionbardemo; 17 | 18 | import android.app.Activity; 19 | import android.content.Intent; 20 | import android.net.Uri; 21 | import android.os.Bundle; 22 | import android.view.Menu; 23 | import android.view.MenuItem; 24 | 25 | import com.achep.header2actionbar.FadingActionBarHelper; 26 | 27 | public class MainActivity extends Activity { 28 | 29 | private static final String LINK_TO_GITHUB = "https://github.com/AChep/Header2ActionBar"; 30 | 31 | private FadingActionBarHelper mFadingActionBarHelper; 32 | 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_main); 37 | 38 | mFadingActionBarHelper = new FadingActionBarHelper(getActionBar(), 39 | getResources().getDrawable(R.drawable.actionbar_bg)); 40 | 41 | if (savedInstanceState == null) { 42 | getFragmentManager().beginTransaction() 43 | .add(R.id.container, new ListViewFragment()) 44 | .commit(); 45 | } 46 | } 47 | 48 | 49 | @Override 50 | public boolean onCreateOptionsMenu(Menu menu) { 51 | 52 | // Inflate the menu; this adds items to the action bar if it is present. 53 | getMenuInflater().inflate(R.menu.main, menu); 54 | return true; 55 | } 56 | 57 | @Override 58 | public boolean onOptionsItemSelected(MenuItem item) { 59 | // Handle action bar item clicks here. The action bar will 60 | // automatically handle clicks on the Home/Up button, so long 61 | // as you specify a parent activity in AndroidManifest.xml. 62 | int id = item.getItemId(); 63 | if (id == R.id.action_github) { // open repo at GitHub 64 | Uri uri = Uri.parse(LINK_TO_GITHUB); 65 | Intent intent = new Intent(Intent.ACTION_VIEW, uri); 66 | startActivity(intent); 67 | return true; 68 | } 69 | return super.onOptionsItemSelected(item); 70 | } 71 | 72 | public FadingActionBarHelper getFadingActionBarHelper() { 73 | return mFadingActionBarHelper; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/java/com/achep/header2actionbardemo/Project.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 AChep@xda 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.achep.header2actionbardemo; 17 | 18 | /** 19 | * Created by Artem on 06.12.13. 20 | */ 21 | public class Project { 22 | 23 | public static final boolean DEBUG = true; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/libs/Header2ActionBar-0.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/sample/Header2ActionBarDemo/src/main/libs/Header2ActionBar-0.2.1.jar -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/sample/Header2ActionBarDemo/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/sample/Header2ActionBarDemo/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/sample/Header2ActionBarDemo/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/sample/Header2ActionBarDemo/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/drawable/header_ab_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/drawable/header_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/sample/Header2ActionBarDemo/src/main/res/drawable/header_bg.png -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/layout/fragment_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 13 | 14 | 24 | 25 | 31 | 32 | 38 | 39 | 40 | 41 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/layout/fragment_listview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 |

4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #0099CC 6 | 7 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 8dp 7 | 16dp 8 | 4dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | @color/actionbar_bg 6 | 7 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Header2ActionBarDemo 5 | Hello world! 6 | Settings 7 | GitHub 8 | Test title text 9 | Test subtitle text 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/Header2ActionBarDemo/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 14 | 23 | 24 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /screenshots/device-2013-12-05-115925.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/screenshots/device-2013-12-05-115925.png -------------------------------------------------------------------------------- /screenshots/device-2013-12-05-115955.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AChep/Header2ActionBar/cba481dbf27210ae0e86d100218027b8f626b573/screenshots/device-2013-12-05-115955.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':Header2ActionBar' 2 | --------------------------------------------------------------------------------