Repository: florent37/MaterialViewPager
Branch: master
Commit: e2fb22e0ad95
Files: 75
Total size: 152.1 KB
Directory structure:
gitextract_vckdg7ln/
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── circle.yml
├── gradle/
│ ├── bintray-android-v1.gradle
│ ├── install-v1.gradle
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── materialviewpager/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── github/
│ │ └── florent37/
│ │ └── materialviewpager/
│ │ ├── MaterialViewPager.java
│ │ ├── MaterialViewPagerAnimator.java
│ │ ├── MaterialViewPagerHeader.java
│ │ ├── MaterialViewPagerHeaderView.java
│ │ ├── MaterialViewPagerHelper.java
│ │ ├── MaterialViewPagerSettings.java
│ │ ├── Utils.java
│ │ └── header/
│ │ ├── HeaderDesign.java
│ │ ├── MaterialViewPagerHeaderDecorator.java
│ │ ├── MaterialViewPagerImageHeader.java
│ │ ├── MaterialViewPagerImageHelper.java
│ │ └── MaterialViewPagerKenBurnsHeader.java
│ └── res/
│ ├── layout/
│ │ ├── material_view_pager_imageview_header.xml
│ │ ├── material_view_pager_layout.xml
│ │ ├── material_view_pager_moving_header.xml
│ │ ├── material_view_pager_pagertitlestrip_newstand.xml
│ │ ├── material_view_pager_pagertitlestrip_standard.xml
│ │ ├── material_view_pager_placeholder.xml
│ │ ├── material_view_pager_viewpager.xml
│ │ ├── tools_list_item_card_big.xml
│ │ ├── tools_list_item_card_small.xml
│ │ ├── tools_list_items.xml
│ │ └── tools_material_view_pager_pagertitlestrip.xml
│ └── values/
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── ids.xml
│ └── styles.xml
├── publish.sh
├── sample/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── github/
│ │ └── florent37/
│ │ └── materialviewpager/
│ │ └── sample/
│ │ ├── DrawerActivity.java
│ │ ├── MainActivity.java
│ │ ├── TestListViewAdapter.java
│ │ ├── TestRecyclerViewAdapter.java
│ │ └── fragment/
│ │ ├── RecyclerViewFragment.java
│ │ └── ScrollFragment.java
│ └── res/
│ ├── drawable/
│ │ └── circle.xml
│ ├── layout/
│ │ ├── activity_main.xml
│ │ ├── drawer.xml
│ │ ├── fragment_list.xml
│ │ ├── fragment_recyclerview.xml
│ │ ├── fragment_scroll.xml
│ │ ├── fragment_webview.xml
│ │ ├── header_logo.xml
│ │ ├── header_logo_2.xml
│ │ ├── header_logo_full.xml
│ │ ├── header_logo_text.xml
│ │ ├── list_item_card_big.xml
│ │ └── list_item_card_small.xml
│ ├── menu/
│ │ └── menu_main.xml
│ ├── values/
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── values-w820dp/
│ └── dimens.xml
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
.gradle
.idea
*.iml
**/build/*
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
MaterialViewPager
=======
[](http://android-arsenal.com/details/1/1731)
[](http://androidweekly.net/issues/issue-151)
[](https://circleci.com/gh/florent37/MaterialViewPager)
Material Design ViewPager easy to use library
<a href="https://goo.gl/WXW8Dc">
<img alt="Android app on Google Play" src="https://developer.android.com/images/brand/en_app_rgb_wo_45.png" />
</a>
[](http://youtu.be/g6tTDVceM9E)
# Sample
<a href="https://goo.gl/WXW8Dc">
<img alt="Android app on Google Play" src="https://developer.android.com/images/brand/en_app_rgb_wo_45.png" />
</a>
And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.com/watch?v=r95Tt6AS18c)
# Download
<a href='https://ko-fi.com/A160LCC' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
In your module [](https://bintray.com/florent37/maven/MaterialViewPager/_latestVersion)
```groovy
compile 'com.github.florent37:materialviewpager:1.2.3'
//dependencies
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile 'com.github.bumptech.glide:glide:4.0.0'
```
# Usage
Add MaterialViewPager to your activity's layout
```xml
<com.github.florent37.materialviewpager.MaterialViewPager
android:id="@+id/materialViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:viewpager_logo="@layout/header_logo"
app:viewpager_logoMarginTop="100dp"
app:viewpager_color="@color/colorPrimary"
app:viewpager_headerHeight="200dp"
app:viewpager_headerAlpha="1.0"
app:viewpager_hideLogoWithFade="false"
app:viewpager_hideToolbarAndTitle="true"
app:viewpager_enableToolbarElevation="true"
app:viewpager_parallaxHeaderFactor="1.5"
app:viewpager_headerAdditionalHeight="20dp"
app:viewpager_displayToolbarWhenSwipe="true"
app:viewpager_transparentToolbar="true"
app:viewpager_animatedHeaderImage="true"
app:viewpager_disableToolbar="false"
/>
```
with **header_logo.xml**
```xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/logo_white"
android:layout_width="wrap_content"
android:layout_height="@dimen/materialviewpager_logoHeight"
android:text="Material is Good"
android:textSize="30sp"
android:textColor="@android:color/white"/>
```
You will see on Android Studio Preview :

To get a beautiful screen and enable preview, you theme may follow
```xml
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:windowTranslucentStatus" tools:targetApi="21">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- Toolbar Theme / Apply white arrow -->
<item name="colorControlNormal">@android:color/white</item>
<item name="actionBarTheme">@style/AppTheme.ActionBarTheme</item>
<!-- Material Theme -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/accent_color</item>
<item name="android:navigationBarColor" tools:targetApi="21">@color/navigationBarColor</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>
<style name="AppTheme.ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<!-- White arrow -->
<item name="colorControlNormal">@android:color/white</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@color/drawerArrowColor</item>
</style>
```
# Retrieve the MaterialViewPager
You can use MaterialViewPager as an usual Android View, and get it by findViewById
```java
public class MainActivity extends ActionBarActivity {
private MaterialViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
}
}
```
# Customisation
First choose your color and height
```xml
<com.github.florent37.materialviewpager.MaterialViewPager
android:id="@+id/materialViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
...
app:viewpager_color="@color/colorPrimary"
app:viewpager_headerHeight="200dp"
...
/>
```
## Set your logo
```xml
<com.github.florent37.materialviewpager.MaterialViewPager
...
app:viewpager_logo="@layout/header_logo" <-- look custom logo layout
app:viewpager_logoMarginTop="100dp" <-- look at the preview
...
/>
```
### Titlebar Logo
[](http://youtu.be/82gvoUqXb_I)
Your logo's layout must
* layout_height="@dimen/materialviewpager_logoHeight"
**header_logo.xml**
```xml
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/logo_white"
android:layout_width="200dp"
android:layout_height="@dimen/materialviewpager_logoHeight"
android:fitsSystemWindows="true"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
android:src="@drawable/logo_white" />
```
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_hideLogoWithFade="false"
...
/>
```
### Fading Logo
[](http://youtu.be/9laniARQdqg)
**header_logo.xml**
```xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:background="@drawable/circle">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:fitsSystemWindows="true"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="@drawable/flying" />
</FrameLayout>
```
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_hideLogoWithFade="true"
...
/>
```
## Toolbar Animation
## Hide Logo and Toolbar
[](http://youtu.be/3ElFoqVKxag)
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_hideToolbarAndTitle="true"
...
/>
```
### Sticky Toolbar
[](http://youtu.be/3ElFoqVKxag)
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_hideToolbarAndTitle="false"
...
/>
```
### Transparent Toolbar
[](https://youtu.be/jUVO2cozQHQ)
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_transparentToolbar="true"
...
/>
```
## Header Layout
You can replace the header
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_header="@layout/myHeader"
...
/>
```
### Moving Header
Or use the default header, with a KenBurns animation
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_animatedHeaderImage="true"
...
/>
```
### Static Header
Or simply use an ImageView as header
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_animatedHeaderImage="false"
...
/>
```
## Custom Tab Bar
You can set you own tab bar, by default I provided 2 implementations
### Standard
[](http://youtu.be/VRinfxgewNE)
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_pagerTitleStrip="@layout/material_view_pager_pagertitlestrip_standard"
...
/>
```
### News Stand
[](http://youtu.be/MBzK2s7HU1A)
```xml
<com.github.florent37.materialviewpager.MaterialViewPager`
...
app:viewpager_pagerTitleStrip="@layout/material_view_pager_pagertitlestrip_newstand"
...
/>
```
### Or create your own tab bar
Create your own layout using a PagerSlidingTabStrip
**my_tabs.xml**
```xml
<com.astuetz.PagerSlidingTabStrip
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@id/materialviewpager_pagerTitleStrip"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:pstsPaddingMiddle="true"
app:pstsDividerPadding="20dp"
app:pstsIndicatorColor="#FFF"
app:pstsIndicatorHeight="2dp"
app:pstsShouldExpand="true"
app:pstsTabPaddingLeftRight="10dp"
app:pstsTabTextAllCaps="true"
tools:background="#A333"
/>
```
**Don't forget to give it id="@id/materialviewpager_pagerTitleStrip"**
```xml
<com.github.florent37.materialviewpager.MaterialViewPager
...
app:viewpager_pagerTitleStrip="@layout/my_tabs"
...
/>
```
# Animate Header
[](http://youtu.be/90gKwEL1j2I )
Simply add a listen to the ViewPager
```java
mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
@Override
public HeaderDesign getHeaderDesign(int page) {
switch (page) {
case 0:
return HeaderDesign.fromColorResAndUrl(
R.color.blue,
"http://cdn1.tnwcdn.com/wp-content/blogs.dir/1/files/2014/06/wallpaper_51.jpg");
case 1:
return HeaderDesign.fromColorResAndUrl(
R.color.green,
"https://fs01.androidpit.info/a/63/0e/android-l-wallpapers-630ea6-h900.jpg");
case 2:
return HeaderDesign.fromColorResAndUrl(
R.color.cyan,
"http://www.droid-life.com/wp-content/uploads/2014/10/lollipop-wallpapers10.jpg");
case 3:
return HeaderDesign.fromColorResAndUrl(
R.color.red,
"http://www.tothemobile.com/wp-content/uploads/2014/07/original.jpg");
}
//execute others actions if needed (ex : modify your header logo)
return null;
}
});
```
Available
```java
HeaderDesign.fromColorAndUrl(Color.BLUE,"http:...);
HeaderDesign.fromColorResAndUrl(R.color.blue,"http:...);
HeaderDesign.fromColorAndDrawable(Color.BLUE,myDrawable);
HeaderDesign.fromColorResAndDrawable(R.color.blue,myDrawable);
```
# Toolbar
```java
Toolbar toolbar = mViewPager.getToolbar();
if (toolbar != null) {
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(true);
}
```
# ViewPager
```java
ViewPager viewPager = mViewPager.getViewPager();
viewPage.setAdapter(...);
//After set an adapter to the ViewPager
mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
```
# RecyclerView
```java
mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
mRecyclerView.setAdapter(yourAdapter);
```
# ScrollView
The ScrollView must be an NestedScrollView`
```java
MaterialViewPagerHelper.registerScrollView(getActivity(), mScrollView, null);
```
And include @layout/material_view_pager_placeholder` as first child
```xml
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/material_view_pager_placeholder"/>
...your content...
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
```
# CHANGELOG
## 1.2.0
- header decorator instead of Adapter
## 1.1.3
- header is now clickable
- fixed some scrolling issues
## 1.1.2
- quick scroll fix
- can set a custom viewpager with app:viewpager_viewpager (the viewpager id must be id/materialviewpager_viewpager)
## 1.1.0
- orientation change fix
- header image display fix
- elements on header are now clickable
- notifyHeaderChanged
## 1.0.8
- added attribute viewpager_disableToolbar
## 1.0.7
- fix bug on low resolutions
## 1.0.6
- added attribute transparentToolbar
- added attribute animatedHeaderImage
- fixed bug when page is too small to scroll
- modified HeaderDesign implementation
## 1.0.5
- smoother toolbar scrolling
- fixed bug with fitSystemWindow
- added HeaderDesign to modify the header color & image
- added displayToolbarWhenSwipe attribute
## 1.0.4
Fixed :
- Orientation changed
- Memory Leak
- Android >2.3 with NineOldAndroid
- Removed ListView usage
## 1.0.3
Fixed : Rapid scrolling results in varying Toolbar height
RecyclerViewMaterialAdapter can handle a custom placeholder cells count (usefull for GridLayoutManager)
```java
public RecyclerViewMaterialAdapter(RecyclerView.Adapter adapter, int placeholderSize)
```
## 1.0.2
Added attributes
```java
app:viewpager_parallaxHeaderFactor="1.5"
app:viewpager_headerAdditionalHeight="20dp"
```
*parallaxHeaderFactor* Modify the speed of parallax header scroll (not the speed of KenBurns effect)
*parallaxHeaderFactor* Set up the height of the header's layout displayed behind the first cards view
Fixed issue when scroll down & scroll up multiples time while hideToolbarAndTitle="true"
## 1.0.1
Added attributes
```java
viewpager_headerAlpha="0.6"
```
# Community
Looking for contributors, feel free to fork !
Tell me if you're using my library in your application, I'll share it in this README
# Dependencies
* [Glide][glide] (from Bumptech)
* [KenBurnsView][kenburnsview] (from flavioarfaria)
* [Material PagerSlidingTabStrip][pagerslidingtitlestrip] (from jpardogo, forked from astuetz)
# Credits
Author: Florent Champigny [http://www.florentchampigny.com/](http://www.florentchampigny.com/)
Blog : [http://www.tutos-android-france.com/](http://www.tutos-android-france.com/)
Fiches Plateau Moto : [https://www.fiches-plateau-moto.fr/](https://www.fiches-plateau-moto.fr/)
<a href="https://goo.gl/WXW8Dc">
<img alt="Android app on Google Play" src="https://developer.android.com/images/brand/en_app_rgb_wo_45.png" />
</a>
<a href="https://plus.google.com/+florentchampigny">
<img alt="Follow me on Google+"
src="https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/gplus.png" />
</a>
<a href="https://twitter.com/florent_champ">
<img alt="Follow me on Twitter"
src="https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/twitter.png" />
</a>
<a href="https://www.linkedin.com/in/florentchampigny">
<img alt="Follow me on LinkedIn"
src="https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/linkedin.png" />
</a>
License
--------
Copyright 2015 florent37, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
[glide]: https://github.com/bumptech/glide
[kenburnsview]: https://github.com/flavioarfaria/KenBurnsView
[pagerslidingtitlestrip]: https://github.com/jpardogo/PagerSlidingTabStrip
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
google()
maven { url "http://dl.bintray.com/jfrog/jfrog-jars" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:+'
classpath 'io.fabric.tools:gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
minSdk = 14
sdk = 27
buildTools = "26.0.2"
supportVersion = "27.1.0"
libraryVersion = '1.2.3'
}
allprojects {
repositories {
jcenter()
maven { url "http://dl.bintray.com/florent37/maven" }
maven { url 'https://maven.fabric.io/public' }
maven { url "https://maven.google.com" }
google()
}
}
================================================
FILE: circle.yml
================================================
deployment:
release:
tag: /v.*/
commands:
- ./gradlew :materialviewpager:bintrayUpload
================================================
FILE: gradle/bintray-android-v1.gradle
================================================
apply plugin: 'com.jfrog.bintray'
version = libraryVersion
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
//archives javadocJar
archives sourcesJar
}
def _user = System.getenv("BINTRAY_USER")
def _key = System.getenv("BINTRAY_API_KEY")
def _passphrase = System.getenv("BINTRAY_PASSPHRASE")
if(project.rootProject.file('local.properties').exists() && (_user == null || _user.isEmpty())){
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
_user = properties.getProperty("bintray.user")
_key = properties.getProperty("bintray.apikey");
_passphrase = properties.getProperty("bintray.gpg.password")
}
// Bintray
bintray {
user = _user
key = _key
configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
userOrg = orgName
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
publish = true
publicDownloadNumbers = true
version {
desc = libraryDescription
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = _passphrase
//Optional. The passphrase for GPG signing'
}
}
}
}
================================================
FILE: gradle/install-v1.gradle
================================================
apply plugin: 'com.github.dcendents.android-maven'
group = publishedGroupId // Maven Group ID for the artifact
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
groupId publishedGroupId
artifactId artifact
// Add your description here
name libraryName
description libraryDescription
url siteUrl
// Set your license
licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
//from https://github.com/workarounds/bundler/blob/master/gradle/install-v1.gradle
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Mon Feb 27 17:10:37 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip
================================================
FILE: gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: materialviewpager/.gitignore
================================================
/build
================================================
FILE: materialviewpager/build.gradle
================================================
apply plugin: 'com.android.library'
apply plugin: 'com.github.ben-manes.versions'
android {
compileSdkVersion project.sdk
buildToolsVersion project.buildTools
defaultConfig {
minSdkVersion project.minSdk
targetSdkVersion project.sdk
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile (
'com.android.support:appcompat-v7:'+project.supportVersion,
'com.android.support:recyclerview-v7:'+project.supportVersion,
'com.android.support:support-annotations:'+project.supportVersion
)
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile ('com.jpardogo.materialtabstrip:library:1.1.0') {
exclude module: 'support-v4'
}
compile 'com.github.bumptech.glide:glide:4.6.1'
}
ext {
bintrayRepo = 'maven'
bintrayName = 'MaterialViewPager'
orgName = 'florent37'
publishedGroupId = 'com.github.florent37'
libraryName = 'MaterialViewPager'
artifact = 'materialviewpager'
libraryDescription = 'MaterialViewPager'
siteUrl = 'https://github.com/florent37/MaterialViewPager'
gitUrl = 'https://github.com/florent37/MaterialViewPager.git'
libraryVersion = rootProject.ext.libraryVersion
developerId = 'florent37'
developerName = 'Florent Champigny'
developerEmail = 'champigny.florent@gmail.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
apply from: rootProject.file('gradle/install-v1.gradle')
apply from: rootProject.file('gradle/bintray-android-v1.gradle')
================================================
FILE: materialviewpager/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/florentchampigny/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: materialviewpager/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.florent37.materialviewpager" >
</manifest>
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java
================================================
package com.github.florent37.materialviewpager;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.astuetz.PagerSlidingTabStrip;
import com.github.florent37.materialviewpager.header.HeaderDesign;
import com.github.florent37.materialviewpager.header.MaterialViewPagerImageHelper;
/**
* Created by florentchampigny on 28/04/15.
* <p/>
* The main class of MaterialViewPager
* To use in an xml layout with attributes viewpager_*
* <p/>
* Display a preview with header, actual logo and fake cells
*/
public class MaterialViewPager extends FrameLayout implements ViewPager.OnPageChangeListener {
/**
* Contains all references to MatervialViewPager's header views
*/
protected MaterialViewPagerHeader materialViewPagerHeader;
//the child toolbar
protected Toolbar mToolbar;
//the child viewpager
protected ViewPager mViewPager;
//a view used to add placeholder color below the header
protected View headerBackground;
//a view used to add fading color over the headerBackgroundContainer
protected View toolbarLayoutBackground;
//Class containing the configuration of the MaterialViewPager
protected MaterialViewPagerSettings settings = new MaterialViewPagerSettings();
protected MaterialViewPager.Listener listener;
int lastPosition = -1;
int currentPagerState = Integer.MIN_VALUE;
/**
* the layout containing the header
* default : add @layout/material_view_pager_default_header
* with viewpager_header you can set your own layout
*/
private ViewGroup headerBackgroundContainer;
/**
* the layout containing tabs
* default : add @layout/material_view_pager_pagertitlestrip_standard
* with viewpager_pagerTitleStrip you can set your own layout
*/
private ViewGroup pagerTitleStripContainer;
/**
* the layout containing the viewpager, can be replaced to add your own implementation of viewpager
*/
private ViewGroup viewpagerContainer;
//region construct
/**
* the layout containing logo
* default : empty
* with viewpager_logo you can set your own layout
*/
private ViewGroup logoContainer;
public MaterialViewPager(Context context) {
super(context);
}
public MaterialViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
settings.handleAttributes(context, attrs);
}
public MaterialViewPager(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
settings.handleAttributes(context, attrs);
}
//endregion
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public MaterialViewPager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
settings.handleAttributes(context, attrs);
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
this.settings = ss.settings;
if (headerBackground != null) {
headerBackground.setBackgroundColor(this.settings.color);
}
MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(this.getContext());
//-1*ss.yOffset restore to 0
animator.restoreScroll(-1 * ss.yOffset, ss.settings);
MaterialViewPagerHelper.register(getContext(), animator);
}
@Override
protected Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
//end
ss.settings = this.settings;
ss.yOffset = MaterialViewPagerHelper.getAnimator(getContext()).lastYOffset;
return ss;
}
/**
* Retrieve the displayed viewpager, don't forget to use
* getPagerTitleStrip().setAdapter(materialviewpager.getViewPager())
* after set an adapter
*
* @return the displayed viewpager
*/
public ViewPager getViewPager() {
return mViewPager;
}
/**
* Retrieve the displayed tabs
*
* @return the displayed tabs
*/
public PagerSlidingTabStrip getPagerTitleStrip() {
return (PagerSlidingTabStrip) pagerTitleStripContainer.findViewById(R.id.materialviewpager_pagerTitleStrip);
}
/**
* Retrieve the displayed toolbar
*
* @return the displayed toolbar
*/
public Toolbar getToolbar() {
return mToolbar;
}
/**
* Retrieve the displayed toolbar
*/
public void setToolbar(Toolbar toolbar) {
mToolbar = toolbar;
}
/**
* change the header displayed image with a fade
* may remove Picasso
*/
public void setImageUrl(String imageUrl, int fadeDuration) {
if (imageUrl != null) {
final ImageView headerBackgroundImage = (ImageView) findViewById(R.id.materialviewpager_imageHeader);
//if using MaterialViewPagerImageHeader
if (headerBackgroundImage != null) {
ViewCompat.setAlpha(headerBackgroundImage, settings.headerAlpha);
MaterialViewPagerImageHelper.setImageUrl(headerBackgroundImage, imageUrl, fadeDuration);
setImageHeaderDarkLayerAlpha();
}
}
}
/**
* change the header displayed image with a fade and an OnLoadListener
* may remove Picasso
*/
public void setImageUrl(String imageUrl, int fadeDuration, OnImageLoadListener imageLoadListener) {
if (imageLoadListener != null) {
MaterialViewPagerImageHelper.setImageLoadListener(imageLoadListener);
}
setImageUrl(imageUrl, fadeDuration);
}
/**
* change the header displayed image with a fade
* may remove Picasso
*/
public void setImageDrawable(Drawable drawable, int fadeDuration) {
if (drawable != null) {
final ImageView headerBackgroundImage = (ImageView) findViewById(R.id.materialviewpager_imageHeader);
//if using MaterialViewPagerImageHeader
if (headerBackgroundImage != null) {
ViewCompat.setAlpha(headerBackgroundImage, settings.headerAlpha);
MaterialViewPagerImageHelper.setImageDrawable(headerBackgroundImage, drawable, fadeDuration);
setImageHeaderDarkLayerAlpha();
}
}
}
/**
* Change alpha of the header image dark layer to reveal text.
*/
public void setImageHeaderDarkLayerAlpha() {
final View headerImageDarkLayerView = findViewById(R.id.materialviewpager_headerImageDarkLayer);
//if using MaterialViewPagerImageHeader
if (headerImageDarkLayerView != null) {
headerImageDarkLayerView.setBackgroundColor(getResources().getColor(android.R.color.black));
ViewCompat.setAlpha(headerImageDarkLayerView, settings.imageHeaderDarkLayerAlpha);
}
}
/**
* Change the header color
*/
public void setColor(int color, int fadeDuration) {
if (MaterialViewPagerHelper.getAnimator(getContext()) != null) {
MaterialViewPagerHelper.getAnimator(getContext()).setColor(color, fadeDuration * 2);
}
}
public ViewGroup getHeaderBackgroundContainer() {
return headerBackgroundContainer;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (currentPagerState != ViewPager.SCROLL_STATE_SETTLING) {
if (positionOffset >= 0.5) {
onPageSelected(position + 1);
} else if (positionOffset <= -0.5) {
onPageSelected(position - 1);
} else {
onPageSelected(position);
}
}
}
public void notifyHeaderChanged() {
int position = lastPosition;
lastPosition = -1;
onPageSelected(position);
}
//region ViewPagerOnPageListener
@Override
public void onPageSelected(int position) {
if (position == lastPosition || listener == null) {
return;
}
HeaderDesign headerDesign = listener.getHeaderDesign(position);
if (headerDesign == null) {
return;
}
int fadeDuration = 400;
int color = headerDesign.getColor();
if (headerDesign.getColorRes() != 0) {
color = getContext().getResources().getColor(headerDesign.getColorRes());
}
if (headerDesign.getDrawable() != null) {
setImageDrawable(headerDesign.getDrawable(), fadeDuration);
} else {
setImageUrl(headerDesign.getImageUrl(), fadeDuration);
}
setColor(color, fadeDuration);
lastPosition = position;
}
@Override
public void onPageScrollStateChanged(int state) {
currentPagerState = state;
if (settings.displayToolbarWhenSwipe) {
MaterialViewPagerHelper.getAnimator(getContext()).onViewPagerPageChanged();
}
}
public void setMaterialViewPagerListener(Listener listener) {
this.listener = listener;
}
@Override
protected void onDetachedFromWindow() {
MaterialViewPagerHelper.unregister(getContext());
listener = null;
super.onDetachedFromWindow();
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
//add @layout/material_view_pager_layout as child, containing all the MaterialViewPager views
addView(LayoutInflater.from(getContext()).inflate(R.layout.material_view_pager_layout, this, false));
headerBackgroundContainer = (ViewGroup) findViewById(R.id.headerBackgroundContainer);
pagerTitleStripContainer = (ViewGroup) findViewById(R.id.pagerTitleStripContainer);
viewpagerContainer = (ViewGroup) findViewById(R.id.viewpager_layout);
logoContainer = (ViewGroup) findViewById(R.id.logoContainer);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
if (settings.disableToolbar) {
mToolbar.setVisibility(INVISIBLE);
}
{ //replace the viewpager ?
int viewPagerLayoutId = settings.viewpagerId;
if (viewPagerLayoutId != -1) {
viewpagerContainer.removeAllViews();
viewpagerContainer.addView(LayoutInflater.from(getContext()).inflate(viewPagerLayoutId, viewpagerContainer, false));
}
}
mViewPager = (ViewPager) findViewById(R.id.materialviewpager_viewpager);
mViewPager.addOnPageChangeListener(this);
//inflate subviews defined in attributes
{
int headerId = settings.headerLayoutId;
if (headerId == -1) {
if (settings.animatedHeaderImage) {
headerId = R.layout.material_view_pager_moving_header;
} else {
headerId = R.layout.material_view_pager_imageview_header;
}
}
headerBackgroundContainer.addView(LayoutInflater.from(getContext()).inflate(headerId, headerBackgroundContainer, false));
}
if (isInEditMode()) { //preview titlestrip
//add fake tabs on edit mode
settings.pagerTitleStripId = R.layout.tools_material_view_pager_pagertitlestrip;
}
if (settings.pagerTitleStripId != -1) {
pagerTitleStripContainer.addView(LayoutInflater.from(getContext()).inflate(settings.pagerTitleStripId, pagerTitleStripContainer, false));
}
if (settings.logoLayoutId != -1) {
logoContainer.addView(LayoutInflater.from(getContext()).inflate(settings.logoLayoutId, logoContainer, false));
if (settings.logoMarginTop != 0) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) logoContainer.getLayoutParams();
layoutParams.setMargins(0, settings.logoMarginTop, 0, 0);
logoContainer.setLayoutParams(layoutParams);
}
}
headerBackground = findViewById(R.id.headerBackground);
toolbarLayoutBackground = findViewById(R.id.toolbar_layout_background);
initialiseHeights();
//construct the materialViewPagerHeader with subviews
if (!isInEditMode()) {
materialViewPagerHeader = MaterialViewPagerHeader
.withToolbar(mToolbar)
.withToolbarLayoutBackground(toolbarLayoutBackground)
.withPagerSlidingTabStrip(pagerTitleStripContainer)
.withHeaderBackground(headerBackground)
.withStatusBackground(findViewById(R.id.statusBackground))
.withLogo(logoContainer);
//and construct the MaterialViewPagerAnimator
//attach it to the activity to enable MaterialViewPagerHeaderView.setMaterialHeight();
MaterialViewPagerHelper.register(getContext(), new MaterialViewPagerAnimator(this));
} else {
//if in edit mode, add fake cardsviews
View sample = LayoutInflater.from(getContext()).inflate(R.layout.tools_list_items, pagerTitleStripContainer, false);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) sample.getLayoutParams();
int marginTop = Math.round(Utils.dpToPx(settings.headerHeight + 10, getContext()));
params.setMargins(0, marginTop, 0, 0);
super.setLayoutParams(params);
addView(sample);
}
}
//endregion
private void initialiseHeights() {
if (headerBackground != null) {
headerBackground.setBackgroundColor(this.settings.color);
ViewGroup.LayoutParams layoutParams = headerBackground.getLayoutParams();
layoutParams.height = (int) Utils.dpToPx(this.settings.headerHeight + settings.headerAdditionalHeight, getContext());
headerBackground.setLayoutParams(layoutParams);
}
if (pagerTitleStripContainer != null) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) pagerTitleStripContainer.getLayoutParams();
int marginTop = (int) Utils.dpToPx(this.settings.headerHeight - 40, getContext());
layoutParams.setMargins(0, marginTop, 0, 0);
pagerTitleStripContainer.setLayoutParams(layoutParams);
}
if (toolbarLayoutBackground != null) {
ViewGroup.LayoutParams layoutParams = toolbarLayoutBackground.getLayoutParams();
layoutParams.height = (int) Utils.dpToPx(this.settings.headerHeight, getContext());
toolbarLayoutBackground.setLayoutParams(layoutParams);
}
}
public interface Listener {
HeaderDesign getHeaderDesign(int page);
}
public interface OnImageLoadListener {
void OnImageLoad(ImageView imageView, Bitmap bitmap);
}
static class SavedState extends BaseSavedState {
//required field that makes Parcelables from a Parcel
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
public MaterialViewPagerSettings settings;
public float yOffset;
SavedState(Parcelable superState) {
super(superState);
}
private SavedState(Parcel in) {
super(in);
this.settings = in.readParcelable(MaterialViewPagerSettings.class.getClassLoader());
this.yOffset = in.readFloat();
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeParcelable(this.settings, flags);
out.writeFloat(this.yOffset);
}
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java
================================================
package com.github.florent37.materialviewpager;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static com.github.florent37.materialviewpager.Utils.canScroll;
import static com.github.florent37.materialviewpager.Utils.colorWithAlpha;
import static com.github.florent37.materialviewpager.Utils.dpToPx;
import static com.github.florent37.materialviewpager.Utils.getTheVisibileView;
import static com.github.florent37.materialviewpager.Utils.minMax;
import static com.github.florent37.materialviewpager.Utils.scrollTo;
import static com.github.florent37.materialviewpager.Utils.setBackgroundColor;
import static com.github.florent37.materialviewpager.Utils.setElevation;
import static com.github.florent37.materialviewpager.Utils.setScale;
/**
* Created by florentchampigny on 24/04/15.
* <p>
* Listen to Scrollable inside MaterialViewPager
* When notified scroll, dispatch the current scroll to other scrollable
* <p>
* Note : didn't want to translate the MaterialViewPager or intercept Scroll,
* so added a ViewPager with scrollables containing a transparent placeholder on top
* <p>
* When scroll, animate the MaterialViewPager Header (toolbar, logo, color ...)
*/
public class MaterialViewPagerAnimator {
private static final String TAG = "MaterialViewPager";
//duration of translate header enter animation
private static final int ENTER_TOOLBAR_ANIMATION_DURATION = 300;
public static Boolean ENABLE_LOG = false;
//final toolbar layout elevation (if attr viewpager_enableToolbarElevation = true)
public final float elevation;
//max scroll which will be dispatched for all scrollable
private final float scrollMax;
// equals scrollMax in DP (saved to avoir convert to dp anytime I use it)
private final float scrollMaxDp;
float lastYOffset = -1; //the current yOffset
private float lastPercent = 0; //the current Percent
//contains the attributes given to MaterialViewPager from layout
private MaterialViewPagerSettings settings;
//list of all registered scrollers
private List<View> scrollViewList = new ArrayList<>();
//save all yOffsets of scrollables
private HashMap<Object, Integer> yOffsets = new HashMap<>();
private boolean followScrollToolbarIsVisible = false;
private float firstScrollValue = Float.MIN_VALUE;
private boolean justToolbarAnimated = false;
//intial distance between pager & toolbat
private float initialDistance = -1;
//contains MaterialViewPager subviews references
private MaterialViewPagerHeader mHeader;
//the tmp headerAnimator (not null if animating, else null)
private ValueAnimator headerAnimator;
MaterialViewPagerAnimator(MaterialViewPager materialViewPager) {
this.settings = materialViewPager.settings;
this.mHeader = materialViewPager.materialViewPagerHeader;
Context context = mHeader.getContext();
// initialise the scrollMax to headerHeight, so until the first cell touch the top of the screen
this.scrollMax = this.settings.headerHeight;
//save in into dp once
this.scrollMaxDp = Utils.dpToPx(this.scrollMax, context);
//heightMaxScrollToolbar = context.getResources().getDimension(R.dimen.material_viewpager_padding_top);
elevation = dpToPx(4, context);
}
/**
* Called when a scroller(RecyclerView/ListView,ScrollView,WebView) scrolled by the user
*
* @param source the scroller
* @param yOffset the scroller current yOffset
*/
private boolean onMaterialScrolled(Object source, float yOffset) {
if (initialDistance == -1 || initialDistance == 0) {
initialDistance = mHeader.mPagerSlidingTabStrip.getTop() - mHeader.toolbar.getBottom();
}
//only if yOffset changed
if (yOffset == lastYOffset) {
return false;
}
float scrollTop = -yOffset;
{
//parallax scroll of the Background ImageView (the KenBurnsView)
if (mHeader.headerBackground != null) {
if (this.settings.parallaxHeaderFactor != 0) {
ViewCompat.setTranslationY(mHeader.headerBackground, scrollTop / this.settings.parallaxHeaderFactor);
}
if (ViewCompat.getY(mHeader.headerBackground) >= 0) {
ViewCompat.setY(mHeader.headerBackground, 0);
}
}
}
log("yOffset" + yOffset);
//dispatch the new offset to all registered scrollables
dispatchScrollOffset(source, minMax(0, yOffset, scrollMaxDp));
float percent = yOffset / scrollMax;
log("percent1" + percent);
if (percent != 0) {
//distance between pager & toolbar
float newDistance = ViewCompat.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom();
percent = 1 - newDistance / initialDistance;
log("percent2" + percent);
}
if (Float.isNaN(percent)) //fix for orientation change
{
return false;
}
//fix quick scroll
if (percent == 0 && headerAnimator != null) {
cancelHeaderAnimator();
ViewCompat.setTranslationY(mHeader.toolbarLayout, 0);
}
percent = minMax(0, percent, 1);
{
if (!settings.toolbarTransparent) {
// change color of toolbar & viewpager indicator & statusBaground
setColorPercent(percent);
} else {
if (justToolbarAnimated) {
if (toolbarJoinsTabs()) {
setColorPercent(1);
} else if (lastPercent != percent) {
animateColorPercent(0, 200);
}
}
}
lastPercent = percent; //save the percent
if (mHeader.mPagerSlidingTabStrip != null) { //move the viewpager indicator
//float newY = ViewCompat.getY(mHeader.mPagerSlidingTabStrip) + scrollTop;
log("" + scrollTop);
//mHeader.mPagerSlidingTabStrip.setTranslationY(mHeader.getToolbar().getBottom()-mHeader.mPagerSlidingTabStrip.getY());
if (scrollTop <= 0) {
ViewCompat.setTranslationY(mHeader.mPagerSlidingTabStrip, scrollTop);
ViewCompat.setTranslationY(mHeader.toolbarLayoutBackground, scrollTop);
//when
if (ViewCompat.getY(mHeader.mPagerSlidingTabStrip) < mHeader.getToolbar().getBottom()) {
float ty = mHeader.getToolbar().getBottom() - mHeader.mPagerSlidingTabStrip.getTop();
ViewCompat.setTranslationY(mHeader.mPagerSlidingTabStrip, ty);
ViewCompat.setTranslationY(mHeader.toolbarLayoutBackground, ty);
}
}
}
if (mHeader.mLogo != null) { //move the header logo to toolbar
if (this.settings.hideLogoWithFade) {
ViewCompat.setAlpha(mHeader.mLogo, 1 - percent);
ViewCompat.setTranslationY(mHeader.mLogo, (mHeader.finalTitleY - mHeader.originalTitleY) * percent);
} else {
ViewCompat.setTranslationY(mHeader.mLogo, (mHeader.finalTitleY - mHeader.originalTitleY) * percent);
ViewCompat.setTranslationX(mHeader.mLogo, (mHeader.finalTitleX - mHeader.originalTitleX) * percent);
float scale = (1 - percent) * (1 - mHeader.finalScale) + mHeader.finalScale;
setScale(scale, mHeader.mLogo);
}
}
if (this.settings.hideToolbarAndTitle && mHeader.toolbarLayout != null) {
boolean scrollUp = lastYOffset < yOffset;
if (scrollUp) {
scrollUp(yOffset);
} else {
scrollDown(yOffset);
}
}
}
if (headerAnimator != null && percent < 1) {
cancelHeaderAnimator();
}
lastYOffset = yOffset;
return true;
}
/**
* Change the color of the statusbackground, toolbar, toolbarlayout and pagertitlestrip
* With a color transition animation
*
* @param color the final color
* @param duration the transition color animation duration
*/
void setColor(int color, int duration) {
final ValueAnimator colorAnim = ObjectAnimator.ofInt(mHeader.headerBackground, "backgroundColor", settings.color, color);
colorAnim.setEvaluator(new ArgbEvaluator());
colorAnim.setDuration(duration);
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final int animatedValue = (Integer) animation.getAnimatedValue();
int colorAlpha = colorWithAlpha(animatedValue, lastPercent);
mHeader.headerBackground.setBackgroundColor(colorAlpha);
mHeader.statusBackground.setBackgroundColor(colorAlpha);
mHeader.toolbar.setBackgroundColor(colorAlpha);
mHeader.toolbarLayoutBackground.setBackgroundColor(colorAlpha);
mHeader.mPagerSlidingTabStrip.setBackgroundColor(colorAlpha);
//set the new color as MaterialViewPager's color
settings.color = animatedValue;
}
});
colorAnim.start();
}
public void animateColorPercent(float percent, int duration) {
final ValueAnimator valueAnimator = ValueAnimator.ofFloat(lastPercent, percent);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
setColorPercent((float) animation.getAnimatedValue());
}
});
valueAnimator.setDuration(duration);
valueAnimator.start();
}
public void setColorPercent(float percent) {
// change color of
// toolbar & viewpager indicator & statusBaground
setBackgroundColor(
colorWithAlpha(this.settings.color, percent),
mHeader.statusBackground
);
if (percent >= 1) {
setBackgroundColor(
colorWithAlpha(this.settings.color, percent),
mHeader.toolbar,
mHeader.toolbarLayoutBackground,
mHeader.mPagerSlidingTabStrip
);
} else {
setBackgroundColor(
colorWithAlpha(this.settings.color, 0),
mHeader.toolbar,
mHeader.toolbarLayoutBackground,
mHeader.mPagerSlidingTabStrip
);
}
if (this.settings.enableToolbarElevation && toolbarJoinsTabs()) {
setElevation(
(percent == 1) ? elevation : 0,
mHeader.toolbar,
mHeader.toolbarLayoutBackground,
mHeader.mPagerSlidingTabStrip,
mHeader.mLogo
);
}
}
public int getHeaderHeight() {
return this.settings.headerHeight;
}
/**
* Register a RecyclerView to the current MaterialViewPagerAnimator
* Listen to RecyclerView.OnScrollListener so give to $[onScrollListener] your RecyclerView.OnScrollListener if you already use one
* For loadmore or anything else
*
* @param recyclerView the scrollable
*/
void registerRecyclerView(final RecyclerView recyclerView) {
if (recyclerView != null && !scrollViewList.contains(recyclerView)) {
scrollViewList.add(recyclerView); //add to the scrollable list
yOffsets.put(recyclerView, recyclerView.getScrollY()); //save the initial recyclerview's yOffset (0) into hashmap
//only necessary for recyclerview
//listen to scroll
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
boolean firstZeroPassed;
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int yOffset = yOffsets.get(recyclerView);
if(yOffset < 0) {
yOffset = 0;
}
yOffset += dy;
yOffsets.put(recyclerView, yOffset); //save the new offset
//first time you get 0, don't share it to others scrolls
if (yOffset == 0 && !firstZeroPassed) {
firstZeroPassed = true;
return;
}
//only if yOffset changed
if (isNewYOffset(yOffset)) {
onMaterialScrolled(recyclerView, yOffset);
}
}
});
recyclerView.post(new Runnable() {
@Override
public void run() {
setScrollOffset(recyclerView, lastYOffset);
}
});
}
}
/**
* Register a ScrollView to the current MaterialViewPagerAnimator
* Listen to ObservableScrollViewCallbacks so give to $[observableScrollViewCallbacks] your ObservableScrollViewCallbacks if you already use one
* For loadmore or anything else
*
* @param scrollView the scrollable
*/
void registerScrollView(final NestedScrollView scrollView) {
if (scrollView != null) {
scrollViewList.add(scrollView); //add to the scrollable list
scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
boolean firstZeroPassed;
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
//first time you get 0, don't share it to others scrolls
if (scrollY == 0 && !firstZeroPassed) {
firstZeroPassed = true;
return;
}
//only if yOffset changed
if (isNewYOffset(scrollY)) {
onMaterialScrolled(scrollView, scrollY);
}
}
});
scrollView.post(new Runnable() {
@Override
public void run() {
setScrollOffset(scrollView, lastYOffset);
}
});
}
}
void restoreScroll(final float scroll, final MaterialViewPagerSettings settings) {
//try to scroll up, on a looper to wait until restored
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
if (!onMaterialScrolled(null, scroll)) {
restoreScroll(scroll, settings);
}
}
}, 100);
}
void onViewPagerPageChanged() {
scrollDown(lastYOffset);
View visibleView = getTheVisibileView(scrollViewList);
if (!canScroll(visibleView)) {
followScrollToolbarLayout(0);
onMaterialScrolled(visibleView, 0);
}
}
/**
* When notified for scroll, dispatch it to all registered scrollables
*
* @param source
* @param yOffset
*/
private void dispatchScrollOffset(Object source, float yOffset) {
if (scrollViewList != null) {
for (Object scroll : scrollViewList) {
//do not re-scroll the source
if (scroll != null && scroll != source) {
setScrollOffset(scroll, yOffset);
}
}
}
}
private boolean isNewYOffset(int yOffset) {
if (lastYOffset == -1) {
return true;
} else {
return yOffset != lastYOffset;
}
}
/**
* When notified for scroll, dispatch it to all registered scrollables
*
* @param scroll
* @param yOffset
*/
private void setScrollOffset(Object scroll, float yOffset) {
//do not re-scroll the source
if (scroll != null && yOffset >= 0) {
scrollTo(scroll, yOffset);
//save the current yOffset of the scrollable on the yOffsets hashmap
yOffsets.put(scroll, (int) yOffset);
}
}
private void cancelHeaderAnimator() {
if (headerAnimator != null) {
headerAnimator.cancel();
headerAnimator = null;
}
}
//region register scrollables
private void scrollUp(float yOffset) {
log("scrollUp");
followScrollToolbarLayout(yOffset);
}
private void log(String scrollUp) {
if (ENABLE_LOG) {
Log.d(TAG, scrollUp);
}
}
private void scrollDown(float yOffset) {
log("scrollDown");
if (yOffset > mHeader.toolbarLayout.getHeight() * 1.5f) {
animateEnterToolbarLayout(yOffset);
} else {
if (headerAnimator != null) {
followScrollToolbarIsVisible = true;
} else {
followScrollToolbarLayout(yOffset);
}
}
}
private boolean toolbarJoinsTabs() {
return (mHeader.toolbar.getBottom() == mHeader.mPagerSlidingTabStrip.getTop() + ViewCompat.getTranslationY(mHeader.mPagerSlidingTabStrip));
}
//endregion
/**
* move the toolbarlayout (containing toolbar & tabs)
* following the current scroll
*/
private void followScrollToolbarLayout(float yOffset) {
if (mHeader.toolbar.getBottom() == 0) {
return;
}
if (toolbarJoinsTabs()) {
if (firstScrollValue == Float.MIN_VALUE) {
firstScrollValue = yOffset;
}
float translationY = firstScrollValue - yOffset;
if (translationY > 0) {
translationY = 0;
}
log("translationY " + translationY);
ViewCompat.setTranslationY(mHeader.toolbarLayout, translationY);
} else {
ViewCompat.setTranslationY(mHeader.toolbarLayout, 0);
justToolbarAnimated = false;
}
followScrollToolbarIsVisible = (ViewCompat.getY(mHeader.toolbarLayout) >= 0);
}
/**
* Animate enter toolbarlayout
*
* @param yOffset
*/
private void animateEnterToolbarLayout(float yOffset) {
if (!followScrollToolbarIsVisible && headerAnimator != null) {
headerAnimator.cancel();
headerAnimator = null;
}
if (headerAnimator == null) {
headerAnimator = ObjectAnimator.ofFloat(mHeader.toolbarLayout, View.TRANSLATION_Y, 0);
headerAnimator.setDuration(ENTER_TOOLBAR_ANIMATION_DURATION);
headerAnimator.addListener(new android.animation.AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(android.animation.Animator animation) {
super.onAnimationEnd(animation);
followScrollToolbarIsVisible = true;
firstScrollValue = Float.MIN_VALUE;
justToolbarAnimated = true;
}
});
headerAnimator.start();
}
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java
================================================
package com.github.florent37.materialviewpager;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewTreeObserver;
import android.support.v4.view.ViewCompat;
import static com.github.florent37.materialviewpager.Utils.dpToPx;
/**
* Created by florentchampigny on 25/04/15.
* A class containing references to views inside MaterialViewPager's header
*/
public class MaterialViewPagerHeader {
protected Context context;
protected View toolbarLayout;
protected Toolbar toolbar;
protected View mPagerSlidingTabStrip;
protected View toolbarLayoutBackground;
protected View headerBackground;
protected View statusBackground;
protected View mLogo;
//positions used to animate views during scroll
public float finalTabsY;
public float finalTitleY;
public float finalTitleHeight;
public float finalTitleX;
public float originalTitleY;
public float originalTitleHeight;
public float originalTitleX;
public float finalScale;
private MaterialViewPagerHeader(Toolbar toolbar) {
this.toolbar = toolbar;
this.context = toolbar.getContext();
this.toolbarLayout = (View) toolbar.getParent();
}
public static MaterialViewPagerHeader withToolbar(Toolbar toolbar) {
return new MaterialViewPagerHeader(toolbar);
}
public Context getContext() {
return context;
}
public MaterialViewPagerHeader withPagerSlidingTabStrip(View pagerSlidingTabStrip) {
this.mPagerSlidingTabStrip = pagerSlidingTabStrip;
mPagerSlidingTabStrip.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
finalTabsY = dpToPx(-2, context);
mPagerSlidingTabStrip.getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
});
return this;
}
public MaterialViewPagerHeader withHeaderBackground(View headerBackground) {
this.headerBackground = headerBackground;
return this;
}
public MaterialViewPagerHeader withStatusBackground(View statusBackground) {
this.statusBackground = statusBackground;
return this;
}
public MaterialViewPagerHeader withToolbarLayoutBackground(View toolbarLayoutBackground) {
this.toolbarLayoutBackground = toolbarLayoutBackground;
return this;
}
public int getStatusBarHeight(Context context) {
int result = 0;
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
public MaterialViewPagerHeader withLogo(View logo) {
this.mLogo = logo;
//when logo get a height, initialise initial & final logo positions
toolbarLayout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
//rotation fix, if not set, originalTitleY = Na
ViewCompat.setTranslationY(mLogo,0);
ViewCompat.setTranslationX(mLogo, 0);
originalTitleY = ViewCompat.getY(mLogo);
originalTitleX = ViewCompat.getX(mLogo);
originalTitleHeight = mLogo.getHeight();
finalTitleHeight = dpToPx(21, context);
//the final scale of the logo
finalScale = finalTitleHeight / originalTitleHeight;
finalTitleY = (toolbar.getPaddingTop() + toolbar.getHeight()) / 2 - finalTitleHeight / 2 - (1 - finalScale) * finalTitleHeight;
//(mLogo.getWidth()/2) *(1-finalScale) is the margin left added by the scale() on the logo
//when logo scaledown, the content stay in center, so we have to anually remove the left padding
finalTitleX = dpToPx(52f, context) - (mLogo.getWidth() / 2) * (1 - finalScale);
toolbarLayout.getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
});
return this;
}
public Toolbar getToolbar() {
return toolbar;
}
public View getHeaderBackground() {
return headerBackground;
}
public View getStatusBackground() {
return statusBackground;
}
public View getLogo() {
return mLogo;
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeaderView.java
================================================
package com.github.florent37.materialviewpager;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
/**
* Created by florentchampigny on 26/04/15.
* A placeholder view used to add a transparent padding on top of a Scroller
* RecyclerView : use RecyclerViewMaterialAdapter
* ListView : use ListViewMaterialAdapter (smoother if use RecyclerView)
* ScrollView : add a MaterialViewPagerHeaderView on top of your ScrollView (with LinearLayout vertical)
*/
public class MaterialViewPagerHeaderView extends View {
public MaterialViewPagerHeaderView(Context context) {
super(context);
}
public MaterialViewPagerHeaderView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MaterialViewPagerHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public MaterialViewPagerHeaderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
private void setMaterialHeight() {
//get the MaterialViewPagerAnimator attached to this activity
//to retrieve the declared header height
//and set it as current view height (+10dp margin)
MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(getContext());
if (animator != null) {
ViewGroup.LayoutParams params = getLayoutParams();
params.height = Math.round(Utils.dpToPx(animator.getHeaderHeight() + 10, getContext()));
super.setLayoutParams(params);
}
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
if (!isInEditMode()) {
getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
setMaterialHeight();
getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
});
}
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java
================================================
package com.github.florent37.materialviewpager;
import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.RecyclerView;
import java.util.concurrent.ConcurrentHashMap;
/**
* Created by florentchampigny on 25/04/15.
* <p/>
* MaterialViewPagerHelper attach a MaterialViewPagerAnimator to an activity
* You can use MaterialViewPagerHelper to retrieve MaterialViewPagerAnimator from context
* Or register a scrollable to the current activity's MaterialViewPagerAnimator
*/
public class MaterialViewPagerHelper {
private static ConcurrentHashMap<Object, MaterialViewPagerAnimator> hashMap = new ConcurrentHashMap<>();
/**
* Register an MaterialViewPagerAnimator attached to an activity into the ConcurrentHashMap
*
* @param context the context
* @param animator the current MaterialViewPagerAnimator
*/
static void register(Context context, MaterialViewPagerAnimator animator) {
hashMap.put(context, animator);
}
static void unregister(Context context) {
if (context != null) {
hashMap.remove(context);
}
}
/**
* Register a RecyclerView to the current MaterialViewPagerAnimator
* Listen to RecyclerView.OnScrollListener so give to $[onScrollListener] your RecyclerView.OnScrollListener if you already use one
* For loadmore or anything else
*
* @param context current context
* @param recyclerView the scrollable
*/
public static void registerRecyclerView(Context context, RecyclerView recyclerView) {
if (context != null && hashMap.containsKey(context)) {
final MaterialViewPagerAnimator animator = hashMap.get(context);
if (animator != null) {
animator.registerRecyclerView(recyclerView);
}
}
}
/**
* Register a ScrollView to the current MaterialViewPagerAnimator
* Listen to ObservableScrollViewCallbacks so give to $[observableScrollViewCallbacks] your ObservableScrollViewCallbacks if you already use one
* For loadmore or anything else
*
* @param context current context
* @param mScrollView the scrollable
*/
public static void registerScrollView(Context context, NestedScrollView mScrollView) {
if (context != null && hashMap.containsKey(context)) {
final MaterialViewPagerAnimator animator = hashMap.get(context);
if (animator != null) {
animator.registerScrollView(mScrollView);
}
}
}
/**
* Retrieve the current MaterialViewPagerAnimator used in this context (Activity)
*
* @param context the context
* @return current MaterialViewPagerAnimator
*/
public static MaterialViewPagerAnimator getAnimator(Context context) {
return hashMap.get(context);
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java
================================================
package com.github.florent37.materialviewpager;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import static com.github.florent37.materialviewpager.Utils.pxToDp;
/**
* Created by florentchampigny on 29/04/15.
* <p/>
* Save attributes given to MaterialViewPager from layout
*/
public class MaterialViewPagerSettings implements Parcelable {
//attributes are protected and can be used by class from the same package
//com.github.florent37.materialviewpager
public static final Parcelable.Creator<MaterialViewPagerSettings> CREATOR = new Parcelable.Creator<MaterialViewPagerSettings>() {
public MaterialViewPagerSettings createFromParcel(Parcel source) {
return new MaterialViewPagerSettings(source);
}
public MaterialViewPagerSettings[] newArray(int size) {
return new MaterialViewPagerSettings[size];
}
};
int headerLayoutId;
int pagerTitleStripId;
int viewpagerId;
int logoLayoutId;
int logoMarginTop;
int headerAdditionalHeight;
int headerHeight;
int headerHeightPx;
int color;
float headerAlpha;
float parallaxHeaderFactor;
float imageHeaderDarkLayerAlpha;
boolean hideToolbarAndTitle;
boolean hideLogoWithFade;
boolean enableToolbarElevation;
boolean displayToolbarWhenSwipe;
boolean toolbarTransparent;
boolean animatedHeaderImage;
boolean disableToolbar;
//region parcelable
public MaterialViewPagerSettings() {
}
private MaterialViewPagerSettings(Parcel in) {
this.headerLayoutId = in.readInt();
this.pagerTitleStripId = in.readInt();
this.viewpagerId = in.readInt();
this.logoLayoutId = in.readInt();
this.logoMarginTop = in.readInt();
this.headerAdditionalHeight = in.readInt();
this.headerHeight = in.readInt();
this.headerHeightPx = in.readInt();
this.color = in.readInt();
this.headerAlpha = in.readFloat();
this.imageHeaderDarkLayerAlpha = in.readFloat();
this.parallaxHeaderFactor = in.readFloat();
this.hideToolbarAndTitle = in.readByte() != 0;
this.hideLogoWithFade = in.readByte() != 0;
this.enableToolbarElevation = in.readByte() != 0;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.headerLayoutId);
dest.writeInt(this.pagerTitleStripId);
dest.writeInt(this.viewpagerId);
dest.writeInt(this.logoLayoutId);
dest.writeInt(this.logoMarginTop);
dest.writeInt(this.headerAdditionalHeight);
dest.writeInt(this.headerHeight);
dest.writeInt(this.headerHeightPx);
dest.writeInt(this.color);
dest.writeFloat(this.headerAlpha);
dest.writeFloat(this.imageHeaderDarkLayerAlpha);
dest.writeFloat(this.parallaxHeaderFactor);
dest.writeByte(hideToolbarAndTitle ? (byte) 1 : (byte) 0);
dest.writeByte(hideLogoWithFade ? (byte) 1 : (byte) 0);
dest.writeByte(enableToolbarElevation ? (byte) 1 : (byte) 0);
}
/**
* Retrieve attributes from the MaterialViewPager
*
* @param context
* @param attrs
*/
void handleAttributes(Context context, AttributeSet attrs) {
try {
TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.MaterialViewPager);
{
headerLayoutId = styledAttrs.getResourceId(R.styleable.MaterialViewPager_viewpager_header, -1);
}
{
pagerTitleStripId = styledAttrs.getResourceId(R.styleable.MaterialViewPager_viewpager_pagerTitleStrip, -1);
if (pagerTitleStripId == -1) {
pagerTitleStripId = R.layout.material_view_pager_pagertitlestrip_standard;
}
}
{
viewpagerId = styledAttrs.getResourceId(R.styleable.MaterialViewPager_viewpager_viewpager, -1);
}
{
logoLayoutId = styledAttrs.getResourceId(R.styleable.MaterialViewPager_viewpager_logo, -1);
logoMarginTop = styledAttrs.getDimensionPixelSize(R.styleable.MaterialViewPager_viewpager_logoMarginTop, 0);
}
{
color = styledAttrs.getColor(R.styleable.MaterialViewPager_viewpager_color, 0);
}
{
headerHeightPx = styledAttrs.getDimensionPixelOffset(R.styleable.MaterialViewPager_viewpager_headerHeight, 200);
headerHeight = Math.round(pxToDp(headerHeightPx, context)); //convert to dp
}
{
headerAdditionalHeight = styledAttrs.getDimensionPixelOffset(R.styleable.MaterialViewPager_viewpager_headerAdditionalHeight, 60);
}
{
headerAlpha = styledAttrs.getFloat(R.styleable.MaterialViewPager_viewpager_headerAlpha, 0.5f);
}
{
imageHeaderDarkLayerAlpha = styledAttrs.getFloat(R.styleable.MaterialViewPager_viewpager_imageHeaderDarkLayerAlpha, 0.0f);
}
{
parallaxHeaderFactor = styledAttrs.getFloat(R.styleable.MaterialViewPager_viewpager_parallaxHeaderFactor, 1.5f);
parallaxHeaderFactor = Math.max(parallaxHeaderFactor, 1); //min=1
}
{
hideToolbarAndTitle = styledAttrs.getBoolean(R.styleable.MaterialViewPager_viewpager_hideToolbarAndTitle, false);
hideLogoWithFade = styledAttrs.getBoolean(R.styleable.MaterialViewPager_viewpager_hideLogoWithFade, false);
}
{
enableToolbarElevation = styledAttrs.getBoolean(R.styleable.MaterialViewPager_viewpager_enableToolbarElevation, false);
}
{
displayToolbarWhenSwipe = styledAttrs.getBoolean(R.styleable.MaterialViewPager_viewpager_displayToolbarWhenSwipe, false);
}
{
toolbarTransparent = styledAttrs.getBoolean(R.styleable.MaterialViewPager_viewpager_transparentToolbar, false);
}
{
animatedHeaderImage = styledAttrs.getBoolean(R.styleable.MaterialViewPager_viewpager_animatedHeaderImage, true);
}
{
disableToolbar = styledAttrs.getBoolean(R.styleable.MaterialViewPager_viewpager_disableToolbar, false);
}
styledAttrs.recycle();
} catch (Exception e) {
e.printStackTrace();
}
}
//endregion
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/Utils.java
================================================
package com.github.florent37.materialviewpager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.webkit.WebView;
import android.widget.ListView;
import android.widget.ScrollView;
import android.support.v4.view.ViewCompat;
import java.util.List;
/**
* Created by florentchampigny on 24/04/15.
*/
public class Utils {
/**
* convert dp to px
*/
public static float dpToPx(float dp, Context context) {
return dp * context.getResources().getDisplayMetrics().density;
}
/**
* convert px to dp
*/
static float pxToDp(float px, Context context) {
return px / context.getResources().getDisplayMetrics().density;
}
/*
* Create a color from [$color].RGB and then add an alpha with 255*[$percent]
*/
static int colorWithAlpha(int color, float percent) {
int r = Color.red(color);
int g = Color.green(color);
int b = Color.blue(color);
int alpha = Math.round(percent * 255);
return Color.argb(alpha, r, g, b);
}
static float minMax(float min, float value, float max) {
value = Math.min(value, max);
value = Math.max(min, value);
return value;
}
/**
* modify the scale of multiples views
*
* @param scale the new scale
* @param views
*/
static void setScale(float scale, View... views) {
for (View view : views) {
if (view != null) {
ViewCompat.setScaleX(view, scale);
ViewCompat.setScaleY(view, scale);
}
}
}
/**
* modify the elevation of multiples views
*
* @param elevation the new elevation
* @param views
*/
static void setElevation(float elevation, View... views) {
for (View view : views) {
if (view != null) {
ViewCompat.setElevation(view, elevation);
}
}
}
/**
* modify the backgroundcolor of multiples views
*
* @param color the new backgroundcolor
* @param views
*/
static void setBackgroundColor(int color, View... views) {
for (View view : views) {
if (view != null) {
view.setBackgroundColor(color);
}
}
}
static boolean canScroll(View view) {
if (view instanceof ScrollView) {
ScrollView scrollView = (ScrollView) view;
View child = scrollView.getChildAt(0);
if (child != null) {
int childHeight = child.getHeight();
return scrollView.getHeight() < childHeight + scrollView.getPaddingTop() + scrollView.getPaddingBottom();
}
return false;
} else if (view instanceof RecyclerView) {
RecyclerView recyclerView = (RecyclerView) view;
int yOffset = recyclerView.computeVerticalScrollOffset();
return yOffset != 0;
}
return true;
}
public static void scrollTo(Object scroll, float yOffset) {
if (scroll instanceof RecyclerView) {
//RecyclerView.scrollTo : UnsupportedOperationException
//Moved to the RecyclerView.LayoutManager.scrollToPositionWithOffset
//Have to be instanceOf RecyclerView.LayoutManager to work (so work with RecyclerView.GridLayoutManager)
final RecyclerView.LayoutManager layoutManager = ((RecyclerView) scroll).getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
linearLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
staggeredGridLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
}
} else if (scroll instanceof NestedScrollView) {
((NestedScrollView) scroll).scrollTo(0, (int) yOffset);
}
}
static View getTheVisibileView(List<View> viewList) {
Rect scrollBounds = new Rect();
int listSize = viewList.size();
for (int i = 0; i < listSize; ++i) {
View view = viewList.get(i);
if (view != null) {
view.getHitRect(scrollBounds);
if (view.getLocalVisibleRect(scrollBounds)) {
return view;
}
}
}
return null;
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/HeaderDesign.java
================================================
package com.github.florent37.materialviewpager.header;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
/**
* Created by florentchampigny on 10/06/15.
*/
public class HeaderDesign {
protected int color;
protected int colorRes;
protected String imageUrl;
protected Drawable drawable;
private HeaderDesign() {
}
public static HeaderDesign fromColorAndUrl(@ColorInt int color, String imageUrl) {
HeaderDesign headerDesign = new HeaderDesign();
headerDesign.color = color;
headerDesign.imageUrl = imageUrl;
return headerDesign;
}
public static HeaderDesign fromColorResAndUrl(@ColorRes int colorRes, String imageUrl) {
HeaderDesign headerDesign = new HeaderDesign();
headerDesign.colorRes = colorRes;
headerDesign.imageUrl = imageUrl;
return headerDesign;
}
public static HeaderDesign fromColorAndDrawable(@ColorInt int color, Drawable drawable) {
HeaderDesign headerDesign = new HeaderDesign();
headerDesign.drawable = drawable;
headerDesign.color = color;
return headerDesign;
}
public static HeaderDesign fromColorResAndDrawable(@ColorRes int colorRes, Drawable drawable) {
HeaderDesign headerDesign = new HeaderDesign();
headerDesign.colorRes = colorRes;
headerDesign.drawable = drawable;
return headerDesign;
}
public int getColor() {
return color;
}
public int getColorRes() {
return colorRes;
}
public String getImageUrl() {
return imageUrl;
}
public Drawable getDrawable() {
return drawable;
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerHeaderDecorator.java
================================================
package com.github.florent37.materialviewpager.header;
import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import com.github.florent37.materialviewpager.MaterialViewPagerAnimator;
import com.github.florent37.materialviewpager.MaterialViewPagerHelper;
import com.github.florent37.materialviewpager.Utils;
/**
* Created by florentchampigny on 27/05/2016.
*/
public class MaterialViewPagerHeaderDecorator extends RecyclerView.ItemDecoration {
boolean registered = false;
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView recyclerView, RecyclerView.State state) {
final RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
final Context context = recyclerView.getContext();
if(!registered) {
MaterialViewPagerHelper.registerRecyclerView(context, recyclerView);
registered = true;
}
int headerCells = 1;
//don't work with stagged
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if(layoutManager instanceof GridLayoutManager){
GridLayoutManager gridLayoutManager = (GridLayoutManager)layoutManager;
headerCells = gridLayoutManager.getSpanCount();
}
MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(context);
if (animator != null) {
if (holder.getAdapterPosition() < headerCells) {
outRect.top = Math.round(Utils.dpToPx(animator.getHeaderHeight() + 10, context));
}
}
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHeader.java
================================================
package com.github.florent37.materialviewpager.header;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import com.flaviofaria.kenburnsview.KenBurnsView;
/**
* Created by florentchampigny on 29/04/15.
* The MaterialViewPager animated Header
* Using com.flaviofaria.kenburnsview.KenBurnsView
* https://github.com/flavioarfaria/KenBurnsView
*/
public class MaterialViewPagerImageHeader extends KenBurnsView {
//region construct
public MaterialViewPagerImageHeader(Context context) {
super(context);
}
public MaterialViewPagerImageHeader(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MaterialViewPagerImageHeader(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
//endregion
/**
* change the image with a fade
*
* @param urlImage
* @param fadeDuration TODO : remove Picasso
*/
public void setImageUrl(final String urlImage, final int fadeDuration) {
MaterialViewPagerImageHelper.setImageUrl(this, urlImage, fadeDuration);
}
/**
* change the image with a fade
*
* @param drawable
* @param fadeDuration
*/
public void setImageDrawable(final Drawable drawable, final int fadeDuration) {
MaterialViewPagerImageHelper.setImageDrawable(this, drawable, fadeDuration);
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java
================================================
package com.github.florent37.materialviewpager.header;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorListenerAdapter;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.github.florent37.materialviewpager.MaterialViewPager;
import android.os.Handler;
/**
* Created by florentchampigny on 12/06/15.
*/
public class MaterialViewPagerImageHelper {
private static MaterialViewPager.OnImageLoadListener imageLoadListener;
/**
* change the image with a fade
*
* @param urlImage
* @param fadeDuration TODO : remove Picasso
*/
public static void setImageUrl(final ImageView imageView, final String urlImage, final int fadeDuration) {
final float alpha = ViewCompat.getAlpha(imageView);
final ImageView viewToAnimate = imageView;
//fade to alpha=0
fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
super.onAnimationEnd(view);
//change the image when alpha=0
Glide.with(imageView.getContext()).load(urlImage)
.apply(new RequestOptions().centerCrop())
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
//then fade to alpha=1
new Handler(Looper.getMainLooper()) {}.post(new Runnable(){
@Override
public void run(){
fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
if (imageLoadListener != null) {
imageLoadListener.OnImageLoad(imageView, ((BitmapDrawable) imageView.getDrawable()).getBitmap());
}
}
});
return false;
}
})
.into(viewToAnimate);
}
});
}
public static void fadeOut(View view, int fadeDuration, ViewPropertyAnimatorListenerAdapter listener) {
//fade to alpha=0
ViewCompat.animate(view)
.alpha(0)
.setDuration(fadeDuration)
.withLayer()
.setInterpolator(new DecelerateInterpolator())
.setListener(listener);
}
public static void fadeIn(View view, float alpha, int fadeDuration, ViewPropertyAnimatorListenerAdapter listener) {
//fade to alpha=0
ViewCompat.animate(view)
.alpha(alpha)
.setDuration(fadeDuration)
.withLayer()
.setInterpolator(new AccelerateInterpolator())
.setListener(listener);
}
/**
* change the image with a fade
*
* @param drawable
* @param fadeDuration
*/
public static void setImageDrawable(final ImageView imageView, final Drawable drawable, final int fadeDuration) {
final float alpha = ViewCompat.getAlpha(imageView);
final ImageView viewToAnimate = imageView;
fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
super.onAnimationEnd(view);
//change the image when alpha=0
imageView.setImageDrawable(drawable);
//then fade to alpha=1
fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
}
});
}
public static void setImageLoadListener(MaterialViewPager.OnImageLoadListener imageLoadListener) {
MaterialViewPagerImageHelper.imageLoadListener = imageLoadListener;
}
}
================================================
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerKenBurnsHeader.java
================================================
package com.github.florent37.materialviewpager.header;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import com.flaviofaria.kenburnsview.KenBurnsView;
/**
* Created by florentchampigny on 29/04/15.
* The MaterialViewPager animated Header
* Using com.flaviofaria.kenburnsview.KenBurnsView
* https://github.com/flavioarfaria/KenBurnsView
*/
public class MaterialViewPagerKenBurnsHeader extends KenBurnsView {
//region construct
public MaterialViewPagerKenBurnsHeader(Context context) {
super(context);
}
public MaterialViewPagerKenBurnsHeader(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MaterialViewPagerKenBurnsHeader(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
//endregion
/**
* change the image with a fade
*
* @param urlImage
* @param fadeDuration TODO : remove Picasso
*/
public void setImageUrl(final String urlImage, final int fadeDuration) {
MaterialViewPagerImageHelper.setImageUrl(this, urlImage, fadeDuration);
}
/**
* change the image with a fade
*
* @param drawable
* @param fadeDuration
*/
public void setImageDrawable(final Drawable drawable, final int fadeDuration) {
MaterialViewPagerImageHelper.setImageDrawable(this, drawable, fadeDuration);
}
}
================================================
FILE: materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@id/materialviewpager_imageHeader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<View
android:id="@id/materialviewpager_headerImageDarkLayer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
================================================
FILE: materialviewpager/src/main/res/layout/material_view_pager_layout.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical">
<FrameLayout
android:id="@+id/headerBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:background="@color/colorPrimary"
tools:layout_height="250dp">
<FrameLayout
android:id="@+id/headerBackgroundContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<View
android:id="@+id/statusBackground"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<FrameLayout
android:id="@+id/viewpager_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/material_view_pager_viewpager"/>
</FrameLayout>
<RelativeLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/toolbar_layout_background"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
android:theme="@style/MVP_AppTheme.ActionBarTheme"
app:navigationIcon="?attr/homeAsUpIndicator"
tools:background="#3FFF" />
<FrameLayout
android:id="@+id/pagerTitleStripContainer"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="160dp"
android:fitsSystemWindows="true"
tools:background="#3FFF" />
<FrameLayout
android:id="@+id/logoContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</RelativeLayout>
================================================
FILE: materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.florent37.materialviewpager.header.MaterialViewPagerImageHeader
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/materialviewpager_imageHeader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<View
android:id="@id/materialviewpager_headerImageDarkLayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"/>
</FrameLayout>
================================================
FILE: materialviewpager/src/main/res/layout/material_view_pager_pagertitlestrip_newstand.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<com.astuetz.PagerSlidingTabStrip
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@id/materialviewpager_pagerTitleStrip"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:pstsPaddingMiddle="true"
app:pstsDividerPadding="20dp"
app:pstsIndicatorColor="#FFF"
app:pstsIndicatorHeight="2dp"
app:pstsShouldExpand="true"
app:pstsTabPaddingLeftRight="10dp"
app:pstsTabTextAllCaps="true"
tools:background="#A333"
/>
================================================
FILE: materialviewpager/src/main/res/layout/material_view_pager_pagertitlestrip_standard.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<com.astuetz.PagerSlidingTabStrip
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@id/materialviewpager_pagerTitleStrip"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:pstsDividerPadding="20dp"
app:pstsIndicatorColor="#FFF"
app:pstsIndicatorHeight="4dp"
app:pstsShouldExpand="true"
app:pstsTabPaddingLeftRight="10dp"
app:pstsTabTextAllCaps="true"
tools:background="#A333"
/>
================================================
FILE: materialviewpager/src/main/res/layout/material_view_pager_placeholder.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<com.github.florent37.materialviewpager.MaterialViewPagerHeaderView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp" />
================================================
FILE: materialviewpager/src/main/res/layout/material_view_pager_viewpager.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
android:id="@id/materialviewpager_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" />
================================================
FILE: materialviewpager/src/main/res/layout/tools_list_item_card_big.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@android:color/white"
android:layout_marginBottom="@dimen/cardMarginVertical"
android:layout_marginLeft="@dimen/cardMarginHorizontal"
android:layout_marginRight="@dimen/cardMarginHorizontal"
android:layout_marginTop="@dimen/cardMarginVertical"
android:elevation="2dp" />
</FrameLayout>
================================================
FILE: materialviewpager/src/main/res/layout/tools_list_item_card_small.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="80dp"
android:elevation="2dp"
android:background="@android:color/white"
android:layout_marginBottom="@dimen/cardMarginVertical"
android:layout_marginLeft="@dimen/cardMarginHorizontal"
android:layout_marginRight="@dimen/cardMarginHorizontal"
android:layout_marginTop="@dimen/cardMarginVertical"
/>
</FrameLayout>
================================================
FILE: materialviewpager/src/main/res/layout/tools_list_items.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/tools_list_item_card_big"/>
<include layout="@layout/tools_list_item_card_small"/>
<include layout="@layout/tools_list_item_card_small"/>
<include layout="@layout/tools_list_item_card_small"/>
<include layout="@layout/tools_list_item_card_small"/>
</LinearLayout>
================================================
FILE: materialviewpager/src/main/res/layout/tools_material_view_pager_pagertitlestrip.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<FrameLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Tab 1"
android:textAllCaps="true"
android:gravity="center"
android:textColor="@android:color/white" />
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@android:color/white"
android:layout_gravity="bottom"/>
</FrameLayout>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Tab 2"
android:textAllCaps="true"
android:gravity="center"
android:textColor="@android:color/white" />
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:textAllCaps="true"
android:layout_height="match_parent"
android:text="Tab 3"
android:gravity="center"
android:textColor="@android:color/white" />
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:textAllCaps="true"
android:layout_height="match_parent"
android:text="Tab 4"
android:gravity="center"
android:textColor="@android:color/white" />
</LinearLayout>
================================================
FILE: materialviewpager/src/main/res/values/attrs.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MaterialViewPager">
<attr name="viewpager_header" format="reference"/>
<attr name="viewpager_logo" format="reference"/>
<attr name="viewpager_pagerTitleStrip" format="reference"/>
<attr name="viewpager_viewpager" format="reference"/>
<attr name="viewpager_logoMarginTop" format="dimension"/>
<attr name="viewpager_color" format="color"/>
<attr name="viewpager_headerHeight" format="dimension"/>
<attr name="viewpager_headerAlpha" format="float"/>
<attr name="viewpager_imageHeaderDarkLayerAlpha" format="float"/>
<attr name="viewpager_hideToolbarAndTitle" format="boolean"/>
<attr name="viewpager_hideLogoWithFade" format="boolean"/>
<attr name="viewpager_enableToolbarElevation" format="boolean"/>
<attr name="viewpager_parallaxHeaderFactor" format="float"/>
<attr name="viewpager_headerAdditionalHeight" format="dimension"/>
<attr name="viewpager_displayToolbarWhenSwipe" format="boolean"/>
<attr name="viewpager_transparentToolbar" format="boolean"/>
<attr name="viewpager_animatedHeaderImage" format="boolean"/>
<attr name="viewpager_disableToolbar" format="boolean"/>
</declare-styleable>
</resources>
================================================
FILE: materialviewpager/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blue">#303F9F</color>
<color name="green">#4CAF50</color>
<color name="green_teal">#009688</color>
<color name="purple">#673AB7</color>
<color name="red">#F44336</color>
<color name="cyan">#00BCD4</color>
<color name="lime">#CDDC39</color>
<color name="accent_color">@color/blue</color>
<color name="colorPrimary">@color/blue</color>
<color name="colorPrimaryDark">@color/blue</color>
<color name="statusBarColor">@color/blue</color>
<color name="navigationBarColor">@android:color/black</color>
<color name="drawerArrowColor">@android:color/white</color>
</resources>
================================================
FILE: materialviewpager/src/main/res/values/dimens.xml
================================================
<resources>
<dimen name="cardMarginHorizontal">10dp</dimen>
<dimen name="cardMarginVertical">8dp</dimen>
<dimen name="materialviewpager_logoHeight">35dp</dimen>
</resources>
================================================
FILE: materialviewpager/src/main/res/values/ids.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="materialviewpager_pagerTitleStrip" />
<item type="id" name="materialviewpager_imageHeader" />
<item type="id" name="materialviewpager_headerImageDarkLayer" />
<item type="id" name="materialviewpager_viewpager" />
</resources>
================================================
FILE: materialviewpager/src/main/res/values/styles.xml
================================================
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="MVP_AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
</style>
<!-- Base application theme. -->
<style name="MVP_AppTheme" parent="MVP_AppBaseTheme">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="drawerArrowStyle">@style/MVP_DrawerArrowStyle</item>
<item name="android:windowTranslucentStatus" tools:targetApi="19">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBar">false</item>
<!-- Toolbar Theme / Apply white arrow -->
<item name="colorControlNormal">@android:color/white</item>
<item name="actionBarTheme">@style/MVP_AppTheme.ActionBarTheme</item>
<!-- Material Theme -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/accent_color</item>
<item name="android:statusBarColor" tools:targetApi="21">@color/statusBarColor</item>
<item name="android:navigationBarColor" tools:targetApi="21">@color/navigationBarColor</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>
<style name="MVP_AppTheme.ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<!-- White arrow -->
<item name="colorControlNormal">@android:color/white</item>
</style>
<style name="MVP_DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@color/drawerArrowColor</item>
</style>
</resources>
================================================
FILE: publish.sh
================================================
./gradlew clean :materialviewpager:install :materialviewpager:bintrayUpload
================================================
FILE: sample/.gitignore
================================================
/build
material_view_pager_keystore.jks
keyInfos.properties
fabric.properties
================================================
FILE: sample/build.gradle
================================================
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion project.sdk
buildToolsVersion project.buildTools
defaultConfig {
minSdkVersion project.minSdk
targetSdkVersion project.sdk
versionCode 4
versionName "1.0"
}
File signFile = project.file('keyInfos.properties')
if (signFile.exists()) {
Properties properties = new Properties()
properties.load(new FileInputStream(signFile))
signingConfigs {
release {
storeFile file(project.file(properties['keystore.filename']))
storePassword properties['keystore.password']
keyAlias properties['keystore.alias']
keyPassword properties['keystore.password']
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
if (signFile.exists())
signingConfig signingConfigs.release
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:'+project.supportVersion
compile 'com.android.support:cardview-v7:'+project.supportVersion
compile 'com.jakewharton:butterknife:8.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
//compile ('com.github.florent37:materialviewpager:1.0.6@aar'){
// transitive=true
//}
compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
transitive = true;
}
compile project(':materialviewpager')
}
================================================
FILE: sample/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/florentchampigny/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: sample/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.florent37.materialviewpager.sample"
>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="29cbd600bb8183011201895a931db91e93f2d614" />
</application>
</manifest>
================================================
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/DrawerActivity.java
================================================
package com.github.florent37.materialviewpager.sample;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
/**
* Created by florentchampigny on 27/05/2016.
*/
public class DrawerActivity extends AppCompatActivity {
private DrawerLayout mDrawer;
private ActionBarDrawerToggle mDrawerToggle;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!BuildConfig.DEBUG) {
Fabric.with(this, new Crashlytics());
}
}
@Override
protected void onStart() {
super.onStart();
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0);
mDrawer.setDrawerListener(mDrawerToggle);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(true);
}
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mDrawerToggle.syncState();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return mDrawerToggle.onOptionsItemSelected(item) ||
super.onOptionsItemSelected(item);
}
}
================================================
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java
================================================
package com.github.florent37.materialviewpager.sample;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.crashlytics.android.Crashlytics;
import com.github.florent37.materialviewpager.MaterialViewPager;
import com.github.florent37.materialviewpager.header.HeaderDesign;
import com.github.florent37.materialviewpager.sample.fragment.RecyclerViewFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.fabric.sdk.android.Fabric;
public class MainActivity extends DrawerActivity {
@BindView(R.id.materialViewPager)
MaterialViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("");
ButterKnife.bind(this);
final Toolbar toolbar = mViewPager.getToolbar();
if (toolbar != null) {
setSupportActionBar(toolbar);
}
mViewPager.getViewPager().setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
switch (position % 4) {
//case 0:
// return RecyclerViewFragment.newInstance();
//case 1:
// return RecyclerViewFragment.newInstance();
//case 2:
// return WebViewFragment.newInstance();
default:
return RecyclerViewFragment.newInstance();
}
}
@Override
public int getCount() {
return 4;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position % 4) {
case 0:
return "Selection";
case 1:
return "Actualités";
case 2:
return "Professionnel";
case 3:
return "Divertissement";
}
return "";
}
});
mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
@Override
public HeaderDesign getHeaderDesign(int page) {
switch (page) {
case 0:
return HeaderDesign.fromColorResAndUrl(
R.color.green,
"http://phandroid.s3.amazonaws.com/wp-content/uploads/2014/06/android_google_moutain_google_now_1920x1080_wallpaper_Wallpaper-HD_2560x1600_www.paperhi.com_-640x400.jpg");
case 1:
return HeaderDesign.fromColorResAndUrl(
R.color.blue,
"http://www.hdiphonewallpapers.us/phone-wallpapers/540x960-1/540x960-mobile-wallpapers-hd-2218x5ox3.jpg");
case 2:
return HeaderDesign.fromColorResAndUrl(
R.color.cyan,
"http://www.droid-life.com/wp-content/uploads/2014/10/lollipop-wallpapers10.jpg");
case 3:
return HeaderDesign.fromColorResAndUrl(
R.color.red,
"http://www.tothemobile.com/wp-content/uploads/2014/07/original.jpg");
}
//execute others actions if needed (ex : modify your header logo)
return null;
}
});
mViewPager.getViewPager().setOffscreenPageLimit(mViewPager.getViewPager().getAdapter().getCount());
mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
final View logo = findViewById(R.id.logo_white);
if (logo != null) {
logo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.notifyHeaderChanged();
Toast.makeText(getApplicationContext(), "Yes, the title is clickable", Toast.LENGTH_SHORT).show();
}
});
}
}
}
================================================
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/TestListViewAdapter.java
================================================
package com.github.florent37.materialviewpager.sample;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import java.util.List;
/**
* Created by florentchampigny on 24/04/15.
*/
public class TestListViewAdapter extends ArrayAdapter<Object> {
static final int TYPE_HEADER = 0;
static final int TYPE_CELL = 1;
public TestListViewAdapter(Context context, List<Object> objects) {
super(context, 0, objects);
}
@Override
public int getItemViewType(int position) {
switch (position) {
case 0:
return TYPE_HEADER;
default:
return TYPE_CELL;
}
}
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
switch (getItemViewType(position)) {
case TYPE_HEADER: {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.tools_list_item_card_big, parent, false);
}
break;
case TYPE_CELL: {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.tools_list_item_card_small, parent, false);
}
break;
}
}
return convertView;
}
}
================================================
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/TestRecyclerViewAdapter.java
================================================
package com.github.florent37.materialviewpager.sample;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
/**
* Created by florentchampigny on 24/04/15.
*/
public class TestRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
List<Object> contents;
static final int TYPE_HEADER = 0;
static final int TYPE_CELL = 1;
public TestRecyclerViewAdapter(List<Object> contents) {
this.contents = contents;
}
@Override
public int getItemViewType(int position) {
switch (position) {
case 0:
return TYPE_HEADER;
default:
return TYPE_CELL;
}
}
@Override
public int getItemCount() {
return contents.size();
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
switch (viewType) {
case TYPE_HEADER: {
view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item_card_big, parent, false);
return new RecyclerView.ViewHolder(view) {
};
}
case TYPE_CELL: {
view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item_card_small, parent, false);
return new RecyclerView.ViewHolder(view) {
};
}
}
return null;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (getItemViewType(position)) {
case TYPE_HEADER:
break;
case TYPE_CELL:
break;
}
}
}
================================================
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/RecyclerViewFragment.java
================================================
package com.github.florent37.materialviewpager.sample.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator;
import com.github.florent37.materialviewpager.sample.R;
import com.github.florent37.materialviewpager.sample.TestRecyclerViewAdapter;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by florentchampigny on 24/04/15.
*/
public class RecyclerViewFragment extends Fragment {
private static final boolean GRID_LAYOUT = false;
private static final int ITEM_COUNT = 100;
@BindView(R.id.recyclerView)
RecyclerView mRecyclerView;
public static RecyclerViewFragment newInstance() {
return new RecyclerViewFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recyclerview, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
final List<Object> items = new ArrayList<>();
for (int i = 0; i < ITEM_COUNT; ++i) {
items.add(new Object());
}
//setup materialviewpager
if (GRID_LAYOUT) {
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
} else {
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
}
mRecyclerView.setHasFixedSize(true);
//Use this now
mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
mRecyclerView.setAdapter(new TestRecyclerViewAdapter(items));
}
}
================================================
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/ScrollFragment.java
================================================
package com.github.florent37.materialviewpager.sample.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.NestedScrollView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.florent37.materialviewpager.MaterialViewPagerHelper;
import com.github.florent37.materialviewpager.sample.R;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by florentchampigny on 24/04/15.
*/
public class ScrollFragment extends Fragment {
@BindView(R.id.scrollView)
NestedScrollView mScrollView;
public static ScrollFragment newInstance() {
return new ScrollFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_scroll, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
MaterialViewPagerHelper.registerScrollView(getActivity(), mScrollView);
}
}
================================================
FILE: sample/src/main/res/drawable/circle.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="#448AFF"/>
</shape>
================================================
FILE: sample/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.florent37.materialviewpager.MaterialViewPager
android:id="@+id/materialViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:viewpager_logo="@layout/header_logo"
app:viewpager_pagerTitleStrip="@layout/material_view_pager_pagertitlestrip_newstand"
app:viewpager_logoMarginTop="100dp"
app:viewpager_color="@color/colorPrimary"
app:viewpager_headerHeight="200dp"
app:viewpager_headerAlpha="1.0"
app:viewpager_imageHeaderDarkLayerAlpha="0.2"
app:viewpager_hideLogoWithFade="false"
app:viewpager_hideToolbarAndTitle="true"
app:viewpager_enableToolbarElevation="true"
app:viewpager_parallaxHeaderFactor="1.5"
app:viewpager_headerAdditionalHeight="20dp"
app:viewpager_displayToolbarWhenSwipe="true"
app:viewpager_transparentToolbar="false"
app:viewpager_animatedHeaderImage="true"
/>
<include layout="@layout/drawer" />
</android.support.v4.widget.DrawerLayout>
================================================
FILE: sample/src/main/res/layout/drawer.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/left_drawer"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
/>
================================================
FILE: sample/src/main/res/layout/fragment_list.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<com.github.ksoichiro.android.observablescrollview.ObservableListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
/>
================================================
FILE: sample/src/main/res/layout/fragment_recyclerview.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
================================================
FILE: sample/src/main/res/layout/fragment_scroll.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/material_view_pager_placeholder"/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/cardMarginVertical"
android:layout_marginLeft="@dimen/cardMarginHorizontal"
android:layout_marginRight="@dimen/cardMarginHorizontal"
android:layout_marginTop="@dimen/cardMarginVertical"
android:background="@android:color/white"
app:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1000dp"
android:orientation="vertical">
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
================================================
FILE: sample/src/main/res/layout/fragment_webview.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
>
<com.github.ksoichiro.android.observablescrollview.ObservableWebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
================================================
FILE: sample/src/main/res/layout/header_logo.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/logo_white"
android:layout_width="200dp"
android:layout_height="@dimen/materialviewpager_logoHeight"
android:src="@drawable/logo_white" />
================================================
FILE: sample/src/main/res/layout/header_logo_2.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/circle">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:fitsSystemWindows="true"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="@drawable/flying" />
</FrameLayout>
================================================
FILE: sample/src/main/res/layout/header_logo_full.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/logo_white"
android:layout_width="200dp"
android:layout_height="@dimen/materialviewpager_logoHeight"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
android:src="@android:color/white" />
================================================
FILE: sample/src/main/res/layout/header_logo_text.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/logo_white"
android:layout_width="100dp"
android:layout_height="@dimen/materialviewpager_logoHeight"
android:text="This is my logo"
android:textSize="45sp"
android:background="@android:color/white"
android:textColor="@android:color/white"/>
================================================
FILE: sample/src/main/res/layout/list_item_card_big.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="@dimen/cardMarginVertical"
android:layout_marginLeft="@dimen/cardMarginHorizontal"
android:layout_marginRight="@dimen/cardMarginHorizontal"
android:layout_marginTop="@dimen/cardMarginVertical"
app:cardCornerRadius="2dp"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:contentPadding="0dp">
</android.support.v7.widget.CardView>
</FrameLayout>
================================================
FILE: sample/src/main/res/layout/list_item_card_small.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="80dp"
app:cardCornerRadius="2dp"
app:cardElevation="2dp"
android:layout_marginBottom="@dimen/cardMarginVertical"
android:layout_marginLeft="@dimen/cardMarginHorizontal"
android:layout_marginRight="@dimen/cardMarginHorizontal"
android:layout_marginTop="@dimen/cardMarginVertical"
app:cardPreventCornerOverlap="false"
app:contentPadding="0dp"></android.support.v7.widget.CardView>
</FrameLayout>
================================================
FILE: sample/src/main/res/menu/menu_main.xml
================================================
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
</menu>
================================================
FILE: sample/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blue">#303F9F</color>
<color name="accent_color">@color/blue</color>
<color name="colorPrimary">@color/blue</color>
<color name="colorPrimaryDark">@color/blue</color>
<color name="statusBarColor">@color/blue</color>
<color name="navigationBarColor">@android:color/black</color>
<color name="drawerArrowColor">@android:color/white</color>
</resources>
================================================
FILE: sample/src/main/res/values/dimens.xml
================================================
<resources>
<dimen name="cardMarginHorizontal">10dp</dimen>
<dimen name="cardMarginVertical">8dp</dimen>
</resources>
================================================
FILE: sample/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">Material View Pager</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
</resources>
================================================
FILE: sample/src/main/res/values/styles.xml
================================================
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:windowTranslucentStatus" tools:targetApi="19">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBar">false</item>
<!-- Material Theme -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/accent_color</item>
<item name="android:statusBarColor" tools:targetApi="21">@color/statusBarColor</item>
<item name="android:navigationBarColor" tools:targetApi="21">@color/navigationBarColor</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@color/drawerArrowColor</item>
</style>
</resources>
================================================
FILE: sample/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: settings.gradle
================================================
include ':materialviewpager', ':sample'
gitextract_vckdg7ln/ ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── circle.yml ├── gradle/ │ ├── bintray-android-v1.gradle │ ├── install-v1.gradle │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── materialviewpager/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── florent37/ │ │ └── materialviewpager/ │ │ ├── MaterialViewPager.java │ │ ├── MaterialViewPagerAnimator.java │ │ ├── MaterialViewPagerHeader.java │ │ ├── MaterialViewPagerHeaderView.java │ │ ├── MaterialViewPagerHelper.java │ │ ├── MaterialViewPagerSettings.java │ │ ├── Utils.java │ │ └── header/ │ │ ├── HeaderDesign.java │ │ ├── MaterialViewPagerHeaderDecorator.java │ │ ├── MaterialViewPagerImageHeader.java │ │ ├── MaterialViewPagerImageHelper.java │ │ └── MaterialViewPagerKenBurnsHeader.java │ └── res/ │ ├── layout/ │ │ ├── material_view_pager_imageview_header.xml │ │ ├── material_view_pager_layout.xml │ │ ├── material_view_pager_moving_header.xml │ │ ├── material_view_pager_pagertitlestrip_newstand.xml │ │ ├── material_view_pager_pagertitlestrip_standard.xml │ │ ├── material_view_pager_placeholder.xml │ │ ├── material_view_pager_viewpager.xml │ │ ├── tools_list_item_card_big.xml │ │ ├── tools_list_item_card_small.xml │ │ ├── tools_list_items.xml │ │ └── tools_material_view_pager_pagertitlestrip.xml │ └── values/ │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── ids.xml │ └── styles.xml ├── publish.sh ├── sample/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── florent37/ │ │ └── materialviewpager/ │ │ └── sample/ │ │ ├── DrawerActivity.java │ │ ├── MainActivity.java │ │ ├── TestListViewAdapter.java │ │ ├── TestRecyclerViewAdapter.java │ │ └── fragment/ │ │ ├── RecyclerViewFragment.java │ │ └── ScrollFragment.java │ └── res/ │ ├── drawable/ │ │ └── circle.xml │ ├── layout/ │ │ ├── activity_main.xml │ │ ├── drawer.xml │ │ ├── fragment_list.xml │ │ ├── fragment_recyclerview.xml │ │ ├── fragment_scroll.xml │ │ ├── fragment_webview.xml │ │ ├── header_logo.xml │ │ ├── header_logo_2.xml │ │ ├── header_logo_full.xml │ │ ├── header_logo_text.xml │ │ ├── list_item_card_big.xml │ │ └── list_item_card_small.xml │ ├── menu/ │ │ └── menu_main.xml │ ├── values/ │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── values-w820dp/ │ └── dimens.xml └── settings.gradle
SYMBOL INDEX (158 symbols across 18 files)
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java
class MaterialViewPager (line 33) | public class MaterialViewPager extends FrameLayout implements ViewPager....
method MaterialViewPager (line 77) | public MaterialViewPager(Context context) {
method MaterialViewPager (line 81) | public MaterialViewPager(Context context, AttributeSet attrs) {
method MaterialViewPager (line 86) | public MaterialViewPager(Context context, AttributeSet attrs, int defS...
method MaterialViewPager (line 93) | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
method onRestoreInstanceState (line 99) | @Override
method onSaveInstanceState (line 116) | @Override
method getViewPager (line 135) | public ViewPager getViewPager() {
method getPagerTitleStrip (line 144) | public PagerSlidingTabStrip getPagerTitleStrip() {
method getToolbar (line 153) | public Toolbar getToolbar() {
method setToolbar (line 160) | public void setToolbar(Toolbar toolbar) {
method setImageUrl (line 168) | public void setImageUrl(String imageUrl, int fadeDuration) {
method setImageUrl (line 184) | public void setImageUrl(String imageUrl, int fadeDuration, OnImageLoad...
method setImageDrawable (line 195) | public void setImageDrawable(Drawable drawable, int fadeDuration) {
method setImageHeaderDarkLayerAlpha (line 210) | public void setImageHeaderDarkLayerAlpha() {
method setColor (line 222) | public void setColor(int color, int fadeDuration) {
method getHeaderBackgroundContainer (line 228) | public ViewGroup getHeaderBackgroundContainer() {
method onPageScrolled (line 232) | @Override
method notifyHeaderChanged (line 245) | public void notifyHeaderChanged() {
method onPageSelected (line 253) | @Override
method onPageScrollStateChanged (line 281) | @Override
method setMaterialViewPagerListener (line 289) | public void setMaterialViewPagerListener(Listener listener) {
method onDetachedFromWindow (line 293) | @Override
method onFinishInflate (line 300) | @Override
method initialiseHeights (line 394) | private void initialiseHeights() {
type Listener (line 415) | public interface Listener {
method getHeaderDesign (line 416) | HeaderDesign getHeaderDesign(int page);
type OnImageLoadListener (line 419) | public interface OnImageLoadListener {
method OnImageLoad (line 420) | void OnImageLoad(ImageView imageView, Bitmap bitmap);
class SavedState (line 423) | static class SavedState extends BaseSavedState {
method createFromParcel (line 427) | public SavedState createFromParcel(Parcel in) {
method newArray (line 431) | public SavedState[] newArray(int size) {
method SavedState (line 438) | SavedState(Parcelable superState) {
method SavedState (line 442) | private SavedState(Parcel in) {
method writeToParcel (line 448) | @Override
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java
class MaterialViewPagerAnimator (line 40) | public class MaterialViewPagerAnimator {
method MaterialViewPagerAnimator (line 71) | MaterialViewPagerAnimator(MaterialViewPager materialViewPager) {
method onMaterialScrolled (line 93) | private boolean onMaterialScrolled(Object source, float yOffset) {
method setColor (line 229) | void setColor(int color, int duration) {
method animateColorPercent (line 251) | public void animateColorPercent(float percent, int duration) {
method setColorPercent (line 263) | public void setColorPercent(float percent) {
method getHeaderHeight (line 299) | public int getHeaderHeight() {
method registerRecyclerView (line 310) | void registerRecyclerView(final RecyclerView recyclerView) {
method registerScrollView (line 361) | void registerScrollView(final NestedScrollView scrollView) {
method restoreScroll (line 393) | void restoreScroll(final float scroll, final MaterialViewPagerSettings...
method onViewPagerPageChanged (line 406) | void onViewPagerPageChanged() {
method dispatchScrollOffset (line 422) | private void dispatchScrollOffset(Object source, float yOffset) {
method isNewYOffset (line 434) | private boolean isNewYOffset(int yOffset) {
method setScrollOffset (line 448) | private void setScrollOffset(Object scroll, float yOffset) {
method cancelHeaderAnimator (line 459) | private void cancelHeaderAnimator() {
method scrollUp (line 468) | private void scrollUp(float yOffset) {
method log (line 474) | private void log(String scrollUp) {
method scrollDown (line 480) | private void scrollDown(float yOffset) {
method toolbarJoinsTabs (line 493) | private boolean toolbarJoinsTabs() {
method followScrollToolbarLayout (line 503) | private void followScrollToolbarLayout(float yOffset) {
method animateEnterToolbarLayout (line 535) | private void animateEnterToolbarLayout(float yOffset) {
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java
class MaterialViewPagerHeader (line 17) | public class MaterialViewPagerHeader {
method MaterialViewPagerHeader (line 43) | private MaterialViewPagerHeader(Toolbar toolbar) {
method withToolbar (line 49) | public static MaterialViewPagerHeader withToolbar(Toolbar toolbar) {
method getContext (line 53) | public Context getContext() {
method withPagerSlidingTabStrip (line 57) | public MaterialViewPagerHeader withPagerSlidingTabStrip(View pagerSlid...
method withHeaderBackground (line 73) | public MaterialViewPagerHeader withHeaderBackground(View headerBackgro...
method withStatusBackground (line 78) | public MaterialViewPagerHeader withStatusBackground(View statusBackgro...
method withToolbarLayoutBackground (line 83) | public MaterialViewPagerHeader withToolbarLayoutBackground(View toolba...
method getStatusBarHeight (line 88) | public int getStatusBarHeight(Context context) {
method withLogo (line 97) | public MaterialViewPagerHeader withLogo(View logo) {
method getToolbar (line 130) | public Toolbar getToolbar() {
method getHeaderBackground (line 134) | public View getHeaderBackground() {
method getStatusBackground (line 138) | public View getStatusBackground() {
method getLogo (line 142) | public View getLogo() {
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeaderView.java
class MaterialViewPagerHeaderView (line 18) | public class MaterialViewPagerHeaderView extends View {
method MaterialViewPagerHeaderView (line 19) | public MaterialViewPagerHeaderView(Context context) {
method MaterialViewPagerHeaderView (line 23) | public MaterialViewPagerHeaderView(Context context, AttributeSet attrs) {
method MaterialViewPagerHeaderView (line 27) | public MaterialViewPagerHeaderView(Context context, AttributeSet attrs...
method MaterialViewPagerHeaderView (line 31) | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
method setMaterialHeight (line 36) | private void setMaterialHeight() {
method onFinishInflate (line 49) | @Override
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java
class MaterialViewPagerHelper (line 17) | public class MaterialViewPagerHelper {
method register (line 27) | static void register(Context context, MaterialViewPagerAnimator animat...
method unregister (line 31) | static void unregister(Context context) {
method registerRecyclerView (line 45) | public static void registerRecyclerView(Context context, RecyclerView ...
method registerScrollView (line 62) | public static void registerScrollView(Context context, NestedScrollVie...
method getAnimator (line 77) | public static MaterialViewPagerAnimator getAnimator(Context context) {
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java
class MaterialViewPagerSettings (line 16) | public class MaterialViewPagerSettings implements Parcelable {
method createFromParcel (line 22) | public MaterialViewPagerSettings createFromParcel(Parcel source) {
method newArray (line 26) | public MaterialViewPagerSettings[] newArray(int size) {
method MaterialViewPagerSettings (line 52) | public MaterialViewPagerSettings() {
method MaterialViewPagerSettings (line 55) | private MaterialViewPagerSettings(Parcel in) {
method describeContents (line 73) | @Override
method writeToParcel (line 78) | @Override
method handleAttributes (line 103) | void handleAttributes(Context context, AttributeSet attrs) {
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/Utils.java
class Utils (line 23) | public class Utils {
method dpToPx (line 28) | public static float dpToPx(float dp, Context context) {
method pxToDp (line 35) | static float pxToDp(float px, Context context) {
method colorWithAlpha (line 42) | static int colorWithAlpha(int color, float percent) {
method minMax (line 51) | static float minMax(float min, float value, float max) {
method setScale (line 63) | static void setScale(float scale, View... views) {
method setElevation (line 78) | static void setElevation(float elevation, View... views) {
method setBackgroundColor (line 92) | static void setBackgroundColor(int color, View... views) {
method canScroll (line 100) | static boolean canScroll(View view) {
method scrollTo (line 117) | public static void scrollTo(Object scroll, float yOffset) {
method getTheVisibileView (line 135) | static View getTheVisibileView(List<View> viewList) {
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/HeaderDesign.java
class HeaderDesign (line 10) | public class HeaderDesign {
method HeaderDesign (line 16) | private HeaderDesign() {
method fromColorAndUrl (line 19) | public static HeaderDesign fromColorAndUrl(@ColorInt int color, String...
method fromColorResAndUrl (line 26) | public static HeaderDesign fromColorResAndUrl(@ColorRes int colorRes, ...
method fromColorAndDrawable (line 33) | public static HeaderDesign fromColorAndDrawable(@ColorInt int color, D...
method fromColorResAndDrawable (line 40) | public static HeaderDesign fromColorResAndDrawable(@ColorRes int color...
method getColor (line 47) | public int getColor() {
method getColorRes (line 51) | public int getColorRes() {
method getImageUrl (line 55) | public String getImageUrl() {
method getDrawable (line 59) | public Drawable getDrawable() {
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerHeaderDecorator.java
class MaterialViewPagerHeaderDecorator (line 17) | public class MaterialViewPagerHeaderDecorator extends RecyclerView.ItemD...
method getItemOffsets (line 21) | @Override
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHeader.java
class MaterialViewPagerImageHeader (line 15) | public class MaterialViewPagerImageHeader extends KenBurnsView {
method MaterialViewPagerImageHeader (line 19) | public MaterialViewPagerImageHeader(Context context) {
method MaterialViewPagerImageHeader (line 23) | public MaterialViewPagerImageHeader(Context context, AttributeSet attr...
method MaterialViewPagerImageHeader (line 27) | public MaterialViewPagerImageHeader(Context context, AttributeSet attr...
method setImageUrl (line 39) | public void setImageUrl(final String urlImage, final int fadeDuration) {
method setImageDrawable (line 49) | public void setImageDrawable(final Drawable drawable, final int fadeDu...
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java
class MaterialViewPagerImageHelper (line 27) | public class MaterialViewPagerImageHelper {
method setImageUrl (line 37) | public static void setImageUrl(final ImageView imageView, final String...
method fadeOut (line 77) | public static void fadeOut(View view, int fadeDuration, ViewPropertyAn...
method fadeIn (line 87) | public static void fadeIn(View view, float alpha, int fadeDuration, Vi...
method setImageDrawable (line 103) | public static void setImageDrawable(final ImageView imageView, final D...
method setImageLoadListener (line 121) | public static void setImageLoadListener(MaterialViewPager.OnImageLoadL...
FILE: materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerKenBurnsHeader.java
class MaterialViewPagerKenBurnsHeader (line 15) | public class MaterialViewPagerKenBurnsHeader extends KenBurnsView {
method MaterialViewPagerKenBurnsHeader (line 19) | public MaterialViewPagerKenBurnsHeader(Context context) {
method MaterialViewPagerKenBurnsHeader (line 23) | public MaterialViewPagerKenBurnsHeader(Context context, AttributeSet a...
method MaterialViewPagerKenBurnsHeader (line 27) | public MaterialViewPagerKenBurnsHeader(Context context, AttributeSet a...
method setImageUrl (line 39) | public void setImageUrl(final String urlImage, final int fadeDuration) {
method setImageDrawable (line 49) | public void setImageDrawable(final Drawable drawable, final int fadeDu...
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/DrawerActivity.java
class DrawerActivity (line 18) | public class DrawerActivity extends AppCompatActivity {
method onCreate (line 23) | @Override
method onStart (line 33) | @Override
method onPostCreate (line 51) | @Override
method onOptionsItemSelected (line 57) | @Override
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java
class MainActivity (line 24) | public class MainActivity extends DrawerActivity {
method onCreate (line 29) | @Override
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/TestListViewAdapter.java
class TestListViewAdapter (line 14) | public class TestListViewAdapter extends ArrayAdapter<Object> {
method TestListViewAdapter (line 19) | public TestListViewAdapter(Context context, List<Object> objects) {
method getItemViewType (line 23) | @Override
method getViewTypeCount (line 33) | @Override
method getView (line 38) | @Override
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/TestRecyclerViewAdapter.java
class TestRecyclerViewAdapter (line 13) | public class TestRecyclerViewAdapter extends RecyclerView.Adapter<Recycl...
method TestRecyclerViewAdapter (line 20) | public TestRecyclerViewAdapter(List<Object> contents) {
method getItemViewType (line 24) | @Override
method getItemCount (line 34) | @Override
method onCreateViewHolder (line 39) | @Override
method onBindViewHolder (line 61) | @Override
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/RecyclerViewFragment.java
class RecyclerViewFragment (line 26) | public class RecyclerViewFragment extends Fragment {
method newInstance (line 34) | public static RecyclerViewFragment newInstance() {
method onCreateView (line 38) | @Override
method onViewCreated (line 43) | @Override
FILE: sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/ScrollFragment.java
class ScrollFragment (line 21) | public class ScrollFragment extends Fragment {
method newInstance (line 26) | public static ScrollFragment newInstance() {
method onCreateView (line 30) | @Override
method onViewCreated (line 35) | @Override
Condensed preview — 75 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (168K chars).
[
{
"path": ".gitignore",
"chars": 425,
"preview": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbi"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 17526,
"preview": "MaterialViewPager\n=======\n\n[ {\n from android.sourceSets.ma"
},
{
"path": "gradle/install-v1.gradle",
"chars": 1258,
"preview": "apply plugin: 'com.github.dcendents.android-maven'\n\ngroup = publishedGroupId // Maven Grou"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 232,
"preview": "#Mon Feb 27 17:10:37 CET 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties",
"chars": 855,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 5080,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "materialviewpager/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "materialviewpager/build.gradle",
"chars": 1876,
"preview": "apply plugin: 'com.android.library'\napply plugin: 'com.github.ben-manes.versions'\n\nandroid {\n compileSdkVersion proje"
},
{
"path": "materialviewpager/proguard-rules.pro",
"chars": 666,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "materialviewpager/src/main/AndroidManifest.xml",
"chars": 176,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java",
"chars": 16634,
"preview": "package com.github.florent37.materialviewpager;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nim"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java",
"chars": 20107,
"preview": "package com.github.florent37.materialviewpager;\n\nimport android.animation.ArgbEvaluator;\nimport android.animation.Object"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java",
"chars": 4655,
"preview": "package com.github.florent37.materialviewpager;\n\nimport android.content.Context;\nimport android.support.v4.view.ViewComp"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeaderView.java",
"chars": 2318,
"preview": "package com.github.florent37.materialviewpager;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nim"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java",
"chars": 2928,
"preview": "package com.github.florent37.materialviewpager;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport and"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java",
"chars": 6723,
"preview": "package com.github.florent37.materialviewpager;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\n"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/Utils.java",
"chars": 4935,
"preview": "package com.github.florent37.materialviewpager;\n\nimport android.content.Context;\nimport android.graphics.Color;\nimport a"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/HeaderDesign.java",
"chars": 1743,
"preview": "package com.github.florent37.materialviewpager.header;\n\nimport android.graphics.drawable.Drawable;\nimport android.suppor"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerHeaderDecorator.java",
"chars": 1768,
"preview": "package com.github.florent37.materialviewpager.header;\n\nimport android.content.Context;\nimport android.graphics.Rect;\nim"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHeader.java",
"chars": 1447,
"preview": "package com.github.florent37.materialviewpager.header;\n\nimport android.content.Context;\nimport android.graphics.drawable"
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java",
"chars": 4885,
"preview": "package com.github.florent37.materialviewpager.header;\n\nimport android.graphics.drawable.BitmapDrawable;\nimport android."
},
{
"path": "materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerKenBurnsHeader.java",
"chars": 1459,
"preview": "package com.github.florent37.materialviewpager.header;\n\nimport android.content.Context;\nimport android.graphics.drawable"
},
{
"path": "materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml",
"chars": 617,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n a"
},
{
"path": "materialviewpager/src/main/res/layout/material_view_pager_layout.xml",
"chars": 2558,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xm"
},
{
"path": "materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml",
"chars": 799,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n a"
},
{
"path": "materialviewpager/src/main/res/layout/material_view_pager_pagertitlestrip_newstand.xml",
"chars": 655,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.astuetz.PagerSlidingTabStrip\n xmlns:android=\"http://schemas.android.com/a"
},
{
"path": "materialviewpager/src/main/res/layout/material_view_pager_pagertitlestrip_standard.xml",
"chars": 621,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.astuetz.PagerSlidingTabStrip\n xmlns:android=\"http://schemas.android.com/a"
},
{
"path": "materialviewpager/src/main/res/layout/material_view_pager_placeholder.xml",
"chars": 245,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.github.florent37.materialviewpager.MaterialViewPagerHeaderView\n xmlns:and"
},
{
"path": "materialviewpager/src/main/res/layout/material_view_pager_viewpager.xml",
"chars": 269,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.v4.view.ViewPager\n android:id=\"@id/materialviewpager_viewpage"
},
{
"path": "materialviewpager/src/main/res/layout/tools_list_item_card_big.xml",
"chars": 699,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andro"
},
{
"path": "materialviewpager/src/main/res/layout/tools_list_item_card_small.xml",
"chars": 702,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns"
},
{
"path": "materialviewpager/src/main/res/layout/tools_list_items.xml",
"chars": 539,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "materialviewpager/src/main/res/layout/tools_material_view_pager_pagertitlestrip.xml",
"chars": 1723,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "materialviewpager/src/main/res/values/attrs.xml",
"chars": 1337,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <declare-styleable name=\"MaterialViewPager\">\n <attr name="
},
{
"path": "materialviewpager/src/main/res/values/colors.xml",
"chars": 686,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <color name=\"blue\">#303F9F</color>\n <color name=\"green\">#4CAF"
},
{
"path": "materialviewpager/src/main/res/values/dimens.xml",
"chars": 187,
"preview": "<resources>\n <dimen name=\"cardMarginHorizontal\">10dp</dimen>\n <dimen name=\"cardMarginVertical\">8dp</dimen>\n\n <d"
},
{
"path": "materialviewpager/src/main/res/values/ids.xml",
"chars": 314,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <item type=\"id\" name=\"materialviewpager_pagerTitleStrip\" />\n <"
},
{
"path": "materialviewpager/src/main/res/values/styles.xml",
"chars": 1749,
"preview": "<resources xmlns:tools=\"http://schemas.android.com/tools\">\n\n\n <style name=\"MVP_AppBaseTheme\" parent=\"@style/Theme.App"
},
{
"path": "publish.sh",
"chars": 75,
"preview": "./gradlew clean :materialviewpager:install :materialviewpager:bintrayUpload"
},
{
"path": "sample/.gitignore",
"chars": 77,
"preview": "/build\nmaterial_view_pager_keystore.jks\nkeyInfos.properties\nfabric.properties"
},
{
"path": "sample/build.gradle",
"chars": 1795,
"preview": "apply plugin: 'com.android.application'\napply plugin: 'io.fabric'\n\nandroid {\n compileSdkVersion project.sdk\n build"
},
{
"path": "sample/proguard-rules.pro",
"chars": 666,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "sample/src/main/AndroidManifest.xml",
"chars": 1046,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "sample/src/main/java/com/github/florent37/materialviewpager/sample/DrawerActivity.java",
"chars": 1846,
"preview": "package com.github.florent37.materialviewpager.sample;\n\nimport android.os.Bundle;\nimport android.support.annotation.Null"
},
{
"path": "sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java",
"chars": 4647,
"preview": "package com.github.florent37.materialviewpager.sample;\n\nimport android.os.Bundle;\nimport android.support.v4.app.Fragment"
},
{
"path": "sample/src/main/java/com/github/florent37/materialviewpager/sample/TestListViewAdapter.java",
"chars": 1553,
"preview": "package com.github.florent37.materialviewpager.sample;\n\nimport android.content.Context;\nimport android.view.LayoutInflat"
},
{
"path": "sample/src/main/java/com/github/florent37/materialviewpager/sample/TestRecyclerViewAdapter.java",
"chars": 1862,
"preview": "package com.github.florent37.materialviewpager.sample;\n\nimport android.support.v7.widget.RecyclerView;\nimport android.vi"
},
{
"path": "sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/RecyclerViewFragment.java",
"chars": 2190,
"preview": "package com.github.florent37.materialviewpager.sample.fragment;\n\nimport android.os.Bundle;\nimport android.support.annota"
},
{
"path": "sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/ScrollFragment.java",
"chars": 1268,
"preview": "package com.github.florent37.materialviewpager.sample.fragment;\n\nimport android.os.Bundle;\nimport android.support.annota"
},
{
"path": "sample/src/main/res/drawable/circle.xml",
"chars": 172,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\" android:shape=\""
},
{
"path": "sample/src/main/res/layout/activity_main.xml",
"chars": 1376,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.v4.widget.DrawerLayout xmlns:android=\"http://schemas.android.com"
},
{
"path": "sample/src/main/res/layout/drawer.xml",
"chars": 301,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<View xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:id=\""
},
{
"path": "sample/src/main/res/layout/fragment_list.xml",
"chars": 318,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.github.ksoichiro.android.observablescrollview.ObservableListView\n xmlns:a"
},
{
"path": "sample/src/main/res/layout/fragment_recyclerview.xml",
"chars": 264,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.v7.widget.RecyclerView\n xmlns:android=\"http://schemas.android"
},
{
"path": "sample/src/main/res/layout/fragment_scroll.xml",
"chars": 1353,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.v4.widget.NestedScrollView\n xmlns:android=\"http://schemas.and"
},
{
"path": "sample/src/main/res/layout/fragment_webview.xml",
"chars": 617,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andro"
},
{
"path": "sample/src/main/res/layout/header_logo.xml",
"chars": 280,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ImageView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android"
},
{
"path": "sample/src/main/res/layout/header_logo_2.xml",
"chars": 485,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andro"
},
{
"path": "sample/src/main/res/layout/header_logo_full.xml",
"chars": 359,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ImageView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android"
},
{
"path": "sample/src/main/res/layout/header_logo_text.xml",
"chars": 393,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<TextView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:"
},
{
"path": "sample/src/main/res/layout/list_item_card_big.xml",
"chars": 985,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns"
},
{
"path": "sample/src/main/res/layout/list_item_card_small.xml",
"chars": 858,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns"
},
{
"path": "sample/src/main/res/menu/menu_main.xml",
"chars": 361,
"preview": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\""
},
{
"path": "sample/src/main/res/values/colors.xml",
"chars": 444,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <color name=\"blue\">#303F9F</color>\n\n <color name=\"accent_colo"
},
{
"path": "sample/src/main/res/values/dimens.xml",
"chars": 126,
"preview": "<resources>\n <dimen name=\"cardMarginHorizontal\">10dp</dimen>\n <dimen name=\"cardMarginVertical\">8dp</dimen>\n</resou"
},
{
"path": "sample/src/main/res/values/strings.xml",
"chars": 189,
"preview": "<resources>\n <string name=\"app_name\">Material View Pager</string>\n\n <string name=\"hello_world\">Hello world!</strin"
},
{
"path": "sample/src/main/res/values/styles.xml",
"chars": 1325,
"preview": "<resources xmlns:tools=\"http://schemas.android.com/tools\">\n\n\n <style name=\"AppBaseTheme\" parent=\"@style/Theme.AppComp"
},
{
"path": "sample/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "settings.gradle",
"chars": 39,
"preview": "include ':materialviewpager', ':sample'"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the florent37/MaterialViewPager GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 75 files (152.1 KB), approximately 36.9k tokens, and a symbol index with 158 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.