From f07b7c5c96d1893f1ec980a8cb080e4b6632044c Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 7 Jul 2015 14:36:49 +0200 Subject: [PATCH 01/78] updated README --- .idea/libraries/materialviewpager_1_0_6.xml | 13 ----- README.md | 4 ++ .../MaterialViewPagerAnimator.java | 10 +--- sample/.gitignore | 2 + sample/build.gradle | 33 ++++++++++-- sample/sample.iml | 52 +++++++------------ .../sample/MainActivity.java | 8 +-- sample/src/main/res/layout/activity_main.xml | 2 +- 8 files changed, 62 insertions(+), 62 deletions(-) delete mode 100644 .idea/libraries/materialviewpager_1_0_6.xml diff --git a/.idea/libraries/materialviewpager_1_0_6.xml b/.idea/libraries/materialviewpager_1_0_6.xml deleted file mode 100644 index 058bc97d..00000000 --- a/.idea/libraries/materialviewpager_1_0_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 0b41c978..f4f55346 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ Material Design ViewPager easy to use library #Sample + + Android app on Google Play + + You can find a sample APK : [Link](https://github.com/florent37/MaterialViewPager/releases/download/1.0.3/sample-debug.apk) And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.com/watch?v=r95Tt6AS18c) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 28b9994b..49487888 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -1,17 +1,11 @@ package com.github.florent37.materialviewpager; import android.content.Context; -import android.graphics.Rect; import android.os.Build; -import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.StaggeredGridLayoutManager; import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.webkit.WebView; -import android.widget.ListView; -import android.widget.ScrollView; import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks; @@ -142,7 +136,7 @@ private void setScrollOffset(Object scroll, float yOffset) { //do not re-scroll the source if (scroll != null && yOffset >= 0) { - scrollTo(scroll,yOffset); + scrollTo(scroll, yOffset); //save the current yOffset of the scrollable on the yOffsets hashmap yOffsets.put(scroll, (int) yOffset); @@ -612,7 +606,7 @@ public void onViewPagerPageChanged() { scrollDown(lastYOffset); View visibleView = getTheVisibileView(scrollViewList); - if(!canScroll(visibleView)){ + if (!canScroll(visibleView)) { followScrollToolbarLayout(0); onMaterialScrolled(visibleView, 0); } diff --git a/sample/.gitignore b/sample/.gitignore index 796b96d1..ce9b610d 100644 --- a/sample/.gitignore +++ b/sample/.gitignore @@ -1 +1,3 @@ /build +material_view_pager_keystore.jks +keyInfos.properties \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 8c2d9f52..99df5bc8 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -8,9 +8,34 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 22 - versionCode 1 + versionCode 2 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 @@ -24,9 +49,9 @@ dependencies { compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:cardview-v7:22.2.0' - compile ('com.github.florent37:materialviewpager:1.0.6@aar'){ - transitive=true - } + //compile ('com.github.florent37:materialviewpager:1.0.6@aar'){ + // transitive=true + //} compile project(':materialviewpager') } diff --git a/sample/sample.iml b/sample/sample.iml index b6bdf679..cff01670 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -8,15 +8,12 @@ - - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -71,7 +62,6 @@ - @@ -85,19 +75,17 @@ + - - - - + \ No newline at end of file diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java index 6361c867..b0f67133 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java @@ -92,13 +92,13 @@ public CharSequence getPageTitle(int position) { 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 1: + return HeaderDesign.fromColorResAndUrl( + R.color.blue, + "http://cdn1.tnwcdn.com/wp-content/blogs.dir/1/files/2014/06/wallpaper_51.jpg"); case 2: return HeaderDesign.fromColorResAndUrl( R.color.cyan, diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 6fc285e7..072f001f 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -10,7 +10,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:viewpager_logo="@layout/header_logo" - app:viewpager_pagerTitleStrip="@layout/material_view_pager_pagertitlestrip_standard" + app:viewpager_pagerTitleStrip="@layout/material_view_pager_pagertitlestrip_newstand" app:viewpager_logoMarginTop="100dp" app:viewpager_color="@color/colorPrimary" app:viewpager_headerHeight="200dp" From 3ffcd50ba44396058ca5db2a0ffcd4d346a4065f Mon Sep 17 00:00:00 2001 From: Florent Date: Wed, 8 Jul 2015 15:43:24 +0200 Subject: [PATCH 02/78] fixed bug on small devices --- .../materialviewpager/MaterialViewPagerAnimator.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 49487888..36f90033 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -143,6 +143,8 @@ private void setScrollOffset(Object scroll, float yOffset) { } } + float initialDistance = -1; + /** * Called when a scroller(RecyclerView/ListView,ScrollView,WebView) scrolled by the user * @@ -179,6 +181,13 @@ public void onMaterialScrolled(Object source, float yOffset) { float percent = yOffset / scrollMax; + if(initialDistance == -1) + initialDistance = mHeader.mPagerSlidingTabStrip.getTop() - mHeader.toolbar.getBottom(); + + float newDistance = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom(); + + percent = 1 - newDistance/initialDistance; + percent = minMax(0, percent, 1); { From 541dba473a478772af760732e9fe4e7c609fc468 Mon Sep 17 00:00:00 2001 From: Florent Date: Wed, 8 Jul 2015 16:36:19 +0200 Subject: [PATCH 03/78] upgraded version to 1.0.6 --- .idea/libraries/answers_1_2_2.xml | 10 +++++++++ .idea/libraries/beta_1_1_3.xml | 10 +++++++++ .idea/libraries/crashlytics_2_4_0.xml | 10 +++++++++ .idea/libraries/crashlytics_core_2_3_3.xml | 10 +++++++++ .idea/libraries/fabric_1_3_4.xml | 10 +++++++++ README.md | 3 +++ materialviewpager/build.gradle | 2 +- materialviewpager/materialviewpager.iml | 2 +- .../MaterialViewPagerAnimator.java | 6 +++-- sample/.gitignore | 3 ++- sample/build.gradle | 22 ++++++++++++++++++- sample/sample.iml | 10 +++++++++ sample/src/main/AndroidManifest.xml | 5 +++++ .../sample/MainActivity.java | 6 +++++ 14 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 .idea/libraries/answers_1_2_2.xml create mode 100644 .idea/libraries/beta_1_1_3.xml create mode 100644 .idea/libraries/crashlytics_2_4_0.xml create mode 100644 .idea/libraries/crashlytics_core_2_3_3.xml create mode 100644 .idea/libraries/fabric_1_3_4.xml diff --git a/.idea/libraries/answers_1_2_2.xml b/.idea/libraries/answers_1_2_2.xml new file mode 100644 index 00000000..e070364f --- /dev/null +++ b/.idea/libraries/answers_1_2_2.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/beta_1_1_3.xml b/.idea/libraries/beta_1_1_3.xml new file mode 100644 index 00000000..236ae995 --- /dev/null +++ b/.idea/libraries/beta_1_1_3.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/crashlytics_2_4_0.xml b/.idea/libraries/crashlytics_2_4_0.xml new file mode 100644 index 00000000..02dd64aa --- /dev/null +++ b/.idea/libraries/crashlytics_2_4_0.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/crashlytics_core_2_3_3.xml b/.idea/libraries/crashlytics_core_2_3_3.xml new file mode 100644 index 00000000..b668786e --- /dev/null +++ b/.idea/libraries/crashlytics_core_2_3_3.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/fabric_1_3_4.xml b/.idea/libraries/fabric_1_3_4.xml new file mode 100644 index 00000000..ad1dfd9f --- /dev/null +++ b/.idea/libraries/fabric_1_3_4.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index f4f55346..d9535163 100644 --- a/README.md +++ b/README.md @@ -499,6 +499,9 @@ And must include @layout/material_view_pager_placeholder as first child #CHANGELOG +##1.0.6 +- fix bug on low resolutions + ##1.0.6 - added attribute transparentToolbar - added attribute animatedHeaderImage diff --git a/materialviewpager/build.gradle b/materialviewpager/build.gradle index 9564b743..76b6e152 100644 --- a/materialviewpager/build.gradle +++ b/materialviewpager/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.ben-manes.versions' -version = "1.0.6" +version = "1.0.7" android { compileSdkVersion 22 diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index 5b0aa274..d024ee7d 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -1,5 +1,5 @@ - + diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 36f90033..d698c938 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -91,6 +91,9 @@ public class MaterialViewPagerAnimator { float firstScrollValue = Float.MIN_VALUE; boolean justToolbarAnimated = false; + //intial distance between pager & toolbat + float initialDistance = -1; + public MaterialViewPagerAnimator(MaterialViewPager materialViewPager) { this.settings = materialViewPager.settings; @@ -143,8 +146,6 @@ private void setScrollOffset(Object scroll, float yOffset) { } } - float initialDistance = -1; - /** * Called when a scroller(RecyclerView/ListView,ScrollView,WebView) scrolled by the user * @@ -184,6 +185,7 @@ public void onMaterialScrolled(Object source, float yOffset) { if(initialDistance == -1) initialDistance = mHeader.mPagerSlidingTabStrip.getTop() - mHeader.toolbar.getBottom(); + //distance between pager & toolbar float newDistance = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom(); percent = 1 - newDistance/initialDistance; diff --git a/sample/.gitignore b/sample/.gitignore index ce9b610d..09f39f0b 100644 --- a/sample/.gitignore +++ b/sample/.gitignore @@ -1,3 +1,4 @@ /build material_view_pager_keystore.jks -keyInfos.properties \ No newline at end of file +keyInfos.properties +fabric.properties \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 99df5bc8..35189433 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,6 +1,22 @@ apply plugin: 'android-sdk-manager' apply plugin: 'com.android.application' +buildscript { + repositories { + maven { url 'https://maven.fabric.io/public' } + } + + dependencies { + classpath 'io.fabric.tools:gradle:1.+' + } +} + +apply plugin: 'io.fabric' + +repositories { + maven { url 'https://maven.fabric.io/public' } +} + android { compileSdkVersion 22 buildToolsVersion "22.0.1" @@ -8,7 +24,7 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 22 - versionCode 2 + versionCode 3 versionName "1.0" } @@ -53,5 +69,9 @@ dependencies { // transitive=true //} + compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') { + transitive = true; + } + compile project(':materialviewpager') } diff --git a/sample/sample.iml b/sample/sample.iml index cff01670..fe34cbec 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -62,6 +62,11 @@ + + + + + @@ -80,12 +85,17 @@ + + + + + \ No newline at end of file diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 755fd9e1..c33df6ff 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -20,6 +20,11 @@ + + + diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java index b0f67133..9d58ccc3 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java @@ -9,11 +9,14 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; +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 com.github.florent37.materialviewpager.sample.fragment.ScrollFragment; +import io.fabric.sdk.android.Fabric; + public class MainActivity extends AppCompatActivity { private MaterialViewPager mViewPager; @@ -27,6 +30,9 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + if(!BuildConfig.DEBUG) + Fabric.with(this, new Crashlytics()); + setTitle(""); mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager); From 08a9ee19af81ff8ea94df24b5d8114a893cc1820 Mon Sep 17 00:00:00 2001 From: Florent Date: Wed, 8 Jul 2015 16:40:24 +0200 Subject: [PATCH 04/78] updated README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d9535163..7791e69b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.co In your module [![Download](https://api.bintray.com/packages/florent37/maven/MaterialViewPager/images/download.svg)](https://bintray.com/florent37/maven/MaterialViewPager/_latestVersion) ```groovy -compile ('com.github.florent37:materialviewpager:1.0.6@aar'){ +compile ('com.github.florent37:materialviewpager:1.0.7@aar'){ transitive = true } ``` @@ -499,7 +499,7 @@ And must include @layout/material_view_pager_placeholder as first child #CHANGELOG -##1.0.6 +##1.0.7 - fix bug on low resolutions ##1.0.6 From 69557c203f34ec793b3ed649b0a525d6ee5bc9d9 Mon Sep 17 00:00:00 2001 From: Florent Date: Wed, 8 Jul 2015 16:40:48 +0200 Subject: [PATCH 05/78] updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7791e69b..4aa04e98 100644 --- a/README.md +++ b/README.md @@ -357,7 +357,7 @@ Create your own layout using a PagerSlidingTabStrip Simply add a listen to the ViewPager ```java -mViewPager.setMaterialViewPagerListener(new MaterialViewPager.MaterialViewPagerListener() { +mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() { @Override public HeaderDesign getHeaderDesign(int page) { switch (page) { From 428899333cf385fa0605ae59ea8847de0ec174e0 Mon Sep 17 00:00:00 2001 From: Arnav Gupta Date: Mon, 13 Jul 2015 03:41:34 +0530 Subject: [PATCH 06/78] allow app developers to enable/disable logging This will allow developers to do `MaterialViewPagerAnimator.ENABLE_LOG = false;` in their Application or Activity if they do not want the log spam. --- .../florent37/materialviewpager/MaterialViewPagerAnimator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index d698c938..9508e538 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -47,7 +47,7 @@ public class MaterialViewPagerAnimator { private static final String TAG = MaterialViewPagerAnimator.class.getSimpleName(); - private static final Boolean ENABLE_LOG = true; + public static Boolean ENABLE_LOG = true; private Context context; From bb9541c5406c4583aa83b886c5f42d7a4fffcad3 Mon Sep 17 00:00:00 2001 From: Sven Grossmann Date: Fri, 17 Jul 2015 17:25:45 +0200 Subject: [PATCH 07/78] add the possibility to completly disable the viewpager-toolbar --- .../materialviewpager/MaterialViewPager.java | 12 ++++++++++++ .../materialviewpager/MaterialViewPagerSettings.java | 6 +++++- materialviewpager/src/main/res/values/attrs.xml | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 4913743d..877878b9 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -7,6 +7,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -118,6 +119,8 @@ protected void onFinishInflate() { logoContainer = (ViewGroup) findViewById(R.id.logoContainer); mToolbar = (Toolbar) findViewById(R.id.toolbar); + if(settings.disableToolbar) + mToolbar.setVisibility(GONE); mViewPager = (ViewPager) findViewById(R.id.viewPager); mViewPager.addOnPageChangeListener(this); @@ -225,6 +228,15 @@ public PagerSlidingTabStrip getPagerTitleStrip() { return (PagerSlidingTabStrip) pagerTitleStripContainer.findViewById(R.id.materialviewpager_pagerTitleStrip); } + /** + * Retrieve the displayed toolbar + * + * @return the displayed toolbar + */ + public void setToolbar(Toolbar toolbar) { + mToolbar=toolbar; + } + /** * Retrieve the displayed toolbar * diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java index 347dbb36..0b1dfeaf 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java @@ -39,6 +39,7 @@ public class MaterialViewPagerSettings implements Parcelable { protected boolean displayToolbarWhenSwipe; protected boolean toolbarTransparent; protected boolean animatedHeaderImage; + protected boolean disableToolbar; /** * Retrieve attributes from the MaterialViewPager @@ -75,7 +76,7 @@ protected void handleAttributes(Context context, AttributeSet attrs){ } { parallaxHeaderFactor = styledAttrs.getFloat(R.styleable.MaterialViewPager_viewpager_parallaxHeaderFactor, 1.5f); - parallaxHeaderFactor = Math.max(parallaxHeaderFactor,1); //min=1 + parallaxHeaderFactor = Math.max(parallaxHeaderFactor, 1); //min=1 } { hideToolbarAndTitle = styledAttrs.getBoolean(R.styleable.MaterialViewPager_viewpager_hideToolbarAndTitle, false); @@ -93,6 +94,9 @@ protected void handleAttributes(Context context, AttributeSet attrs){ { 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(); diff --git a/materialviewpager/src/main/res/values/attrs.xml b/materialviewpager/src/main/res/values/attrs.xml index accebf1f..cc2765a9 100644 --- a/materialviewpager/src/main/res/values/attrs.xml +++ b/materialviewpager/src/main/res/values/attrs.xml @@ -17,6 +17,7 @@ + From cc4e78fe50330ba5b32fdd71656eef919e929da9 Mon Sep 17 00:00:00 2001 From: Sven Grossmann Date: Fri, 17 Jul 2015 17:28:02 +0200 Subject: [PATCH 08/78] removed unnecessary import --- .../github/florent37/materialviewpager/MaterialViewPager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 877878b9..f9faf15b 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -7,7 +7,6 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.AttributeSet; import android.view.LayoutInflater; From d3948674d9c7cd654d924f01296967c47d3e3d9d Mon Sep 17 00:00:00 2001 From: Florent Date: Sun, 19 Jul 2015 20:49:11 +0200 Subject: [PATCH 09/78] version 1.0.8 --- .idea/libraries/appcompat_v7_22_2_0.xml | 15 ------------ .idea/libraries/appcompat_v7_22_2_1.xml | 10 ++++++++ .idea/libraries/cardview_v7_22_2_0.xml | 12 ---------- .idea/libraries/cardview_v7_22_2_1.xml | 10 ++++++++ ..._22_2_0.xml => recyclerview_v7_22_2_1.xml} | 10 ++++---- .../libraries/support_annotations_22_2_0.xml | 11 --------- .../libraries/support_annotations_22_2_1.xml | 11 +++++++++ .idea/libraries/support_v4_22_2_0.xml | 16 ------------- .idea/libraries/support_v4_22_2_1.xml | 11 +++++++++ README.md | 2 +- build.gradle | 11 +++++++++ materialviewpager/build.gradle | 20 ++++++++-------- materialviewpager/materialviewpager.iml | 23 ++++++++++--------- .../MaterialViewPagerAnimator.java | 2 +- sample/build.gradle | 12 +++++----- sample/sample.iml | 10 ++++---- .../sample/MainActivity.java | 3 +++ sample/src/main/res/layout/activity_main.xml | 12 ++++++++++ 18 files changed, 107 insertions(+), 94 deletions(-) delete mode 100644 .idea/libraries/appcompat_v7_22_2_0.xml create mode 100644 .idea/libraries/appcompat_v7_22_2_1.xml delete mode 100644 .idea/libraries/cardview_v7_22_2_0.xml create mode 100644 .idea/libraries/cardview_v7_22_2_1.xml rename .idea/libraries/{recyclerview_v7_22_2_0.xml => recyclerview_v7_22_2_1.xml} (55%) delete mode 100644 .idea/libraries/support_annotations_22_2_0.xml create mode 100644 .idea/libraries/support_annotations_22_2_1.xml delete mode 100644 .idea/libraries/support_v4_22_2_0.xml create mode 100644 .idea/libraries/support_v4_22_2_1.xml diff --git a/.idea/libraries/appcompat_v7_22_2_0.xml b/.idea/libraries/appcompat_v7_22_2_0.xml deleted file mode 100644 index cedc18fb..00000000 --- a/.idea/libraries/appcompat_v7_22_2_0.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/appcompat_v7_22_2_1.xml b/.idea/libraries/appcompat_v7_22_2_1.xml new file mode 100644 index 00000000..1b9a3b42 --- /dev/null +++ b/.idea/libraries/appcompat_v7_22_2_1.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/cardview_v7_22_2_0.xml b/.idea/libraries/cardview_v7_22_2_0.xml deleted file mode 100644 index 737b8d08..00000000 --- a/.idea/libraries/cardview_v7_22_2_0.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/cardview_v7_22_2_1.xml b/.idea/libraries/cardview_v7_22_2_1.xml new file mode 100644 index 00000000..7c2cb6ba --- /dev/null +++ b/.idea/libraries/cardview_v7_22_2_1.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/recyclerview_v7_22_2_0.xml b/.idea/libraries/recyclerview_v7_22_2_1.xml similarity index 55% rename from .idea/libraries/recyclerview_v7_22_2_0.xml rename to .idea/libraries/recyclerview_v7_22_2_1.xml index 6dd9acb1..eaae5604 100644 --- a/.idea/libraries/recyclerview_v7_22_2_0.xml +++ b/.idea/libraries/recyclerview_v7_22_2_1.xml @@ -1,12 +1,10 @@ - + - - + + - - - + \ No newline at end of file diff --git a/.idea/libraries/support_annotations_22_2_0.xml b/.idea/libraries/support_annotations_22_2_0.xml deleted file mode 100644 index 533c7529..00000000 --- a/.idea/libraries/support_annotations_22_2_0.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/support_annotations_22_2_1.xml b/.idea/libraries/support_annotations_22_2_1.xml new file mode 100644 index 00000000..d35d8131 --- /dev/null +++ b/.idea/libraries/support_annotations_22_2_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_v4_22_2_0.xml b/.idea/libraries/support_v4_22_2_0.xml deleted file mode 100644 index 81f2c09a..00000000 --- a/.idea/libraries/support_v4_22_2_0.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/support_v4_22_2_1.xml b/.idea/libraries/support_v4_22_2_1.xml new file mode 100644 index 00000000..96cbfbe0 --- /dev/null +++ b/.idea/libraries/support_v4_22_2_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 4aa04e98..2ddcda35 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.co In your module [![Download](https://api.bintray.com/packages/florent37/maven/MaterialViewPager/images/download.svg)](https://bintray.com/florent37/maven/MaterialViewPager/_latestVersion) ```groovy -compile ('com.github.florent37:materialviewpager:1.0.7@aar'){ +compile ('com.github.florent37:materialviewpager:1.0.8@aar'){ transitive = true } ``` diff --git a/build.gradle b/build.gradle index 3d79c2b9..dece29d4 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,17 @@ buildscript { } } +ext{ + ANDROID_BUILD_MIN_SDK_VERSION=10 + ANDROID_BUILD_TARGET_SDK_VERSION=22 + ANDROID_BUILD_TOOLS_VERSION='22.0.0' + ANDROID_BUILD_SDK_VERSION=22 + + SUPPORT_VERSION='22.2.1' + + MAVEN_VERSION='1.0.8' +} + allprojects { repositories { jcenter() diff --git a/materialviewpager/build.gradle b/materialviewpager/build.gradle index 76b6e152..75385766 100644 --- a/materialviewpager/build.gradle +++ b/materialviewpager/build.gradle @@ -4,15 +4,15 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.ben-manes.versions' -version = "1.0.7" +version = project.MAVEN_VERSION android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" + compileSdkVersion project.ANDROID_BUILD_SDK_VERSION + buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION defaultConfig { - minSdkVersion 10 - targetSdkVersion 22 + minSdkVersion project.ANDROID_BUILD_MIN_SDK_VERSION + targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION versionCode 1 versionName "1.0" } @@ -28,11 +28,11 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile ( - 'com.android.support:appcompat-v7:22.2.0', - 'com.android.support:support-v4:22.2.0', - 'com.android.support:recyclerview-v7:22.2.0', - 'com.android.support:cardview-v7:22.2.0', - 'com.android.support:support-annotations:22.2.0' + 'com.android.support:appcompat-v7:'+project.SUPPORT_VERSION, + 'com.android.support:support-v4:'+project.SUPPORT_VERSION, + 'com.android.support:recyclerview-v7:'+project.SUPPORT_VERSION, + 'com.android.support:cardview-v7:'+project.SUPPORT_VERSION, + 'com.android.support:support-annotations:'+project.SUPPORT_VERSION ) compile 'com.nineoldandroids:library:2.4.0' diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index d024ee7d..54e2bda4 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -1,5 +1,5 @@ - + @@ -65,6 +65,7 @@ + @@ -73,10 +74,10 @@ - - - - + + + + @@ -96,17 +97,17 @@ - + - - - - + + + - + + \ No newline at end of file diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 9508e538..68bd3f12 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -47,7 +47,7 @@ public class MaterialViewPagerAnimator { private static final String TAG = MaterialViewPagerAnimator.class.getSimpleName(); - public static Boolean ENABLE_LOG = true; + public static Boolean ENABLE_LOG = false; private Context context; diff --git a/sample/build.gradle b/sample/build.gradle index 35189433..996106b9 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -18,12 +18,12 @@ repositories { } android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" + compileSdkVersion project.ANDROID_BUILD_SDK_VERSION + buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION defaultConfig { - minSdkVersion 14 - targetSdkVersion 22 + minSdkVersion project.ANDROID_BUILD_MIN_SDK_VERSION + targetSdkVersion project.ANDROID_BUILD_TARGET_SDK_VERSION versionCode 3 versionName "1.0" } @@ -62,8 +62,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.2.0' - compile 'com.android.support:cardview-v7:22.2.0' + compile 'com.android.support:appcompat-v7:'+project.SUPPORT_VERSION + compile 'com.android.support:cardview-v7:'+project.SUPPORT_VERSION //compile ('com.github.florent37:materialviewpager:1.0.6@aar'){ // transitive=true diff --git a/sample/sample.iml b/sample/sample.iml index fe34cbec..2e83f4bf 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -82,19 +82,19 @@ - + - - + - + + - + diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java index 9d58ccc3..293b91d2 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java @@ -1,6 +1,7 @@ package com.github.florent37.materialviewpager.sample; import android.os.Bundle; +import android.os.Handler; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.widget.DrawerLayout; @@ -133,4 +134,6 @@ protected void onPostCreate(Bundle savedInstanceState) { mDrawerToggle.syncState(); } + + } diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 072f001f..e1d4d26d 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -28,4 +28,16 @@ + + + + + + \ No newline at end of file From 2837b168efbcfa153149351a6ae1b18be045e407 Mon Sep 17 00:00:00 2001 From: Varun Ramesh Date: Thu, 23 Jul 2015 11:55:15 -0700 Subject: [PATCH 10/78] Fix what seems to be a mistake in fromColorResAndDrawable Based off the name of the function, it seems that `fromColorResAndDrawable` should take in a `Drawable` object, not a `String` imageUrl. --- .../florent37/materialviewpager/header/HeaderDesign.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/HeaderDesign.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/HeaderDesign.java index 1a50e63c..19776b9b 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/HeaderDesign.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/HeaderDesign.java @@ -37,10 +37,10 @@ public static HeaderDesign fromColorAndDrawable(@ColorInt int color, Drawable dr return headerDesign; } - public static HeaderDesign fromColorResAndDrawable(@ColorRes int colorRes, String imageUrl) { + public static HeaderDesign fromColorResAndDrawable(@ColorRes int colorRes, Drawable drawable) { HeaderDesign headerDesign = new HeaderDesign(); headerDesign.colorRes = colorRes; - headerDesign.imageUrl = imageUrl; + headerDesign.drawable = drawable; return headerDesign; } From c3841cce725f0e232798bb0904cfb069bcd15393 Mon Sep 17 00:00:00 2001 From: Tomislav Rajakovic Date: Fri, 24 Jul 2015 13:48:55 +0200 Subject: [PATCH 11/78] mHeader color flickering while swiping tabs #117 fixed --- .../materialviewpager/MaterialViewPagerAnimator.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 68bd3f12..63448013 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -303,19 +303,19 @@ public void setColor(int color, int duration) { colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { - int colorAlpha = colorWithAlpha((Integer) animation.getAnimatedValue(), lastPercent); + 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(); - - //set the new color as MaterialViewPager's color - this.settings.color = color; - } public void animateColorPercent(float percent, int duration) { From b35587647da85123febcacbb1130732bcbf59fbd Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 28 Jul 2015 16:43:04 +0200 Subject: [PATCH 12/78] version 1.0.8 --- .idea/libraries/appcompat_v7_22_2_1.xml | 7 ++++++- .idea/libraries/cardview_v7_22_2_1.xml | 4 +++- .idea/libraries/recyclerview_v7_22_2_1.xml | 4 +++- .idea/libraries/support_v4_22_2_1.xml | 7 ++++++- README.md | 3 +++ build.gradle | 2 +- materialviewpager/materialviewpager.iml | 5 ++--- .../florent37/materialviewpager/MaterialViewPager.java | 2 +- sample/src/main/res/layout/activity_main.xml | 1 + 9 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.idea/libraries/appcompat_v7_22_2_1.xml b/.idea/libraries/appcompat_v7_22_2_1.xml index 1b9a3b42..a630ec58 100644 --- a/.idea/libraries/appcompat_v7_22_2_1.xml +++ b/.idea/libraries/appcompat_v7_22_2_1.xml @@ -1,10 +1,15 @@ + + + - + + + \ No newline at end of file diff --git a/.idea/libraries/cardview_v7_22_2_1.xml b/.idea/libraries/cardview_v7_22_2_1.xml index 7c2cb6ba..59c1810e 100644 --- a/.idea/libraries/cardview_v7_22_2_1.xml +++ b/.idea/libraries/cardview_v7_22_2_1.xml @@ -5,6 +5,8 @@ - + + + \ No newline at end of file diff --git a/.idea/libraries/recyclerview_v7_22_2_1.xml b/.idea/libraries/recyclerview_v7_22_2_1.xml index eaae5604..c88b12ab 100644 --- a/.idea/libraries/recyclerview_v7_22_2_1.xml +++ b/.idea/libraries/recyclerview_v7_22_2_1.xml @@ -5,6 +5,8 @@ - + + + \ No newline at end of file diff --git a/.idea/libraries/support_v4_22_2_1.xml b/.idea/libraries/support_v4_22_2_1.xml index 96cbfbe0..e5875958 100644 --- a/.idea/libraries/support_v4_22_2_1.xml +++ b/.idea/libraries/support_v4_22_2_1.xml @@ -1,11 +1,16 @@ + + + - + + + \ No newline at end of file diff --git a/README.md b/README.md index 2ddcda35..139e959e 100644 --- a/README.md +++ b/README.md @@ -499,6 +499,9 @@ And must include @layout/material_view_pager_placeholder as first child #CHANGELOG +##1.0.8 +- added attribute viewpager_disableToolbar + ##1.0.7 - fix bug on low resolutions diff --git a/build.gradle b/build.gradle index dece29d4..c99f1520 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ ext{ SUPPORT_VERSION='22.2.1' - MAVEN_VERSION='1.0.8' + MAVEN_VERSION='1.0.9' } allprojects { diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index 54e2bda4..a4b4b0b7 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -1,5 +1,5 @@ - + @@ -65,7 +65,6 @@ - @@ -104,8 +103,8 @@ - + diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index f9faf15b..06159421 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -119,7 +119,7 @@ protected void onFinishInflate() { mToolbar = (Toolbar) findViewById(R.id.toolbar); if(settings.disableToolbar) - mToolbar.setVisibility(GONE); + mToolbar.setVisibility(INVISIBLE); mViewPager = (ViewPager) findViewById(R.id.viewPager); mViewPager.addOnPageChangeListener(this); diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index e1d4d26d..1785e5e1 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -23,6 +23,7 @@ app:viewpager_displayToolbarWhenSwipe="true" app:viewpager_transparentToolbar="true" app:viewpager_animatedHeaderImage="true" + app:viewpager_disableToolbar="true" /> From 50097ae7e345e60929395381fd59ce5fbc042da0 Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 28 Jul 2015 16:43:52 +0200 Subject: [PATCH 13/78] updated README --- README.md | 2 ++ sample/src/main/res/layout/activity_main.xml | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 139e959e..a628a7a3 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ Add MaterialViewPager to your activity's layout app:viewpager_displayToolbarWhenSwipe="true" app:viewpager_transparentToolbar="true" app:viewpager_animatedHeaderImage="true" + app:viewpager_disableToolbar="false" + /> ``` diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 1785e5e1..e1d4d26d 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -23,7 +23,6 @@ app:viewpager_displayToolbarWhenSwipe="true" app:viewpager_transparentToolbar="true" app:viewpager_animatedHeaderImage="true" - app:viewpager_disableToolbar="true" /> From 53e1f5162ba10314c91e751a3d9fe05473b3cfd1 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 19:32:53 +0200 Subject: [PATCH 14/78] v1.1.0 --- .idea/gradle.xml | 2 +- .idea/misc.xml | 2 +- build.gradle | 2 +- materialviewpager/materialviewpager.iml | 6 +++--- .../florent37/materialviewpager/MaterialViewPager.java | 2 +- sample/sample.iml | 4 ++-- .../florent37/materialviewpager/sample/MainActivity.java | 2 -- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index eaf26b7e..cf3ca11f 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -5,7 +5,7 @@ - + diff --git a/build.gradle b/build.gradle index c99f1520..cd82da0b 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ ext{ SUPPORT_VERSION='22.2.1' - MAVEN_VERSION='1.0.9' + MAVEN_VERSION='1.1.0' } allprojects { diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index a4b4b0b7..536f6057 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -1,5 +1,5 @@ - + @@ -96,15 +96,15 @@ - + - + diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 06159421..a1534b65 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -316,7 +316,7 @@ public ViewGroup getHeaderBackgroundContainer() { //region ViewPagerOnPageListener - int lastPosition = 0; + int lastPosition = -1; @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { diff --git a/sample/sample.iml b/sample/sample.iml index 2e83f4bf..3dc3207d 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -82,7 +82,7 @@ - + @@ -91,8 +91,8 @@ - + diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java index 293b91d2..2d128aa0 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java @@ -124,8 +124,6 @@ public HeaderDesign getHeaderDesign(int page) { mViewPager.getViewPager().setOffscreenPageLimit(mViewPager.getViewPager().getAdapter().getCount()); mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager()); - - mViewPager.getViewPager().setCurrentItem(1); } @Override From 40be40abb29d06f537a99f7bb78c63088fa584da Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 19:40:43 +0200 Subject: [PATCH 15/78] v1.1.0, fix for header refresh --- .../florent37/materialviewpager/MaterialViewPager.java | 6 ++---- .../materialviewpager/MaterialViewPagerAnimator.java | 6 +++--- .../materialviewpager/MaterialViewPagerHelper.java | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index a1534b65..ace1c6b8 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -23,10 +23,10 @@ /** * Created by florentchampigny on 28/04/15. - *

+ * * The main class of MaterialViewPager * To use in an xml layout with attributes viewpager_* - *

+ * * Display a preview with header, actual logo and fake cells */ public class MaterialViewPager extends FrameLayout implements ViewPager.OnPageChangeListener { @@ -229,8 +229,6 @@ public PagerSlidingTabStrip getPagerTitleStrip() { /** * Retrieve the displayed toolbar - * - * @return the displayed toolbar */ public void setToolbar(Toolbar toolbar) { mToolbar=toolbar; diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 63448013..4eea5b28 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -34,13 +34,13 @@ /** * Created by florentchampigny on 24/04/15. - *

+ * * Listen to Scrollable inside MaterialViewPager * When notified scroll, dispatch the current scroll to other scrollable - *

+ * * Note : didn't want to translate the MaterialViewPager or intercept Scroll, * so added a ViewPager with scrollables containing a transparent placeholder on top - *

+ * * When scroll, animate the MaterialViewPager Header (toolbar, logo, color ...) */ public class MaterialViewPagerAnimator { diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java index dd22c42e..2670c9be 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java @@ -17,7 +17,7 @@ /** * Created by florentchampigny on 25/04/15. - *

+ * * 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 @@ -165,7 +165,7 @@ public void run() { } /** - * Prepare the webview, set Invisible & transparent background + * Prepare the webview, set Invisible and transparent background * Must call injectHeader next */ public static void preLoadInjectHeader(WebView mWebView) { From a8212e23ea4b68571092b5f5adb87ba32e8a3e41 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 20:41:28 +0200 Subject: [PATCH 16/78] orientation change fix --- .../MaterialViewPagerAnimator.java | 2 +- .../MaterialViewPagerHeader.java | 12 ++--- sample/sample.iml | 45 +++++++++++-------- sample/src/main/res/layout/activity_main.xml | 12 ----- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 4eea5b28..add8611e 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -182,7 +182,7 @@ public void onMaterialScrolled(Object source, float yOffset) { float percent = yOffset / scrollMax; - if(initialDistance == -1) + if(initialDistance == -1 || initialDistance == 0) initialDistance = mHeader.mPagerSlidingTabStrip.getTop() - mHeader.toolbar.getBottom(); //distance between pager & toolbar diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java index 86d8f634..67a9966a 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java @@ -1,11 +1,9 @@ package com.github.florent37.materialviewpager; import android.content.Context; -import android.graphics.Rect; import android.support.v7.widget.Toolbar; import android.view.View; import android.view.ViewTreeObserver; -import android.view.Window; import com.nineoldandroids.view.ViewHelper; @@ -41,7 +39,7 @@ public class MaterialViewPagerHeader { public float originalTitleX; public float finalScale; - private MaterialViewPagerHeader(Toolbar toolbar){ + private MaterialViewPagerHeader(Toolbar toolbar) { this.toolbar = toolbar; this.context = toolbar.getContext(); this.toolbarLayout = (View) toolbar.getParent(); @@ -86,7 +84,7 @@ public MaterialViewPagerHeader withToolbarLayoutBackground(View toolbarLayoutBac return this; } - public int getStatusBarHeight(Context context){ + public int getStatusBarHeight(Context context) { int result = 0; int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { @@ -99,9 +97,13 @@ public MaterialViewPagerHeader withLogo(View logo) { this.mLogo = logo; //when logo get a height, initialise initial & final logo positions - toolbar.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + toolbarLayout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { + //rotation fix, if not set, originalTitleY = Na + ViewHelper.setTranslationY(mLogo,0); + ViewHelper.setTranslationX(mLogo, 0); + originalTitleY = ViewHelper.getY(mLogo); originalTitleX = ViewHelper.getX(mLogo); diff --git a/sample/sample.iml b/sample/sample.iml index 3dc3207d..d5bf43b3 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -8,12 +8,15 @@ - - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index e1d4d26d..072f001f 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -28,16 +28,4 @@ - - - - - - \ No newline at end of file From 202ac5bffd083f94c5142ef870aba71dc4c4dd69 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 21:04:28 +0200 Subject: [PATCH 17/78] orientation change fix --- .../MaterialViewPagerAnimator.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index add8611e..e2791c9b 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -2,6 +2,8 @@ import android.content.Context; import android.os.Build; +import android.os.Handler; +import android.os.Looper; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.View; @@ -117,7 +119,7 @@ public MaterialViewPagerAnimator(MaterialViewPager materialViewPager) { * @param source * @param yOffset */ - private void dispatchScrollOffset(Object source, float yOffset) { + protected void dispatchScrollOffset(Object source, float yOffset) { if (scrollViewList != null) { for (Object scroll : scrollViewList) { @@ -154,6 +156,10 @@ private void setScrollOffset(Object scroll, float yOffset) { */ public void 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; @@ -182,14 +188,14 @@ public void onMaterialScrolled(Object source, float yOffset) { float percent = yOffset / scrollMax; - if(initialDistance == -1 || initialDistance == 0) - initialDistance = mHeader.mPagerSlidingTabStrip.getTop() - mHeader.toolbar.getBottom(); - //distance between pager & toolbar float newDistance = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom(); percent = 1 - newDistance/initialDistance; + if(Float.isNaN(percent)) //fix for orientation change + return; + percent = minMax(0, percent, 1); { @@ -608,9 +614,10 @@ public void onUpOrCancelMotionEvent(ScrollState scrollState) { //endregion - public void restoreScroll(float scroll, MaterialViewPagerSettings settings) { - this.settings = settings; + public void restoreScroll(final float scroll, MaterialViewPagerSettings settings) { onMaterialScrolled(null, scroll); + //this.settings = settings; + onMaterialScrolled(null, 0); } public void onViewPagerPageChanged() { From 03852134d5a11575c73fa7486b0f3ff556edf44e Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 21:08:12 +0200 Subject: [PATCH 18/78] orientation change fix --- .../MaterialViewPagerAnimator.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index e2791c9b..0e30991d 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -154,7 +154,7 @@ private void setScrollOffset(Object scroll, float yOffset) { * @param source the scroller * @param yOffset the scroller current yOffset */ - public void onMaterialScrolled(Object source, float yOffset) { + public boolean onMaterialScrolled(Object source, float yOffset) { if(initialDistance == -1 || initialDistance == 0) { initialDistance = mHeader.mPagerSlidingTabStrip.getTop() - mHeader.toolbar.getBottom(); @@ -162,7 +162,7 @@ public void onMaterialScrolled(Object source, float yOffset) { //only if yOffset changed if (yOffset == lastYOffset) - return; + return false; float scrollTop = -yOffset; @@ -194,7 +194,7 @@ public void onMaterialScrolled(Object source, float yOffset) { percent = 1 - newDistance/initialDistance; if(Float.isNaN(percent)) //fix for orientation change - return; + return false; percent = minMax(0, percent, 1); { @@ -271,6 +271,8 @@ else if (headerAnimator instanceof android.animation.ObjectAnimator) } lastYOffset = yOffset; + + return true; } private void scrollUp(float yOffset) { @@ -614,10 +616,16 @@ public void onUpOrCancelMotionEvent(ScrollState scrollState) { //endregion - public void restoreScroll(final float scroll, MaterialViewPagerSettings settings) { - onMaterialScrolled(null, scroll); - //this.settings = settings; - onMaterialScrolled(null, 0); + public void restoreScroll(final float scroll, final MaterialViewPagerSettings settings) { + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + if(!onMaterialScrolled(null, 0)){ + restoreScroll(scroll,settings); + } + } + },100); + } public void onViewPagerPageChanged() { From 4d58016ee5a5594de1e8822502c0cb5124103c5a Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 21:09:45 +0200 Subject: [PATCH 19/78] orientation change fix --- .../florent37/materialviewpager/MaterialViewPagerAnimator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 0e30991d..1ae43504 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -617,10 +617,11 @@ public void onUpOrCancelMotionEvent(ScrollState scrollState) { //endregion public 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, 0)){ + if(!onMaterialScrolled(null, scroll)){ restoreScroll(scroll,settings); } } From d6b57ebd76bf2c1ace02190c922098c3aa309552 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 21:12:48 +0200 Subject: [PATCH 20/78] updated README --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a628a7a3..316e6e6e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.co In your module [![Download](https://api.bintray.com/packages/florent37/maven/MaterialViewPager/images/download.svg)](https://bintray.com/florent37/maven/MaterialViewPager/_latestVersion) ```groovy -compile ('com.github.florent37:materialviewpager:1.0.8@aar'){ +compile ('com.github.florent37:materialviewpager:1.1.0@aar'){ transitive = true } ``` @@ -501,6 +501,10 @@ And must include @layout/material_view_pager_placeholder as first child #CHANGELOG +##1.1.0 +- orientation change fix +- header image display fix + ##1.0.8 - added attribute viewpager_disableToolbar From 601421593a6dc4e7cd85e5e6c8685aaadce20ea5 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 21:18:47 +0200 Subject: [PATCH 21/78] fix headerclickable --- .../res/layout/material_view_pager_layout.xml | 4 +++- .../sample/MainActivity.java | 22 +++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/materialviewpager/src/main/res/layout/material_view_pager_layout.xml b/materialviewpager/src/main/res/layout/material_view_pager_layout.xml index 45efe6f1..a62bf08f 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_layout.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_layout.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:clickable="true" android:orientation="vertical"> + android:layout_height="wrap_content" + android:clickable="true"> Date: Fri, 31 Jul 2015 21:21:09 +0200 Subject: [PATCH 22/78] updated README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 316e6e6e..486924ba 100644 --- a/README.md +++ b/README.md @@ -504,6 +504,7 @@ And must include @layout/material_view_pager_placeholder as first child ##1.1.0 - orientation change fix - header image display fix +- elements on header are now clickable ##1.0.8 - added attribute viewpager_disableToolbar From 9a22e046e5857779f6f55c0adc33516f88e21f86 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 21:45:52 +0200 Subject: [PATCH 23/78] updated README --- README.md | 2 +- sample/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 486924ba..6f8d1117 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Material Design ViewPager easy to use library Android app on Google Play -You can find a sample APK : [Link](https://github.com/florent37/MaterialViewPager/releases/download/1.0.3/sample-debug.apk) +You can find a sample APK : [Link](https://github.com/florent37/MaterialViewPager/releases/download/1.1.0/sample-debug.apk) And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.com/watch?v=r95Tt6AS18c) diff --git a/sample/build.gradle b/sample/build.gradle index 996106b9..d84a994d 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -24,7 +24,7 @@ android { defaultConfig { minSdkVersion project.ANDROID_BUILD_MIN_SDK_VERSION targetSdkVersion project.ANDROID_BUILD_TARGET_SDK_VERSION - versionCode 3 + versionCode 4 versionName "1.0" } From bfeea8a26f5db3459769e338272a215961413dd5 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 23:43:03 +0200 Subject: [PATCH 24/78] notifyHeaderChanged --- materialviewpager/materialviewpager.iml | 3 --- .../florent37/materialviewpager/MaterialViewPager.java | 6 ++++++ sample/sample.iml | 2 +- .../florent37/materialviewpager/sample/MainActivity.java | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index 536f6057..803f1e2c 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -65,7 +65,6 @@ - @@ -91,9 +90,7 @@ - - diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index ace1c6b8..1ba8460d 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -327,6 +327,12 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse } } + public void notifyHeaderChanged(){ + int position = lastPosition; + lastPosition = -1; + onPageSelected(position); + } + @Override public void onPageSelected(int position) { if (position == lastPosition || listener == null) diff --git a/sample/sample.iml b/sample/sample.iml index d5bf43b3..ace1eb41 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -100,8 +100,8 @@ - + diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java index 86b661e2..b32e32c7 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java @@ -132,6 +132,7 @@ public HeaderDesign getHeaderDesign(int page) { 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(); } }); From 0145c61886aab000ba57e605fd2be37a06698942 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 31 Jul 2015 23:44:39 +0200 Subject: [PATCH 25/78] updated README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6f8d1117..b53ae9f3 100644 --- a/README.md +++ b/README.md @@ -505,6 +505,7 @@ And must include @layout/material_view_pager_placeholder as first child - orientation change fix - header image display fix - elements on header are now clickable +- notifyHeaderChanged ##1.0.8 - added attribute viewpager_disableToolbar From 68e9ab7a047ee35f1f062f085483dcc8984fe365 Mon Sep 17 00:00:00 2001 From: Florent CHAMPIGNY Date: Tue, 4 Aug 2015 01:52:10 +0200 Subject: [PATCH 26/78] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b53ae9f3..3a7f4d6a 100644 --- a/README.md +++ b/README.md @@ -584,6 +584,7 @@ Tell me if you're using my library in your application, I'll share it in this RE #Credits Author: Florent Champigny +www.florentchampigny.com/ Follow me on Google+ Date: Tue, 4 Aug 2015 01:58:20 +0200 Subject: [PATCH 27/78] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a7f4d6a..b2ed89e1 100644 --- a/README.md +++ b/README.md @@ -583,8 +583,7 @@ Tell me if you're using my library in your application, I'll share it in this RE #Credits -Author: Florent Champigny -www.florentchampigny.com/ +Author: Florent Champigny www.florentchampigny.com/ Follow me on Google+ Date: Tue, 4 Aug 2015 20:14:05 +0200 Subject: [PATCH 28/78] added adapter notify() --- .idea/gradle.xml | 1 + .idea/libraries/blurry_0_0_3.xml | 10 ++++++++++ .idea/libraries/carpaccio_0_0_1.xml | 10 ++++++++++ .idea/libraries/circleimageview_1_3_0.xml | 13 +++++++++++++ .idea/libraries/materialimageloading_1_0_1.xml | 10 ++++++++++ .idea/modules.xml | 1 + materialviewpager/materialviewpager.iml | 2 +- .../adapter/RecyclerViewMaterialAdapter.java | 18 ++++++++++++++++++ settings.gradle | 2 +- 9 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 .idea/libraries/blurry_0_0_3.xml create mode 100644 .idea/libraries/carpaccio_0_0_1.xml create mode 100644 .idea/libraries/circleimageview_1_3_0.xml create mode 100644 .idea/libraries/materialimageloading_1_0_1.xml diff --git a/.idea/gradle.xml b/.idea/gradle.xml index cf3ca11f..be8a4b2c 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,6 +10,7 @@ diff --git a/.idea/libraries/blurry_0_0_3.xml b/.idea/libraries/blurry_0_0_3.xml new file mode 100644 index 00000000..be118801 --- /dev/null +++ b/.idea/libraries/blurry_0_0_3.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/carpaccio_0_0_1.xml b/.idea/libraries/carpaccio_0_0_1.xml new file mode 100644 index 00000000..e153026d --- /dev/null +++ b/.idea/libraries/carpaccio_0_0_1.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/circleimageview_1_3_0.xml b/.idea/libraries/circleimageview_1_3_0.xml new file mode 100644 index 00000000..f190e249 --- /dev/null +++ b/.idea/libraries/circleimageview_1_3_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/materialimageloading_1_0_1.xml b/.idea/libraries/materialimageloading_1_0_1.xml new file mode 100644 index 00000000..8db6b2f6 --- /dev/null +++ b/.idea/libraries/materialimageloading_1_0_1.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 80cdbf86..d104611d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,6 +4,7 @@ + diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index 803f1e2c..a1c31cc1 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -100,8 +100,8 @@ - + diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java index ce18162d..0fd93365 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java @@ -29,6 +29,8 @@ public class RecyclerViewMaterialAdapter extends RecyclerView.Adapter Date: Tue, 4 Aug 2015 20:15:26 +0200 Subject: [PATCH 29/78] added carpaccio support --- materialviewpagercontroller/.gitignore | 1 + materialviewpagercontroller/build.gradle | 131 ++++++++++++++++++ .../materialviewpagercontroller.iml | 110 +++++++++++++++ .../proguard-rules.pro | 17 +++ .../controllers/ApplicationTest.java | 13 ++ .../src/main/AndroidManifest.xml | 9 ++ .../MaterialViewPagerViewController.java | 88 ++++++++++++ .../src/main/res/values/strings.xml | 3 + sample/build.gradle | 1 + sample/sample.iml | 1 + sample/src/main/AndroidManifest.xml | 3 +- .../sample/MainActivity.java | 7 +- .../CarpaccioRecyclerViewFragment.java | 53 +++++++ .../sample/fragment/RecyclerViewFragment.java | 9 +- .../fragment_recyclerview_carpaccio.xml | 17 +++ 15 files changed, 456 insertions(+), 7 deletions(-) create mode 100644 materialviewpagercontroller/.gitignore create mode 100644 materialviewpagercontroller/build.gradle create mode 100644 materialviewpagercontroller/materialviewpagercontroller.iml create mode 100644 materialviewpagercontroller/proguard-rules.pro create mode 100644 materialviewpagercontroller/src/androidTest/java/com/github/florent37/materialviewpager/controllers/ApplicationTest.java create mode 100644 materialviewpagercontroller/src/main/AndroidManifest.xml create mode 100644 materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/MaterialViewPagerViewController.java create mode 100644 materialviewpagercontroller/src/main/res/values/strings.xml create mode 100644 sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/CarpaccioRecyclerViewFragment.java create mode 100644 sample/src/main/res/layout/fragment_recyclerview_carpaccio.xml diff --git a/materialviewpagercontroller/.gitignore b/materialviewpagercontroller/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/materialviewpagercontroller/.gitignore @@ -0,0 +1 @@ +/build diff --git a/materialviewpagercontroller/build.gradle b/materialviewpagercontroller/build.gradle new file mode 100644 index 00000000..8a0cbff1 --- /dev/null +++ b/materialviewpagercontroller/build.gradle @@ -0,0 +1,131 @@ +apply plugin: 'com.android.library' + +version = project.MAVEN_VERSION + +android { + compileSdkVersion project.ANDROID_BUILD_SDK_VERSION + buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION + + defaultConfig { + minSdkVersion project.ANDROID_BUILD_MIN_SDK_VERSION + targetSdkVersion project.ANDROID_BUILD_TARGET_SDK_VERSION + 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:22.2.1' + + compile ('com.github.florent37:carpaccio:0.0.1@aar') { + transitive = true + } + + compile project (":materialviewpager") +} + + +def siteUrl = 'https://github.com/florent37/MaterialViewPager' // Homepage URL of the library +def gitUrl = 'https://github.com/florent37/MaterialViewPager.git' // Git repository URL +group = "com.github.florent37" // Maven Group ID for the artifact + + +install { + repositories.mavenInstaller { + // This generates POM.xml with proper parameters + pom { + project { + packaging 'aar' + + // Add your description here + name 'MaterialViewPagerContoller' + description = '' + url siteUrl + + // Set your license + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id 'florent37' + name 'Florent Champigny' + email 'champigny.florent@gmail.com' + } + } + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + + } + } + } + } +} + +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 +} + +Properties properties = new Properties() +File f = new File("local.properties") +if(f.exists()) { + properties.load(project.rootProject.file('local.properties').newDataInputStream()) +} + +// https://github.com/bintray/gradle-bintray-plugin +bintray { + + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + pkg { + repo = "maven" + // it is the name that appears in bintray when logged + name = "MaterialViewPagerContoller" + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = ["Apache-2.0"] + publish = true + version { + gpg { + sign = true //Determines whether to GPG sign the files. The default is false + passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing' + } +// mavenCentralSync { +// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central. +// user = properties.getProperty("bintray.oss.user") //OSS user token +// password = properties.getProperty("bintray.oss.password") //OSS user password +// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually. +// } + } + } +} diff --git a/materialviewpagercontroller/materialviewpagercontroller.iml b/materialviewpagercontroller/materialviewpagercontroller.iml new file mode 100644 index 00000000..01d10d22 --- /dev/null +++ b/materialviewpagercontroller/materialviewpagercontroller.iml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/materialviewpagercontroller/proguard-rules.pro b/materialviewpagercontroller/proguard-rules.pro new file mode 100644 index 00000000..7c7c2a3b --- /dev/null +++ b/materialviewpagercontroller/proguard-rules.pro @@ -0,0 +1,17 @@ +# 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 *; +#} diff --git a/materialviewpagercontroller/src/androidTest/java/com/github/florent37/materialviewpager/controllers/ApplicationTest.java b/materialviewpagercontroller/src/androidTest/java/com/github/florent37/materialviewpager/controllers/ApplicationTest.java new file mode 100644 index 00000000..d0260fd4 --- /dev/null +++ b/materialviewpagercontroller/src/androidTest/java/com/github/florent37/materialviewpager/controllers/ApplicationTest.java @@ -0,0 +1,13 @@ +package com.github.florent37.materialviewpager.controllers; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/materialviewpagercontroller/src/main/AndroidManifest.xml b/materialviewpagercontroller/src/main/AndroidManifest.xml new file mode 100644 index 00000000..eff9abd4 --- /dev/null +++ b/materialviewpagercontroller/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/MaterialViewPagerViewController.java b/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/MaterialViewPagerViewController.java new file mode 100644 index 00000000..b648d70a --- /dev/null +++ b/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/MaterialViewPagerViewController.java @@ -0,0 +1,88 @@ +package com.github.florent37.materialviewpager.controllers; + +import android.app.Activity; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.github.florent37.carpaccio.Carpaccio; +import com.github.florent37.carpaccio.CarpaccioHelper; +import com.github.florent37.carpaccio.controllers.CommonViewController; +import com.github.florent37.carpaccio.controllers.adapter.CarpaccioRecyclerViewAdapter; +import com.github.florent37.carpaccio.controllers.adapter.Holder; +import com.github.florent37.materialviewpager.MaterialViewPagerHelper; + +import static com.github.florent37.carpaccio.controllers.ControllerHelper.getLayoutIdentifierFromString; + +/** + * Created by florentchampigny on 04/08/15. + */ +public class MaterialViewPagerViewController { + + protected int recyclerColumnCount = 1; + + public void materialColumn(View view, int number) { + if (view instanceof RecyclerView) { + recyclerColumnCount = number; + + RecyclerView recyclerView = (RecyclerView) view; + recyclerView.setLayoutManager(new GridLayoutManager(view.getContext(), number)); + } + } + + public void materialAdapter(View view, String mappedName, String layoutName) { + final int layoutResId = getLayoutIdentifierFromString(view.getContext(), layoutName); + final Carpaccio carpaccio = CarpaccioHelper.findParentCarpaccio(view); + if (carpaccio != null && layoutResId != -1 && view instanceof RecyclerView) { + CommonViewController commonViewController = new CommonViewController(); + + MaterialCarpaccioRecyclerViewAdapter adapter = new MaterialCarpaccioRecyclerViewAdapter(recyclerColumnCount, carpaccio, layoutResId, mappedName); + + commonViewController.setAdapterForRecyclerView(view, mappedName, layoutName, adapter); + + MaterialViewPagerHelper.registerRecyclerView((Activity) view.getContext(), (RecyclerView) view, null); + } + } + + public class MaterialCarpaccioRecyclerViewAdapter extends CarpaccioRecyclerViewAdapter { + + //the constants value of the header view + static final int TYPE_PLACEHOLDER = Integer.MIN_VALUE; + + //the size taken by the header + protected int mPlaceholderSize = 1; + + public MaterialCarpaccioRecyclerViewAdapter(int mPlaceholderSize, Carpaccio carpaccio, int layoutResId, String mappedName) { + super(carpaccio, layoutResId, mappedName); + this.mPlaceholderSize = mPlaceholderSize; + } + + public int getItemViewType(int position) { + if (position == 0) + return TYPE_PLACEHOLDER; + return super.getItemViewType(position); + } + + @Override + public int getItemCount() { + return super.getItemCount() + mPlaceholderSize; + } + + @Override + public Object getItemForRow(View view, int position) { + return super.getItemForRow(view, position - mPlaceholderSize); + } + + @Override + public Holder onCreateViewHolder(ViewGroup parent, int viewType) { + if (viewType == TYPE_PLACEHOLDER) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.material_view_pager_placeholder, parent, false); + return new Holder(view); + } else + return super.onCreateViewHolder(parent, viewType); + } + } + +} diff --git a/materialviewpagercontroller/src/main/res/values/strings.xml b/materialviewpagercontroller/src/main/res/values/strings.xml new file mode 100644 index 00000000..8b714d54 --- /dev/null +++ b/materialviewpagercontroller/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + MaterialViewPagerController + diff --git a/sample/build.gradle b/sample/build.gradle index d84a994d..8d045952 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -74,4 +74,5 @@ dependencies { } compile project(':materialviewpager') + compile project(':materialviewpagercontroller') } diff --git a/sample/sample.iml b/sample/sample.iml index ace1eb41..8c185a47 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -105,6 +105,7 @@ + \ No newline at end of file diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index c33df6ff..e1274423 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + package="com.github.florent37.materialviewpager.sample" + > diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java index b32e32c7..5b2206b2 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java @@ -15,6 +15,7 @@ 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.CarpaccioRecyclerViewFragment; import com.github.florent37.materialviewpager.sample.fragment.RecyclerViewFragment; import com.github.florent37.materialviewpager.sample.fragment.ScrollFragment; @@ -66,12 +67,12 @@ public Fragment getItem(int position) { switch (position % 4) { //case 0: // return RecyclerViewFragment.newInstance(); - case 1: - return RecyclerViewFragment.newInstance(); + //case 1: + // return RecyclerViewFragment.newInstance(); //case 2: // return WebViewFragment.newInstance(); default: - return ScrollFragment.newInstance(); + return CarpaccioRecyclerViewFragment.newInstance(); } } diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/CarpaccioRecyclerViewFragment.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/CarpaccioRecyclerViewFragment.java new file mode 100644 index 00000000..302db4a7 --- /dev/null +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/CarpaccioRecyclerViewFragment.java @@ -0,0 +1,53 @@ +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.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +import com.github.florent37.carpaccio.Carpaccio; +import com.github.florent37.carpaccio.controllers.adapter.OnItemClickListener; +import com.github.florent37.materialviewpager.sample.R; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by florentchampigny on 24/04/15. + */ +public class CarpaccioRecyclerViewFragment extends Fragment { + + private static final int ITEM_COUNT = 100; + private List mContentItems = new ArrayList<>(); + Carpaccio carpaccio; + + public static CarpaccioRecyclerViewFragment newInstance() { + return new CarpaccioRecyclerViewFragment(); + } + + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_recyclerview_carpaccio, container, false); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + carpaccio = (Carpaccio) view.findViewById(R.id.carpaccio); + + for (int i = 0; i < ITEM_COUNT; ++i) + mContentItems.add(new Object()); + + carpaccio.mapList("card",mContentItems); + carpaccio.onItemClick("card", new OnItemClickListener() { + @Override + public void onItemClick(Object o, int i, View view) { + Toast.makeText(getActivity(),"position :"+i,Toast.LENGTH_SHORT).show(); + } + }); + } +} diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/RecyclerViewFragment.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/RecyclerViewFragment.java index 9de9e2a8..b035ff99 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/RecyclerViewFragment.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/RecyclerViewFragment.java @@ -46,12 +46,15 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setHasFixedSize(true); - for (int i = 0; i < ITEM_COUNT; ++i) - mContentItems.add(new Object()); - mAdapter = new RecyclerViewMaterialAdapter(new TestRecyclerViewAdapter(mContentItems)); mRecyclerView.setAdapter(mAdapter); + { + for (int i = 0; i < ITEM_COUNT; ++i) + mContentItems.add(new Object()); + mAdapter.notifyDataSetChanged(); + } + MaterialViewPagerHelper.registerRecyclerView(getActivity(), mRecyclerView, null); } } diff --git a/sample/src/main/res/layout/fragment_recyclerview_carpaccio.xml b/sample/src/main/res/layout/fragment_recyclerview_carpaccio.xml new file mode 100644 index 00000000..8da9562b --- /dev/null +++ b/sample/src/main/res/layout/fragment_recyclerview_carpaccio.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file From 4f7bfa96f0108528411623f073532df1d5f46e04 Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 4 Aug 2015 21:49:32 +0200 Subject: [PATCH 30/78] updated README --- ...arpaccio_0_0_1.xml => carpaccio_1_0_1.xml} | 6 ++--- .idea/libraries/materialviewpager_1_1_0.xml | 13 +++++++++++ build.gradle | 2 +- materialviewpager/materialviewpager.iml | 5 ++++- materialviewpagercontroller/build.gradle | 8 +++++-- .../materialviewpagercontroller.iml | 22 ++++++++++++------- ...iewController.java => ViewController.java} | 15 +++++++++---- .../CarpaccioRecyclerViewFragment.java | 2 +- .../fragment_recyclerview_carpaccio.xml | 5 ++++- 9 files changed, 57 insertions(+), 21 deletions(-) rename .idea/libraries/{carpaccio_0_0_1.xml => carpaccio_1_0_1.xml} (79%) create mode 100644 .idea/libraries/materialviewpager_1_1_0.xml rename materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/{MaterialViewPagerViewController.java => ViewController.java} (88%) diff --git a/.idea/libraries/carpaccio_0_0_1.xml b/.idea/libraries/carpaccio_1_0_1.xml similarity index 79% rename from .idea/libraries/carpaccio_0_0_1.xml rename to .idea/libraries/carpaccio_1_0_1.xml index e153026d..9b68adf1 100644 --- a/.idea/libraries/carpaccio_0_0_1.xml +++ b/.idea/libraries/carpaccio_1_0_1.xml @@ -1,8 +1,8 @@ - + - - + + diff --git a/.idea/libraries/materialviewpager_1_1_0.xml b/.idea/libraries/materialviewpager_1_1_0.xml new file mode 100644 index 00000000..312c3d3f --- /dev/null +++ b/.idea/libraries/materialviewpager_1_1_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index cd82da0b..ad085511 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ ext{ SUPPORT_VERSION='22.2.1' - MAVEN_VERSION='1.1.0' + MAVEN_VERSION='1.1.1' } allprojects { diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index a1c31cc1..43ce5354 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -1,5 +1,5 @@ - + @@ -65,6 +65,7 @@ + @@ -90,7 +91,9 @@ + + diff --git a/materialviewpagercontroller/build.gradle b/materialviewpagercontroller/build.gradle index 8a0cbff1..b025c3be 100644 --- a/materialviewpagercontroller/build.gradle +++ b/materialviewpagercontroller/build.gradle @@ -1,4 +1,6 @@ apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'com.jfrog.bintray' version = project.MAVEN_VERSION @@ -24,11 +26,13 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.1' - compile ('com.github.florent37:carpaccio:0.0.1@aar') { + compile ('com.github.florent37:carpaccio:1.0.1@aar') { transitive = true } - compile project (":materialviewpager") + compile ('com.github.florent37:materialviewpager:+@aar') { + transitive = true + } } diff --git a/materialviewpagercontroller/materialviewpagercontroller.iml b/materialviewpagercontroller/materialviewpagercontroller.iml index 01d10d22..4d2c3362 100644 --- a/materialviewpagercontroller/materialviewpagercontroller.iml +++ b/materialviewpagercontroller/materialviewpagercontroller.iml @@ -1,5 +1,5 @@ - + @@ -65,6 +65,7 @@ + @@ -72,8 +73,9 @@ - + + @@ -88,23 +90,27 @@ + + - - - + - + + + + + + + - - \ No newline at end of file diff --git a/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/MaterialViewPagerViewController.java b/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/ViewController.java similarity index 88% rename from materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/MaterialViewPagerViewController.java rename to materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/ViewController.java index b648d70a..509d6b5b 100644 --- a/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/MaterialViewPagerViewController.java +++ b/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/ViewController.java @@ -19,11 +19,11 @@ /** * Created by florentchampigny on 04/08/15. */ -public class MaterialViewPagerViewController { +public class ViewController { protected int recyclerColumnCount = 1; - public void materialColumn(View view, int number) { + public void materialColumns(View view, int number) { if (view instanceof RecyclerView) { recyclerColumnCount = number; @@ -67,12 +67,19 @@ public int getItemViewType(int position) { @Override public int getItemCount() { - return super.getItemCount() + mPlaceholderSize; + int itemCount = super.getItemCount(); + if( itemCount > 0) + return itemCount+mPlaceholderSize; + else + return 0; } @Override public Object getItemForRow(View view, int position) { - return super.getItemForRow(view, position - mPlaceholderSize); + if(position > mPlaceholderSize) { + return super.getItemForRow(view, position - mPlaceholderSize); + }else + return null; } @Override diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/CarpaccioRecyclerViewFragment.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/CarpaccioRecyclerViewFragment.java index 302db4a7..602c224b 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/CarpaccioRecyclerViewFragment.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/fragment/CarpaccioRecyclerViewFragment.java @@ -21,7 +21,7 @@ */ public class CarpaccioRecyclerViewFragment extends Fragment { - private static final int ITEM_COUNT = 100; + private static int ITEM_COUNT = 0; private List mContentItems = new ArrayList<>(); Carpaccio carpaccio; diff --git a/sample/src/main/res/layout/fragment_recyclerview_carpaccio.xml b/sample/src/main/res/layout/fragment_recyclerview_carpaccio.xml index 8da9562b..fc9eb43d 100644 --- a/sample/src/main/res/layout/fragment_recyclerview_carpaccio.xml +++ b/sample/src/main/res/layout/fragment_recyclerview_carpaccio.xml @@ -12,6 +12,9 @@ android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" - android:tag="materialAdapter(card,R.layout.list_item_card_small)" /> + android:tag=" + materialColumns(2); + materialAdapter(card,R.layout.list_item_card_small); + " /> \ No newline at end of file From 0f8d9459fb351856f28c5bed838ecdcb0d082132 Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 4 Aug 2015 21:55:29 +0200 Subject: [PATCH 31/78] updated README --- .../controllers/ViewController.java | 95 ------------------- 1 file changed, 95 deletions(-) delete mode 100644 materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/ViewController.java diff --git a/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/ViewController.java b/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/ViewController.java deleted file mode 100644 index 509d6b5b..00000000 --- a/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/controllers/ViewController.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.github.florent37.materialviewpager.controllers; - -import android.app.Activity; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.github.florent37.carpaccio.Carpaccio; -import com.github.florent37.carpaccio.CarpaccioHelper; -import com.github.florent37.carpaccio.controllers.CommonViewController; -import com.github.florent37.carpaccio.controllers.adapter.CarpaccioRecyclerViewAdapter; -import com.github.florent37.carpaccio.controllers.adapter.Holder; -import com.github.florent37.materialviewpager.MaterialViewPagerHelper; - -import static com.github.florent37.carpaccio.controllers.ControllerHelper.getLayoutIdentifierFromString; - -/** - * Created by florentchampigny on 04/08/15. - */ -public class ViewController { - - protected int recyclerColumnCount = 1; - - public void materialColumns(View view, int number) { - if (view instanceof RecyclerView) { - recyclerColumnCount = number; - - RecyclerView recyclerView = (RecyclerView) view; - recyclerView.setLayoutManager(new GridLayoutManager(view.getContext(), number)); - } - } - - public void materialAdapter(View view, String mappedName, String layoutName) { - final int layoutResId = getLayoutIdentifierFromString(view.getContext(), layoutName); - final Carpaccio carpaccio = CarpaccioHelper.findParentCarpaccio(view); - if (carpaccio != null && layoutResId != -1 && view instanceof RecyclerView) { - CommonViewController commonViewController = new CommonViewController(); - - MaterialCarpaccioRecyclerViewAdapter adapter = new MaterialCarpaccioRecyclerViewAdapter(recyclerColumnCount, carpaccio, layoutResId, mappedName); - - commonViewController.setAdapterForRecyclerView(view, mappedName, layoutName, adapter); - - MaterialViewPagerHelper.registerRecyclerView((Activity) view.getContext(), (RecyclerView) view, null); - } - } - - public class MaterialCarpaccioRecyclerViewAdapter extends CarpaccioRecyclerViewAdapter { - - //the constants value of the header view - static final int TYPE_PLACEHOLDER = Integer.MIN_VALUE; - - //the size taken by the header - protected int mPlaceholderSize = 1; - - public MaterialCarpaccioRecyclerViewAdapter(int mPlaceholderSize, Carpaccio carpaccio, int layoutResId, String mappedName) { - super(carpaccio, layoutResId, mappedName); - this.mPlaceholderSize = mPlaceholderSize; - } - - public int getItemViewType(int position) { - if (position == 0) - return TYPE_PLACEHOLDER; - return super.getItemViewType(position); - } - - @Override - public int getItemCount() { - int itemCount = super.getItemCount(); - if( itemCount > 0) - return itemCount+mPlaceholderSize; - else - return 0; - } - - @Override - public Object getItemForRow(View view, int position) { - if(position > mPlaceholderSize) { - return super.getItemForRow(view, position - mPlaceholderSize); - }else - return null; - } - - @Override - public Holder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == TYPE_PLACEHOLDER) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.material_view_pager_placeholder, parent, false); - return new Holder(view); - } else - return super.onCreateViewHolder(parent, viewType); - } - } - -} From b1a0cf17db8124bed6941af1603a0475396430a6 Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 4 Aug 2015 22:11:31 +0200 Subject: [PATCH 32/78] updated the ViewController --- .../materialviewpager/ViewController.java | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/ViewController.java diff --git a/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/ViewController.java b/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/ViewController.java new file mode 100644 index 00000000..69078cbf --- /dev/null +++ b/materialviewpagercontroller/src/main/java/com/github/florent37/materialviewpager/ViewController.java @@ -0,0 +1,95 @@ +package com.github.florent37.materialviewpager.controllers; + +import android.app.Activity; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.github.florent37.carpaccio.Carpaccio; +import com.github.florent37.carpaccio.CarpaccioHelper; +import com.github.florent37.carpaccio.controllers.CommonViewController; +import com.github.florent37.carpaccio.controllers.adapter.CarpaccioRecyclerViewAdapter; +import com.github.florent37.carpaccio.controllers.adapter.Holder; +import com.github.florent37.materialviewpager.MaterialViewPagerHelper; + +import static com.github.florent37.carpaccio.controllers.ControllerHelper.getLayoutIdentifierFromString; + +/** + * Created by florentchampigny on 04/08/15. + */ +public class ViewController { + + protected int recyclerColumnCount = 1; + + public void materialColumns(View view, int number) { + if (view instanceof RecyclerView) { + recyclerColumnCount = number; + + RecyclerView recyclerView = (RecyclerView) view; + recyclerView.setLayoutManager(new GridLayoutManager(view.getContext(), number)); + } + } + + public void materialAdapter(View view, String mappedName, String layoutName) { + final int layoutResId = getLayoutIdentifierFromString(view.getContext(), layoutName); + final Carpaccio carpaccio = CarpaccioHelper.findParentCarpaccio(view); + if (carpaccio != null && layoutResId != -1 && view instanceof RecyclerView) { + CommonViewController commonViewController = new CommonViewController(); + + MaterialCarpaccioRecyclerViewAdapter adapter = new MaterialCarpaccioRecyclerViewAdapter(recyclerColumnCount, carpaccio, layoutResId, mappedName); + + commonViewController.setAdapterForRecyclerView(view, mappedName, layoutName, adapter); + + MaterialViewPagerHelper.registerRecyclerView((Activity) view.getContext(), (RecyclerView) view, null); + } + } + + public class MaterialCarpaccioRecyclerViewAdapter extends CarpaccioRecyclerViewAdapter { + + //the constants value of the header view + static final int TYPE_PLACEHOLDER = Integer.MIN_VALUE; + + //the size taken by the header + protected int mPlaceholderSize = 1; + + public MaterialCarpaccioRecyclerViewAdapter(int mPlaceholderSize, Carpaccio carpaccio, int layoutResId, String mappedName) { + super(carpaccio, layoutResId, mappedName); + this.mPlaceholderSize = mPlaceholderSize; + } + + public int getItemViewType(int position) { + if (position < mPlaceholderSize) + return TYPE_PLACEHOLDER; + return super.getItemViewType(position); + } + + @Override + public int getItemCount() { + int itemCount = super.getItemCount(); + if( itemCount > 0) + return itemCount+mPlaceholderSize; + else + return 0; + } + + @Override + public Object getItemForRow(View view, int position) { + if(position >= mPlaceholderSize) { + return super.getItemForRow(view, position - mPlaceholderSize); + }else + return null; + } + + @Override + public Holder onCreateViewHolder(ViewGroup parent, int viewType) { + if (viewType == TYPE_PLACEHOLDER) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.material_view_pager_placeholder, parent, false); + return new Holder(view); + } else + return super.onCreateViewHolder(parent, viewType); + } + } + +} From 8f0b4885ff80e8e9fca5505a1f6cca3bcd378d13 Mon Sep 17 00:00:00 2001 From: Filipe de Lima Brito Date: Wed, 5 Aug 2015 17:27:00 -0300 Subject: [PATCH 33/78] Fixed sample APK link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2ed89e1..98552348 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Material Design ViewPager easy to use library Android app on Google Play -You can find a sample APK : [Link](https://github.com/florent37/MaterialViewPager/releases/download/1.1.0/sample-debug.apk) +You can find a sample APK : [Link](https://github.com/florent37/MaterialViewPager/releases/download/1.1.0/sample-release.apk) And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.com/watch?v=r95Tt6AS18c) From f17ff5dd3876ec5accb8b8da097f61c9fc9f055b Mon Sep 17 00:00:00 2001 From: Ibrahim Mubarak Date: Sun, 9 Aug 2015 21:55:23 +0530 Subject: [PATCH 34/78] Add OnImageLoad Listener to header when loading images from URL --- .../materialviewpager/MaterialViewPager.java | 16 ++++++++++++++++ .../header/MaterialViewPagerImageHelper.java | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 1ba8460d..97558d17 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -258,6 +258,17 @@ public void setImageUrl(String imageUrl, int fadeDuration) { } } + /** + * 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 @@ -409,4 +420,9 @@ public void setMaterialViewPagerListener(Listener listener) { public interface Listener { HeaderDesign getHeaderDesign(int page); } + + public interface OnImageLoadListener { + void OnImageLoad(ImageView imageView, Bitmap bitmap); + } + } diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java index 8e5c17a5..3daae416 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java @@ -1,10 +1,12 @@ package com.github.florent37.materialviewpager.header; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; +import com.github.florent37.materialviewpager.MaterialViewPager; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.AnimatorListenerAdapter; import com.nineoldandroids.animation.ObjectAnimator; @@ -17,6 +19,8 @@ */ public class MaterialViewPagerImageHelper { + private static MaterialViewPager.OnImageLoadListener imageLoadListener; + /** * change the image with a fade * @param urlImage @@ -46,6 +50,9 @@ public void onSuccess() { final ObjectAnimator fadeIn = ObjectAnimator.ofFloat(viewToAnimate, "alpha", alpha).setDuration(fadeDuration); fadeIn.setInterpolator(new AccelerateInterpolator()); fadeIn.start(); + if(imageLoadListener!=null){ + imageLoadListener.OnImageLoad(imageView,((BitmapDrawable)imageView.getDrawable()).getBitmap()); + } } @Override @@ -87,4 +94,8 @@ public void onAnimationEnd(Animator animation) { fadeOut.start(); } + public static void setImageLoadListener(MaterialViewPager.OnImageLoadListener imageLoadListener) { + MaterialViewPagerImageHelper.imageLoadListener = imageLoadListener; + } } + From 8ae530114232af3c7b48fee0e5e70c874ff9b4b7 Mon Sep 17 00:00:00 2001 From: Ibrahim Mubarak Date: Sun, 9 Aug 2015 22:26:54 +0530 Subject: [PATCH 35/78] Fix crashes when setColor is executed, when Animator is null --- .../github/florent37/materialviewpager/MaterialViewPager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 97558d17..e7a32035 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -288,6 +288,7 @@ public void setImageDrawable(Drawable drawable, int fadeDuration) { * Change the header color */ public void setColor(int color, int fadeDuration) { + if(MaterialViewPagerHelper.getAnimator(getContext())!=null) MaterialViewPagerHelper.getAnimator(getContext()).setColor(color, fadeDuration * 2); } From 27ea29b96dafb3debc06c9968fa707dddbe2689f Mon Sep 17 00:00:00 2001 From: Florent CHAMPIGNY Date: Mon, 10 Aug 2015 14:46:19 +0200 Subject: [PATCH 36/78] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a44f32a2..545dcad9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ jdk: android: components: - - build-tools-21.1.1 - - android-21 + - android-22 + - build-tools-22.0.1 - extra-android-support - extra-google-google_play_services - extra-google-m2repository @@ -28,4 +28,4 @@ install: # - ./gradlew androidDependencies script: - - ./gradlew clean assembleDebug \ No newline at end of file + - ./gradlew clean assembleDebug From 5f66a6bffdd648d8cff86a285ef26fdf28bb9e6c Mon Sep 17 00:00:00 2001 From: math Date: Wed, 12 Aug 2015 15:40:48 +0800 Subject: [PATCH 37/78] Add layer to darken picture and reveal text. --- .../materialviewpager/MaterialViewPager.java | 13 +++++++++++++ .../MaterialViewPagerSettings.java | 6 ++++++ .../material_view_pager_imageview_header.xml | 18 +++++++++++++----- .../src/main/res/values/attrs.xml | 1 + materialviewpager/src/main/res/values/ids.xml | 1 + sample/src/main/res/layout/activity_main.xml | 1 + 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 1ba8460d..6422b25a 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -254,6 +254,7 @@ public void setImageUrl(String imageUrl, int fadeDuration) { if (headerBackgroundImage != null) { ViewHelper.setAlpha(headerBackgroundImage, settings.headerAlpha); MaterialViewPagerImageHelper.setImageUrl(headerBackgroundImage, imageUrl, fadeDuration); + setImageHeaderDarkLayerAlpha(); } } } @@ -269,10 +270,22 @@ public void setImageDrawable(Drawable drawable, int fadeDuration) { if (headerBackgroundImage != null) { ViewHelper.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) { + ViewHelper.setAlpha(headerImageDarkLayerView, settings.imageHeaderDarkLayerAlpha); + } + } + /** * Change the header color */ diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java index 0b1dfeaf..a824ea7a 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java @@ -32,6 +32,7 @@ public class MaterialViewPagerSettings implements Parcelable { protected float headerAlpha; protected float parallaxHeaderFactor; + protected float imageHeaderDarkLayerAlpha; protected boolean hideToolbarAndTitle; protected boolean hideLogoWithFade; @@ -74,6 +75,9 @@ protected void handleAttributes(Context context, AttributeSet attrs){ { 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 @@ -121,6 +125,7 @@ public void writeToParcel(Parcel dest, int flags) { 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); @@ -140,6 +145,7 @@ private MaterialViewPagerSettings(Parcel in) { 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; diff --git a/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml b/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml index a2712e81..38acf2b0 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml @@ -1,8 +1,16 @@ - \ No newline at end of file + android:layout_height="match_parent"> + + + \ No newline at end of file diff --git a/materialviewpager/src/main/res/values/attrs.xml b/materialviewpager/src/main/res/values/attrs.xml index cc2765a9..cedd249c 100644 --- a/materialviewpager/src/main/res/values/attrs.xml +++ b/materialviewpager/src/main/res/values/attrs.xml @@ -9,6 +9,7 @@ + diff --git a/materialviewpager/src/main/res/values/ids.xml b/materialviewpager/src/main/res/values/ids.xml index 63a8e6f4..fb5566a8 100644 --- a/materialviewpager/src/main/res/values/ids.xml +++ b/materialviewpager/src/main/res/values/ids.xml @@ -2,4 +2,5 @@ + \ No newline at end of file diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 072f001f..fc6681d8 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -15,6 +15,7 @@ app:viewpager_color="@color/colorPrimary" app:viewpager_headerHeight="200dp" app:viewpager_headerAlpha="0.6" + app:viewpager_imageHeaderDarkLayerAlpha="0.2" app:viewpager_hideLogoWithFade="false" app:viewpager_hideToolbarAndTitle="true" app:viewpager_enableToolbarElevation="true" From d25b2da4d01756fdcabf54b5ce0e96bb3317335c Mon Sep 17 00:00:00 2001 From: math Date: Wed, 12 Aug 2015 18:54:17 +0800 Subject: [PATCH 38/78] Add layer to darken picture and reveal text : - Set background of layer to black with default value to 0.0 - Add in moving header as well --- .../material_view_pager_imageview_header.xml | 3 ++- .../material_view_pager_moving_header.xml | 20 ++++++++++++++----- sample/src/main/res/layout/activity_main.xml | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml b/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml index 38acf2b0..0bfdab0c 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml @@ -12,5 +12,6 @@ + android:layout_height="match_parent" + android:background="@android:color/black"/> \ No newline at end of file diff --git a/materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml b/materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml index a036d268..afc809ca 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml @@ -1,8 +1,18 @@ - \ No newline at end of file + android:layout_height="match_parent"> + + + \ No newline at end of file diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index fc6681d8..21c9ca69 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -14,7 +14,7 @@ app:viewpager_logoMarginTop="100dp" app:viewpager_color="@color/colorPrimary" app:viewpager_headerHeight="200dp" - app:viewpager_headerAlpha="0.6" + app:viewpager_headerAlpha="1.0" app:viewpager_imageHeaderDarkLayerAlpha="0.2" app:viewpager_hideLogoWithFade="false" app:viewpager_hideToolbarAndTitle="true" From b932d4fbddd213fff25bcf2e80045a08ad3b6ccd Mon Sep 17 00:00:00 2001 From: math Date: Wed, 12 Aug 2015 19:20:39 +0800 Subject: [PATCH 39/78] Add layer to darken picture and reveal text : - Set the layer background color only on apply alpha. --- .../github/florent37/materialviewpager/MaterialViewPager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 6422b25a..adc5113f 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -282,6 +282,7 @@ 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)); ViewHelper.setAlpha(headerImageDarkLayerView, settings.imageHeaderDarkLayerAlpha); } } From 9c40c9cee306a1067741d3bb1b67fcbf0e4e2add Mon Sep 17 00:00:00 2001 From: math Date: Wed, 12 Aug 2015 19:22:02 +0800 Subject: [PATCH 40/78] Add layer to darken picture and reveal text : - remove layer background color from xml --- .../main/res/layout/material_view_pager_imageview_header.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml b/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml index 0bfdab0c..38acf2b0 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml @@ -12,6 +12,5 @@ + android:layout_height="match_parent"/> \ No newline at end of file From 4d8f7c9b02be33b5dd00af76928cf4099e0216b1 Mon Sep 17 00:00:00 2001 From: Florent Date: Wed, 26 Aug 2015 10:03:55 +0200 Subject: [PATCH 41/78] set Framelayout in header instead of RelativeLayout --- ..._1_1_0.xml => materialviewpager_1_1_1.xml} | 8 +++---- materialviewpager/materialviewpager.iml | 2 +- .../materialviewpager/MaterialViewPager.java | 21 ++++++++++--------- .../material_view_pager_imageview_header.xml | 4 ++-- .../material_view_pager_moving_header.xml | 4 ++-- .../materialviewpagercontroller.iml | 6 +++--- 6 files changed, 23 insertions(+), 22 deletions(-) rename .idea/libraries/{materialviewpager_1_1_0.xml => materialviewpager_1_1_1.xml} (77%) diff --git a/.idea/libraries/materialviewpager_1_1_0.xml b/.idea/libraries/materialviewpager_1_1_1.xml similarity index 77% rename from .idea/libraries/materialviewpager_1_1_0.xml rename to .idea/libraries/materialviewpager_1_1_1.xml index 312c3d3f..a0048ee0 100644 --- a/.idea/libraries/materialviewpager_1_1_0.xml +++ b/.idea/libraries/materialviewpager_1_1_1.xml @@ -1,11 +1,11 @@ - + - + - - + + diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index 43ce5354..5302bf85 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -103,8 +103,8 @@ - + diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index a05073af..38c9c399 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -2,6 +2,7 @@ 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; @@ -23,10 +24,10 @@ /** * Created by florentchampigny on 28/04/15. - * + *

* The main class of MaterialViewPager * To use in an xml layout with attributes viewpager_* - * + *

* Display a preview with header, actual logo and fake cells */ public class MaterialViewPager extends FrameLayout implements ViewPager.OnPageChangeListener { @@ -118,7 +119,7 @@ protected void onFinishInflate() { logoContainer = (ViewGroup) findViewById(R.id.logoContainer); mToolbar = (Toolbar) findViewById(R.id.toolbar); - if(settings.disableToolbar) + if (settings.disableToolbar) mToolbar.setVisibility(INVISIBLE); mViewPager = (ViewPager) findViewById(R.id.viewPager); @@ -231,7 +232,7 @@ public PagerSlidingTabStrip getPagerTitleStrip() { * Retrieve the displayed toolbar */ public void setToolbar(Toolbar toolbar) { - mToolbar=toolbar; + mToolbar = toolbar; } /** @@ -264,9 +265,9 @@ public void setImageUrl(String imageUrl, int fadeDuration) { * may remove Picasso */ public void setImageUrl(String imageUrl, int fadeDuration, OnImageLoadListener imageLoadListener) { - if(imageLoadListener!=null) + if (imageLoadListener != null) MaterialViewPagerImageHelper.setImageLoadListener(imageLoadListener); - setImageUrl(imageUrl,fadeDuration); + setImageUrl(imageUrl, fadeDuration); } @@ -302,8 +303,8 @@ public void setImageHeaderDarkLayerAlpha() { * Change the header color */ public void setColor(int color, int fadeDuration) { - if(MaterialViewPagerHelper.getAnimator(getContext())!=null) - MaterialViewPagerHelper.getAnimator(getContext()).setColor(color, fadeDuration * 2); + if (MaterialViewPagerHelper.getAnimator(getContext()) != null) + MaterialViewPagerHelper.getAnimator(getContext()).setColor(color, fadeDuration * 2); } @Override @@ -353,7 +354,7 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse } } - public void notifyHeaderChanged(){ + public void notifyHeaderChanged() { int position = lastPosition; lastPosition = -1; onPageSelected(position); @@ -437,7 +438,7 @@ public interface Listener { } public interface OnImageLoadListener { - void OnImageLoad(ImageView imageView, Bitmap bitmap); + void OnImageLoad(ImageView imageView, Bitmap bitmap); } } diff --git a/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml b/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml index 38acf2b0..64f2830a 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_imageview_header.xml @@ -1,5 +1,5 @@ - @@ -13,4 +13,4 @@ android:id="@id/materialviewpager_headerImageDarkLayer" android:layout_width="match_parent" android:layout_height="match_parent"/> - \ No newline at end of file + \ No newline at end of file diff --git a/materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml b/materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml index afc809ca..0cbaf8fc 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_moving_header.xml @@ -1,5 +1,5 @@ - @@ -15,4 +15,4 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black"/> - \ No newline at end of file + \ No newline at end of file diff --git a/materialviewpagercontroller/materialviewpagercontroller.iml b/materialviewpagercontroller/materialviewpagercontroller.iml index 4d2c3362..2dc47c13 100644 --- a/materialviewpagercontroller/materialviewpagercontroller.iml +++ b/materialviewpagercontroller/materialviewpagercontroller.iml @@ -75,7 +75,7 @@ - + @@ -97,13 +97,13 @@ - + - + From 97ca6df9ee029998483e5a05ab5ff446d71f77a2 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 31 Aug 2015 16:18:35 +0200 Subject: [PATCH 42/78] updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98552348..50397999 100644 --- a/README.md +++ b/README.md @@ -583,7 +583,7 @@ Tell me if you're using my library in your application, I'll share it in this RE #Credits -Author: Florent Champigny www.florentchampigny.com/ +Author: Florent Champigny [http://www.florentchampigny.com/](http://www.florentchampigny.com/) Follow me on Google+ Date: Sun, 13 Sep 2015 14:04:15 +0200 Subject: [PATCH 43/78] fixed quick scroll --- .idea/libraries/appcompat_v7_22_2_1.xml | 7 +--- .idea/libraries/cardview_v7_22_2_1.xml | 4 +-- .idea/libraries/circleimageview_1_3_0.xml | 3 -- .idea/libraries/materialviewpager_1_1_1.xml | 3 -- .idea/libraries/recyclerview_v7_22_2_1.xml | 4 +-- .../libraries/support_annotations_22_2_1.xml | 4 +-- .idea/libraries/support_v4_22_2_1.xml | 7 +--- materialviewpager/materialviewpager.iml | 5 +-- .../MaterialViewPagerAnimator.java | 35 ++++++++++++++----- .../materialviewpagercontroller.iml | 5 +-- .../sample/MainActivity.java | 2 +- sample/src/main/res/layout/activity_main.xml | 2 +- 12 files changed, 37 insertions(+), 44 deletions(-) diff --git a/.idea/libraries/appcompat_v7_22_2_1.xml b/.idea/libraries/appcompat_v7_22_2_1.xml index a630ec58..1b9a3b42 100644 --- a/.idea/libraries/appcompat_v7_22_2_1.xml +++ b/.idea/libraries/appcompat_v7_22_2_1.xml @@ -1,15 +1,10 @@ - - - - - - + \ No newline at end of file diff --git a/.idea/libraries/cardview_v7_22_2_1.xml b/.idea/libraries/cardview_v7_22_2_1.xml index 59c1810e..7c2cb6ba 100644 --- a/.idea/libraries/cardview_v7_22_2_1.xml +++ b/.idea/libraries/cardview_v7_22_2_1.xml @@ -5,8 +5,6 @@ - - - + \ No newline at end of file diff --git a/.idea/libraries/circleimageview_1_3_0.xml b/.idea/libraries/circleimageview_1_3_0.xml index f190e249..597015f3 100644 --- a/.idea/libraries/circleimageview_1_3_0.xml +++ b/.idea/libraries/circleimageview_1_3_0.xml @@ -1,8 +1,5 @@ - - - diff --git a/.idea/libraries/materialviewpager_1_1_1.xml b/.idea/libraries/materialviewpager_1_1_1.xml index a0048ee0..4d9c96db 100644 --- a/.idea/libraries/materialviewpager_1_1_1.xml +++ b/.idea/libraries/materialviewpager_1_1_1.xml @@ -1,8 +1,5 @@ - - - diff --git a/.idea/libraries/recyclerview_v7_22_2_1.xml b/.idea/libraries/recyclerview_v7_22_2_1.xml index c88b12ab..eaae5604 100644 --- a/.idea/libraries/recyclerview_v7_22_2_1.xml +++ b/.idea/libraries/recyclerview_v7_22_2_1.xml @@ -5,8 +5,6 @@ - - - + \ No newline at end of file diff --git a/.idea/libraries/support_annotations_22_2_1.xml b/.idea/libraries/support_annotations_22_2_1.xml index d35d8131..578e0ab2 100644 --- a/.idea/libraries/support_annotations_22_2_1.xml +++ b/.idea/libraries/support_annotations_22_2_1.xml @@ -1,11 +1,11 @@ - + - + \ No newline at end of file diff --git a/.idea/libraries/support_v4_22_2_1.xml b/.idea/libraries/support_v4_22_2_1.xml index e5875958..96cbfbe0 100644 --- a/.idea/libraries/support_v4_22_2_1.xml +++ b/.idea/libraries/support_v4_22_2_1.xml @@ -1,16 +1,11 @@ - - - - - - + \ No newline at end of file diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index 5302bf85..7ac2adff 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -65,7 +65,6 @@ - @@ -91,9 +90,7 @@ - - @@ -103,8 +100,8 @@ - + diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 1ae43504..8db180b5 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -49,7 +49,7 @@ public class MaterialViewPagerAnimator { private static final String TAG = MaterialViewPagerAnimator.class.getSimpleName(); - public static Boolean ENABLE_LOG = false; + public static Boolean ENABLE_LOG = true; private Context context; @@ -188,14 +188,27 @@ public boolean onMaterialScrolled(Object source, float yOffset) { float percent = yOffset / scrollMax; - //distance between pager & toolbar - float newDistance = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom(); + if (ENABLE_LOG) + Log.d("percent1", "" + percent); + + if(percent != 0) { + //distance between pager & toolbar + float newDistance = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom(); + + percent = 1 - newDistance / initialDistance; - percent = 1 - newDistance/initialDistance; + if (ENABLE_LOG) + Log.d("percent2", "" + percent); + } if(Float.isNaN(percent)) //fix for orientation change return false; + if(percent == 0 && headerAnimator != null) { + cancelHeaderAnimator(); + ViewHelper.setTranslationY(mHeader.toolbarLayout,0); + } + percent = minMax(0, percent, 1); { @@ -263,16 +276,22 @@ else if (lastPercent != percent) { } if (headerAnimator != null && percent < 1) { + cancelHeaderAnimator(); + } + + lastYOffset = yOffset; + + return true; + } + + private void cancelHeaderAnimator(){ + if(headerAnimator != null) { if (headerAnimator instanceof ObjectAnimator) ((ObjectAnimator) headerAnimator).cancel(); else if (headerAnimator instanceof android.animation.ObjectAnimator) ((android.animation.ObjectAnimator) headerAnimator).cancel(); headerAnimator = null; } - - lastYOffset = yOffset; - - return true; } private void scrollUp(float yOffset) { diff --git a/materialviewpagercontroller/materialviewpagercontroller.iml b/materialviewpagercontroller/materialviewpagercontroller.iml index 2dc47c13..27be55ec 100644 --- a/materialviewpagercontroller/materialviewpagercontroller.iml +++ b/materialviewpagercontroller/materialviewpagercontroller.iml @@ -65,7 +65,6 @@ - @@ -90,9 +89,7 @@ - - @@ -102,8 +99,8 @@ - + diff --git a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java index 5b2206b2..64bc54f6 100644 --- a/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java +++ b/sample/src/main/java/com/github/florent37/materialviewpager/sample/MainActivity.java @@ -72,7 +72,7 @@ public Fragment getItem(int position) { //case 2: // return WebViewFragment.newInstance(); default: - return CarpaccioRecyclerViewFragment.newInstance(); + return RecyclerViewFragment.newInstance(); } } diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 21c9ca69..e42ac750 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -22,7 +22,7 @@ app:viewpager_parallaxHeaderFactor="1.5" app:viewpager_headerAdditionalHeight="20dp" app:viewpager_displayToolbarWhenSwipe="true" - app:viewpager_transparentToolbar="true" + app:viewpager_transparentToolbar="false" app:viewpager_animatedHeaderImage="true" /> From e4f657af85546757a3c9f70688692546eeeff838 Mon Sep 17 00:00:00 2001 From: florent37 Date: Sun, 13 Sep 2015 14:18:37 +0200 Subject: [PATCH 44/78] added option to replace the viewpager --- .idea/libraries/appcompat_v7_22_2_1.xml | 7 ++++++- .idea/libraries/cardview_v7_22_2_1.xml | 4 +++- .idea/libraries/circleimageview_1_3_0.xml | 3 +++ .idea/libraries/materialviewpager_1_1_1.xml | 3 +++ .idea/libraries/recyclerview_v7_22_2_1.xml | 4 +++- .idea/libraries/support_v4_22_2_1.xml | 7 ++++++- README.md | 4 ++++ build.gradle | 2 +- materialviewpager/materialviewpager.iml | 2 +- .../materialviewpager/MaterialViewPager.java | 19 ++++++++++++++++++- .../MaterialViewPagerAnimator.java | 1 + .../MaterialViewPagerSettings.java | 6 ++++++ .../res/layout/material_view_pager_layout.xml | 10 +++++++--- .../layout/material_view_pager_viewpager.xml | 6 ++++++ .../src/main/res/values/attrs.xml | 1 + materialviewpager/src/main/res/values/ids.xml | 1 + .../materialviewpagercontroller.iml | 2 +- sample/sample.iml | 2 +- 18 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 materialviewpager/src/main/res/layout/material_view_pager_viewpager.xml diff --git a/.idea/libraries/appcompat_v7_22_2_1.xml b/.idea/libraries/appcompat_v7_22_2_1.xml index 1b9a3b42..3fd60afd 100644 --- a/.idea/libraries/appcompat_v7_22_2_1.xml +++ b/.idea/libraries/appcompat_v7_22_2_1.xml @@ -1,10 +1,15 @@ + + + - + + + \ No newline at end of file diff --git a/.idea/libraries/cardview_v7_22_2_1.xml b/.idea/libraries/cardview_v7_22_2_1.xml index 7c2cb6ba..a06563f0 100644 --- a/.idea/libraries/cardview_v7_22_2_1.xml +++ b/.idea/libraries/cardview_v7_22_2_1.xml @@ -5,6 +5,8 @@ - + + + \ No newline at end of file diff --git a/.idea/libraries/circleimageview_1_3_0.xml b/.idea/libraries/circleimageview_1_3_0.xml index 597015f3..f190e249 100644 --- a/.idea/libraries/circleimageview_1_3_0.xml +++ b/.idea/libraries/circleimageview_1_3_0.xml @@ -1,5 +1,8 @@ + + + diff --git a/.idea/libraries/materialviewpager_1_1_1.xml b/.idea/libraries/materialviewpager_1_1_1.xml index 4d9c96db..a0048ee0 100644 --- a/.idea/libraries/materialviewpager_1_1_1.xml +++ b/.idea/libraries/materialviewpager_1_1_1.xml @@ -1,5 +1,8 @@ + + + diff --git a/.idea/libraries/recyclerview_v7_22_2_1.xml b/.idea/libraries/recyclerview_v7_22_2_1.xml index eaae5604..4c638463 100644 --- a/.idea/libraries/recyclerview_v7_22_2_1.xml +++ b/.idea/libraries/recyclerview_v7_22_2_1.xml @@ -5,6 +5,8 @@ - + + + \ No newline at end of file diff --git a/.idea/libraries/support_v4_22_2_1.xml b/.idea/libraries/support_v4_22_2_1.xml index 96cbfbe0..c45b85ba 100644 --- a/.idea/libraries/support_v4_22_2_1.xml +++ b/.idea/libraries/support_v4_22_2_1.xml @@ -1,11 +1,16 @@ + + + - + + + \ No newline at end of file diff --git a/README.md b/README.md index 50397999..a7bbcf56 100644 --- a/README.md +++ b/README.md @@ -501,6 +501,10 @@ And must include @layout/material_view_pager_placeholder as first child #CHANGELOG +##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 diff --git a/build.gradle b/build.gradle index ad085511..c9f3eb44 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ ext{ SUPPORT_VERSION='22.2.1' - MAVEN_VERSION='1.1.1' + MAVEN_VERSION='1.1.2' } allprojects { diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index 7ac2adff..e529fb12 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -1,5 +1,5 @@ - + diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 38c9c399..18d79ad8 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -46,6 +46,12 @@ public class MaterialViewPager extends FrameLayout implements ViewPager.OnPageCh */ private ViewGroup pagerTitleStripContainer; + + /** + * the layout containing the viewpager, can be replaced to add your own implementation of viewpager + */ + private ViewGroup viewpagerContainer; + /** * the layout containing logo * default : empty @@ -116,12 +122,22 @@ protected void onFinishInflate() { 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); - mViewPager = (ViewPager) findViewById(R.id.viewPager); + + { //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); @@ -138,6 +154,7 @@ protected void onFinishInflate() { 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; diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 8db180b5..8eb15793 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -204,6 +204,7 @@ public boolean onMaterialScrolled(Object source, float yOffset) { if(Float.isNaN(percent)) //fix for orientation change return false; + //fix quick scroll if(percent == 0 && headerAnimator != null) { cancelHeaderAnimator(); ViewHelper.setTranslationY(mHeader.toolbarLayout,0); diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java index a824ea7a..a8786f9f 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java @@ -20,6 +20,7 @@ public class MaterialViewPagerSettings implements Parcelable { protected int headerLayoutId; protected int pagerTitleStripId; + protected int viewpagerId; protected int logoLayoutId; protected int logoMarginTop; @@ -58,6 +59,9 @@ protected void handleAttributes(Context context, AttributeSet attrs){ 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); @@ -118,6 +122,7 @@ public int describeContents() { 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); @@ -138,6 +143,7 @@ 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(); diff --git a/materialviewpager/src/main/res/layout/material_view_pager_layout.xml b/materialviewpager/src/main/res/layout/material_view_pager_layout.xml index a62bf08f..18b8c66c 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_layout.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_layout.xml @@ -26,10 +26,14 @@ - + android:layout_height="match_parent"> + + + + + \ No newline at end of file diff --git a/materialviewpager/src/main/res/values/attrs.xml b/materialviewpager/src/main/res/values/attrs.xml index cedd249c..08c24f01 100644 --- a/materialviewpager/src/main/res/values/attrs.xml +++ b/materialviewpager/src/main/res/values/attrs.xml @@ -5,6 +5,7 @@ + diff --git a/materialviewpager/src/main/res/values/ids.xml b/materialviewpager/src/main/res/values/ids.xml index fb5566a8..369adf72 100644 --- a/materialviewpager/src/main/res/values/ids.xml +++ b/materialviewpager/src/main/res/values/ids.xml @@ -3,4 +3,5 @@ + \ No newline at end of file diff --git a/materialviewpagercontroller/materialviewpagercontroller.iml b/materialviewpagercontroller/materialviewpagercontroller.iml index 27be55ec..ef792925 100644 --- a/materialviewpagercontroller/materialviewpagercontroller.iml +++ b/materialviewpagercontroller/materialviewpagercontroller.iml @@ -1,5 +1,5 @@ - + diff --git a/sample/sample.iml b/sample/sample.iml index 8c185a47..7c940ff2 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -100,8 +100,8 @@ - + From 07c7566693ee8ca5298b0ebde59982b615dd7683 Mon Sep 17 00:00:00 2001 From: florent37 Date: Sun, 13 Sep 2015 14:24:37 +0200 Subject: [PATCH 45/78] published 1.1.2 --- README.md | 2 +- materialviewpager/build.gradle | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/README.md b/README.md index a7bbcf56..fb2b518c 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.co In your module [![Download](https://api.bintray.com/packages/florent37/maven/MaterialViewPager/images/download.svg)](https://bintray.com/florent37/maven/MaterialViewPager/_latestVersion) ```groovy -compile ('com.github.florent37:materialviewpager:1.1.0@aar'){ +compile ('com.github.florent37:materialviewpager:1.1.2@aar'){ transitive = true } ``` diff --git a/materialviewpager/build.gradle b/materialviewpager/build.gradle index 75385766..b8c1d62f 100644 --- a/materialviewpager/build.gradle +++ b/materialviewpager/build.gradle @@ -96,18 +96,7 @@ task sourcesJar(type: Jar) { 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 } From 0aa932586eb841906a08228e2a1f3f7a02dc773e Mon Sep 17 00:00:00 2001 From: Daniel Silver Date: Sat, 24 Oct 2015 19:32:29 -0500 Subject: [PATCH 46/78] Corrected attribute name for pstsTabTextAllCaps --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb2b518c..584a3df7 100644 --- a/README.md +++ b/README.md @@ -337,7 +337,7 @@ Create your own layout using a PagerSlidingTabStrip app:pstsIndicatorHeight="2dp" app:pstsShouldExpand="true" app:pstsTabPaddingLeftRight="10dp" - app:pstsTextAllCaps="true" + app:pstsTabTextAllCaps="true" tools:background="#A333" /> ``` From e5cf83dd7c44f1cad7971c28f4e966545e79710f Mon Sep 17 00:00:00 2001 From: Ashok Varma Date: Mon, 9 Nov 2015 10:15:18 +0530 Subject: [PATCH 47/78] Fix - Touch doesn't work ontop of Scrollable views https://github.com/florent37/MaterialViewPager/issues/164 fix --- .../src/main/res/layout/material_view_pager_layout.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/materialviewpager/src/main/res/layout/material_view_pager_layout.xml b/materialviewpager/src/main/res/layout/material_view_pager_layout.xml index 18b8c66c..838f5598 100644 --- a/materialviewpager/src/main/res/layout/material_view_pager_layout.xml +++ b/materialviewpager/src/main/res/layout/material_view_pager_layout.xml @@ -38,8 +38,7 @@ + android:layout_height="wrap_content"> Date: Mon, 9 Nov 2015 10:21:05 +0530 Subject: [PATCH 48/78] Fix - toolbarlayout break on scrolling https://github.com/florent37/MaterialViewPager/issues/123 Fix --- .../materialviewpager/MaterialViewPagerAnimator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 8eb15793..8d8a4373 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -410,6 +410,10 @@ private void followScrollToolbarLayout(float yOffset) { firstScrollValue = yOffset; float translationY = firstScrollValue - yOffset; + + if(translationY > 0) { + translationY = 0; + } if (ENABLE_LOG) Log.d(TAG, "translationY " + translationY); From 2116d37aeae3a8726b2a10e4ec3a62922446b3ee Mon Sep 17 00:00:00 2001 From: florent37 Date: Sat, 14 Nov 2015 12:43:31 +0100 Subject: [PATCH 49/78] sent 1.1.3 --- .idea/libraries/answers_1_2_2.xml | 2 +- .idea/libraries/cardview_v7_22_2_1.xml | 2 +- .idea/libraries/circleimageview_1_3_0.xml | 2 +- .idea/libraries/crashlytics_2_4_0.xml | 2 +- .idea/libraries/crashlytics_core_2_3_3.xml | 2 +- ..._1_1_1.xml => materialviewpager_1_1_2.xml} | 8 ++--- .idea/libraries/recyclerview_v7_22_2_1.xml | 2 +- README.md | 4 +++ build.gradle | 2 +- materialviewpager/materialviewpager.iml | 16 +++++----- .../materialviewpagercontroller.iml | 29 ++++++++++--------- sample/sample.iml | 14 ++++----- 12 files changed, 47 insertions(+), 38 deletions(-) rename .idea/libraries/{materialviewpager_1_1_1.xml => materialviewpager_1_1_2.xml} (77%) diff --git a/.idea/libraries/answers_1_2_2.xml b/.idea/libraries/answers_1_2_2.xml index e070364f..ca5b27f2 100644 --- a/.idea/libraries/answers_1_2_2.xml +++ b/.idea/libraries/answers_1_2_2.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/cardview_v7_22_2_1.xml b/.idea/libraries/cardview_v7_22_2_1.xml index a06563f0..9fa91647 100644 --- a/.idea/libraries/cardview_v7_22_2_1.xml +++ b/.idea/libraries/cardview_v7_22_2_1.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/circleimageview_1_3_0.xml b/.idea/libraries/circleimageview_1_3_0.xml index f190e249..e56840a4 100644 --- a/.idea/libraries/circleimageview_1_3_0.xml +++ b/.idea/libraries/circleimageview_1_3_0.xml @@ -4,8 +4,8 @@ - + diff --git a/.idea/libraries/crashlytics_2_4_0.xml b/.idea/libraries/crashlytics_2_4_0.xml index 02dd64aa..ee6b2b9e 100644 --- a/.idea/libraries/crashlytics_2_4_0.xml +++ b/.idea/libraries/crashlytics_2_4_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/crashlytics_core_2_3_3.xml b/.idea/libraries/crashlytics_core_2_3_3.xml index b668786e..5a1f215b 100644 --- a/.idea/libraries/crashlytics_core_2_3_3.xml +++ b/.idea/libraries/crashlytics_core_2_3_3.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/materialviewpager_1_1_1.xml b/.idea/libraries/materialviewpager_1_1_2.xml similarity index 77% rename from .idea/libraries/materialviewpager_1_1_1.xml rename to .idea/libraries/materialviewpager_1_1_2.xml index a0048ee0..f5c566a4 100644 --- a/.idea/libraries/materialviewpager_1_1_1.xml +++ b/.idea/libraries/materialviewpager_1_1_2.xml @@ -1,11 +1,11 @@ - + - + - - + + diff --git a/.idea/libraries/recyclerview_v7_22_2_1.xml b/.idea/libraries/recyclerview_v7_22_2_1.xml index 4c638463..5b062f4f 100644 --- a/.idea/libraries/recyclerview_v7_22_2_1.xml +++ b/.idea/libraries/recyclerview_v7_22_2_1.xml @@ -1,8 +1,8 @@ - + diff --git a/README.md b/README.md index 584a3df7..91f25d2d 100644 --- a/README.md +++ b/README.md @@ -501,6 +501,10 @@ And must include @layout/material_view_pager_placeholder as first child #CHANGELOG +##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) diff --git a/build.gradle b/build.gradle index c9f3eb44..3c8242b7 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ ext{ SUPPORT_VERSION='22.2.1' - MAVEN_VERSION='1.1.2' + MAVEN_VERSION='1.1.3' } allprojects { diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index e529fb12..c2ae7bb9 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -1,5 +1,5 @@ - + @@ -90,20 +90,22 @@ + + - - + + - + + + - - + - \ No newline at end of file diff --git a/materialviewpagercontroller/materialviewpagercontroller.iml b/materialviewpagercontroller/materialviewpagercontroller.iml index ef792925..82c2eada 100644 --- a/materialviewpagercontroller/materialviewpagercontroller.iml +++ b/materialviewpagercontroller/materialviewpagercontroller.iml @@ -1,5 +1,5 @@ - + @@ -65,6 +65,7 @@ + @@ -74,7 +75,7 @@ - + @@ -89,25 +90,27 @@ + + - - - + + + - + + - - - - - - + - + + + + + \ No newline at end of file diff --git a/sample/sample.iml b/sample/sample.iml index 7c940ff2..87ba5cef 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -93,18 +93,18 @@ + + + + + - - - - - - + - + From 608ea5514d4f9b98a52f13ef9ce8f94f09472c72 Mon Sep 17 00:00:00 2001 From: Ashok Varma Date: Thu, 19 Nov 2015 20:48:52 +0530 Subject: [PATCH 50/78] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 91f25d2d..5d36ff0b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.co In your module [![Download](https://api.bintray.com/packages/florent37/maven/MaterialViewPager/images/download.svg)](https://bintray.com/florent37/maven/MaterialViewPager/_latestVersion) ```groovy -compile ('com.github.florent37:materialviewpager:1.1.2@aar'){ +compile ('com.github.florent37:materialviewpager:1.1.3@aar'){ transitive = true } ``` From 9b717f75ef622db384d55eb30d12ac9ce880975b Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 23 Dec 2015 18:58:37 -0200 Subject: [PATCH 51/78] some .idea deleted and new function in adapter improved --- .idea/compiler.xml | 5 ++- .idea/encodings.xml | 5 --- .idea/gradle.xml | 13 ++------ .../android_observablescrollview_1_5_2.xml | 10 ------ .idea/libraries/answers_1_2_2.xml | 10 ------ .idea/libraries/appcompat_v7_22_2_1.xml | 15 --------- .idea/libraries/beta_1_1_3.xml | 10 ------ .idea/libraries/blurry_0_0_3.xml | 10 ------ .idea/libraries/cardview_v7_22_2_1.xml | 12 ------- .idea/libraries/carpaccio_1_0_1.xml | 10 ------ .idea/libraries/circleimageview_1_3_0.xml | 13 -------- .idea/libraries/crashlytics_2_4_0.xml | 10 ------ .idea/libraries/crashlytics_core_2_3_3.xml | 10 ------ .idea/libraries/fabric_1_3_4.xml | 10 ------ .idea/libraries/kenburnsview_1_0_6.xml | 11 ------- .idea/libraries/library_1_1_0.xml | 10 ------ .idea/libraries/library_2_4_0.xml | 11 ------- .../libraries/materialimageloading_1_0_1.xml | 10 ------ .idea/libraries/materialviewpager_1_1_2.xml | 13 -------- .idea/libraries/picasso_2_5_2.xml | 11 ------- .idea/libraries/recyclerview_v7_22_2_1.xml | 12 ------- .../libraries/support_annotations_22_2_1.xml | 11 ------- .idea/libraries/support_v4_22_2_1.xml | 16 ---------- .idea/misc.xml | 32 ++++++++----------- .idea/modules.xml | 3 -- .idea/vcs.xml | 5 ++- MaterialViewPager.iml | 10 ++++++ .../adapter/RecyclerViewMaterialAdapter.java | 4 +++ 28 files changed, 34 insertions(+), 268 deletions(-) delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/libraries/android_observablescrollview_1_5_2.xml delete mode 100644 .idea/libraries/answers_1_2_2.xml delete mode 100644 .idea/libraries/appcompat_v7_22_2_1.xml delete mode 100644 .idea/libraries/beta_1_1_3.xml delete mode 100644 .idea/libraries/blurry_0_0_3.xml delete mode 100644 .idea/libraries/cardview_v7_22_2_1.xml delete mode 100644 .idea/libraries/carpaccio_1_0_1.xml delete mode 100644 .idea/libraries/circleimageview_1_3_0.xml delete mode 100644 .idea/libraries/crashlytics_2_4_0.xml delete mode 100644 .idea/libraries/crashlytics_core_2_3_3.xml delete mode 100644 .idea/libraries/fabric_1_3_4.xml delete mode 100644 .idea/libraries/kenburnsview_1_0_6.xml delete mode 100644 .idea/libraries/library_1_1_0.xml delete mode 100644 .idea/libraries/library_2_4_0.xml delete mode 100644 .idea/libraries/materialimageloading_1_0_1.xml delete mode 100644 .idea/libraries/materialviewpager_1_1_2.xml delete mode 100644 .idea/libraries/picasso_2_5_2.xml delete mode 100644 .idea/libraries/recyclerview_v7_22_2_1.xml delete mode 100644 .idea/libraries/support_annotations_22_2_1.xml delete mode 100644 .idea/libraries/support_v4_22_2_1.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 217af471..96cc43ef 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,7 +1,6 @@ - - - + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index e206d70d..00000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/.idea/gradle.xml b/.idea/gradle.xml index be8a4b2c..058c87cc 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,17 +3,10 @@ diff --git a/.idea/libraries/android_observablescrollview_1_5_2.xml b/.idea/libraries/android_observablescrollview_1_5_2.xml deleted file mode 100644 index fdd2e47b..00000000 --- a/.idea/libraries/android_observablescrollview_1_5_2.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/answers_1_2_2.xml b/.idea/libraries/answers_1_2_2.xml deleted file mode 100644 index ca5b27f2..00000000 --- a/.idea/libraries/answers_1_2_2.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/appcompat_v7_22_2_1.xml b/.idea/libraries/appcompat_v7_22_2_1.xml deleted file mode 100644 index 3fd60afd..00000000 --- a/.idea/libraries/appcompat_v7_22_2_1.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/beta_1_1_3.xml b/.idea/libraries/beta_1_1_3.xml deleted file mode 100644 index 236ae995..00000000 --- a/.idea/libraries/beta_1_1_3.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/blurry_0_0_3.xml b/.idea/libraries/blurry_0_0_3.xml deleted file mode 100644 index be118801..00000000 --- a/.idea/libraries/blurry_0_0_3.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/cardview_v7_22_2_1.xml b/.idea/libraries/cardview_v7_22_2_1.xml deleted file mode 100644 index 9fa91647..00000000 --- a/.idea/libraries/cardview_v7_22_2_1.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/carpaccio_1_0_1.xml b/.idea/libraries/carpaccio_1_0_1.xml deleted file mode 100644 index 9b68adf1..00000000 --- a/.idea/libraries/carpaccio_1_0_1.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/circleimageview_1_3_0.xml b/.idea/libraries/circleimageview_1_3_0.xml deleted file mode 100644 index e56840a4..00000000 --- a/.idea/libraries/circleimageview_1_3_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/crashlytics_2_4_0.xml b/.idea/libraries/crashlytics_2_4_0.xml deleted file mode 100644 index ee6b2b9e..00000000 --- a/.idea/libraries/crashlytics_2_4_0.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/crashlytics_core_2_3_3.xml b/.idea/libraries/crashlytics_core_2_3_3.xml deleted file mode 100644 index 5a1f215b..00000000 --- a/.idea/libraries/crashlytics_core_2_3_3.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/fabric_1_3_4.xml b/.idea/libraries/fabric_1_3_4.xml deleted file mode 100644 index ad1dfd9f..00000000 --- a/.idea/libraries/fabric_1_3_4.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/kenburnsview_1_0_6.xml b/.idea/libraries/kenburnsview_1_0_6.xml deleted file mode 100644 index 8c460cce..00000000 --- a/.idea/libraries/kenburnsview_1_0_6.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/library_1_1_0.xml b/.idea/libraries/library_1_1_0.xml deleted file mode 100644 index 42d03644..00000000 --- a/.idea/libraries/library_1_1_0.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/library_2_4_0.xml b/.idea/libraries/library_2_4_0.xml deleted file mode 100644 index eedfc0da..00000000 --- a/.idea/libraries/library_2_4_0.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/materialimageloading_1_0_1.xml b/.idea/libraries/materialimageloading_1_0_1.xml deleted file mode 100644 index 8db6b2f6..00000000 --- a/.idea/libraries/materialimageloading_1_0_1.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/materialviewpager_1_1_2.xml b/.idea/libraries/materialviewpager_1_1_2.xml deleted file mode 100644 index f5c566a4..00000000 --- a/.idea/libraries/materialviewpager_1_1_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/picasso_2_5_2.xml b/.idea/libraries/picasso_2_5_2.xml deleted file mode 100644 index b05e3b65..00000000 --- a/.idea/libraries/picasso_2_5_2.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/recyclerview_v7_22_2_1.xml b/.idea/libraries/recyclerview_v7_22_2_1.xml deleted file mode 100644 index 5b062f4f..00000000 --- a/.idea/libraries/recyclerview_v7_22_2_1.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/support_annotations_22_2_1.xml b/.idea/libraries/support_annotations_22_2_1.xml deleted file mode 100644 index 578e0ab2..00000000 --- a/.idea/libraries/support_annotations_22_2_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/support_v4_22_2_1.xml b/.idea/libraries/support_v4_22_2_1.xml deleted file mode 100644 index c45b85ba..00000000 --- a/.idea/libraries/support_v4_22_2_1.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 88eb4113..47662492 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - - + + + + + + + + + + + - - - - - 1.7 - - - - - - + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index d104611d..ad2b2424 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,9 +3,6 @@ - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index c80f2198..35eb1ddf 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,7 +1,6 @@ - + - - + \ No newline at end of file diff --git a/MaterialViewPager.iml b/MaterialViewPager.iml index 9c5f8acd..02342f05 100644 --- a/MaterialViewPager.iml +++ b/MaterialViewPager.iml @@ -7,6 +7,16 @@ + + + + + + + + diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java index 0fd93365..b9db9da9 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java @@ -103,6 +103,10 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { } } + public RecyclerView.Adapter getRecyclerAdapter() { + return mAdapter; + } + public void mvp_notifyDataSetChanged() { mAdapter.notifyDataSetChanged(); notifyDataSetChanged(); From 69f2126c9f08aa045aea2dd414d5b6e851d7bca3 Mon Sep 17 00:00:00 2001 From: florent champigny Date: Fri, 27 May 2016 14:02:39 +0200 Subject: [PATCH 52/78] 1.2.0 added header decorator, removed some nineold usages --- .gitignore | 14 +- .idea/gradle.xml | 20 +- .idea/misc.xml | 5 +- .idea/modules.xml | 3 + .idea/scopes/scope_settings.xml | 5 - .idea/vcs.xml | 2 +- MaterialViewPager.iml | 10 - README.md | 14 +- build.gradle | 35 +- gradle/bintray-android-v1.gradle | 52 ++ gradle/bintray-java-v1.gradle | 49 ++ gradle/install-v1.gradle | 44 ++ gradle/wrapper/gradle-wrapper.properties | 2 +- materialviewpager/build.gradle | 132 ++--- materialviewpager/materialviewpager.iml | 81 +-- .../materialviewpager/MaterialViewPager.java | 411 +++++++------- .../MaterialViewPagerAnimator.java | 508 +++++++++--------- .../MaterialViewPagerHeader.java | 11 +- .../MaterialViewPagerHelper.java | 39 +- .../MaterialViewPagerSettings.java | 126 +++-- .../florent37/materialviewpager/Utils.java | 23 +- .../adapter/RecyclerViewMaterialAdapter.java | 3 + .../MaterialViewPagerHEaderDecorator.java | 47 ++ .../header/MaterialViewPagerImageHeader.java | 15 +- .../header/MaterialViewPagerImageHelper.java | 100 ++-- .../MaterialViewPagerKenBurnsHeader.java | 17 +- materialviewpagercontroller/build.gradle | 123 +---- .../materialviewpagercontroller.iml | 66 ++- sample/build.gradle | 28 +- sample/sample.iml | 68 ++- .../sample/DrawerActivity.java | 62 +++ .../sample/MainActivity.java | 56 +- .../sample/fragment/RecyclerViewFragment.java | 29 +- 33 files changed, 1173 insertions(+), 1027 deletions(-) delete mode 100644 .idea/scopes/scope_settings.xml create mode 100644 gradle/bintray-android-v1.gradle create mode 100644 gradle/bintray-java-v1.gradle create mode 100644 gradle/install-v1.gradle create mode 100644 materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerHEaderDecorator.java create mode 100644 sample/src/main/java/com/github/florent37/materialviewpager/sample/DrawerActivity.java diff --git a/.gitignore b/.gitignore index 27dce785..89676dd8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,6 @@ *.apk *.ap_ -.idea/workspace.xml - # Files for the Dalvik VM *.dex @@ -17,7 +15,6 @@ gen/ # Gradle files .gradle/ build/ -/*/build/ # Local configuration file (sdk path, etc) local.properties @@ -27,3 +24,14 @@ proguard/ # Log Files *.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +.gradle +.idea +*.iml +**/build/* \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 058c87cc..26f59804 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,10 +3,24 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 47662492..5d199810 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,8 @@ + + + - + diff --git a/.idea/modules.xml b/.idea/modules.xml index ad2b2424..d104611d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,9 @@ + + + \ No newline at end of file diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b8..00000000 --- a/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1ddf..94a25f7f 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/MaterialViewPager.iml b/MaterialViewPager.iml index 02342f05..9c5f8acd 100644 --- a/MaterialViewPager.iml +++ b/MaterialViewPager.iml @@ -7,16 +7,6 @@ - - - - - - - - diff --git a/README.md b/README.md index 5d36ff0b..cb6dea21 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ And have a look on a sample Youtube Video : [Youtube Link](http://www.youtube.co In your module [![Download](https://api.bintray.com/packages/florent37/maven/MaterialViewPager/images/download.svg)](https://bintray.com/florent37/maven/MaterialViewPager/_latestVersion) ```groovy -compile ('com.github.florent37:materialviewpager:1.1.3@aar'){ +compile ('com.github.florent37:materialviewpager:1.2.0@aar'){ transitive = true } ``` @@ -441,6 +441,15 @@ Sample : ##RecyclerView +### LinearLayoutManager / GridLayoutManager + +```java +mRecyclerView.setAdapter(new MaterialViewPagerHeaderDecorator()); +mRecyclerView.setAdapter(yourAdapter); +``` + +### StaggedLayoutManager + From your fragment ```java mAdapter = new RecyclerViewMaterialAdapter(new ***Adapter(mList)); @@ -501,6 +510,9 @@ And must include @layout/material_view_pager_placeholder as first child #CHANGELOG +##1.2.0 +- header decorator instead of Adapter + ##1.1.3 - header is now clickable - fixed some scrolling issues diff --git a/build.gradle b/build.gradle index 3c8242b7..9bed12bb 100644 --- a/build.gradle +++ b/build.gradle @@ -4,38 +4,33 @@ buildscript { repositories { mavenCentral() jcenter() - maven { - url "http://dl.bintray.com/jfrog/jfrog-jars" - } + maven { url "http://dl.bintray.com/jfrog/jfrog-jars" } + maven { url 'https://maven.fabric.io/public' } } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' - classpath 'com.github.dcendents:android-maven-plugin:1.2' - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1" - classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+' + classpath 'com.android.tools.build:gradle:2.1.0' + classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1" + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + 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{ - ANDROID_BUILD_MIN_SDK_VERSION=10 - ANDROID_BUILD_TARGET_SDK_VERSION=22 - ANDROID_BUILD_TOOLS_VERSION='22.0.0' - ANDROID_BUILD_SDK_VERSION=22 - - SUPPORT_VERSION='22.2.1' - - MAVEN_VERSION='1.1.3' +ext { + minSdk = 10 + sdk = 23 + buildTools = "23.0.3" + supportVersion = "23.3.0" + libraryVersion = '1.2.0' } allprojects { repositories { jcenter() - maven { - url "http://dl.bintray.com/florent37/maven" - } + maven { url "http://dl.bintray.com/florent37/maven" } + maven { url 'https://maven.fabric.io/public' } } } diff --git a/gradle/bintray-android-v1.gradle b/gradle/bintray-android-v1.gradle new file mode 100644 index 00000000..0101dd55 --- /dev/null +++ b/gradle/bintray-android-v1.gradle @@ -0,0 +1,52 @@ +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 +} + +// Bintray +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + +bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + 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 = properties.getProperty("bintray.gpg.password") + //Optional. The passphrase for GPG signing' + } + } + } +} \ No newline at end of file diff --git a/gradle/bintray-java-v1.gradle b/gradle/bintray-java-v1.gradle new file mode 100644 index 00000000..67025d75 --- /dev/null +++ b/gradle/bintray-java-v1.gradle @@ -0,0 +1,49 @@ +apply plugin: 'com.jfrog.bintray' + +version = libraryVersion + +task sourcesJar(type: Jar) { + from sourceSets.main.allSource + classifier = 'sources' +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} +artifacts { + archives javadocJar + archives sourcesJar +} + +// Bintray +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + +bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + pkg { + repo = bintrayRepo + name = bintrayName + desc = libraryDescription + userOrg = orgName + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = ['Apache-2.0'] + publish = true + publicDownloadNumbers = true + version { + desc = libraryDescription + gpg { + sign = true //Determines whether to GPG sign the files. The default is false + passphrase = properties.getProperty("bintray.gpg.password") + //Optional. The passphrase for GPG signing' + } + } + } +} + +//from https://github.com/workarounds/bundler/blob/master/gradle/bintray-java-v1.gradle \ No newline at end of file diff --git a/gradle/install-v1.gradle b/gradle/install-v1.gradle new file mode 100644 index 00000000..79980d1d --- /dev/null +++ b/gradle/install-v1.gradle @@ -0,0 +1,44 @@ +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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c71e760..d5705170 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip diff --git a/materialviewpager/build.gradle b/materialviewpager/build.gradle index b8c1d62f..addb842d 100644 --- a/materialviewpager/build.gradle +++ b/materialviewpager/build.gradle @@ -1,18 +1,13 @@ -apply plugin: 'android-sdk-manager' apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.ben-manes.versions' -version = project.MAVEN_VERSION - android { - compileSdkVersion project.ANDROID_BUILD_SDK_VERSION - buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION + compileSdkVersion project.sdk + buildToolsVersion project.buildTools defaultConfig { - minSdkVersion project.ANDROID_BUILD_MIN_SDK_VERSION - targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION + minSdkVersion project.minSdk + targetSdkVersion project.sdk versionCode 1 versionName "1.0" } @@ -28,110 +23,47 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile ( - 'com.android.support:appcompat-v7:'+project.SUPPORT_VERSION, - 'com.android.support:support-v4:'+project.SUPPORT_VERSION, - 'com.android.support:recyclerview-v7:'+project.SUPPORT_VERSION, - 'com.android.support:cardview-v7:'+project.SUPPORT_VERSION, - 'com.android.support:support-annotations:'+project.SUPPORT_VERSION + 'com.android.support:appcompat-v7:'+project.supportVersion, + 'com.android.support:support-v4:'+project.supportVersion, + 'com.android.support:recyclerview-v7:'+project.supportVersion, + 'com.android.support:cardview-v7:'+project.supportVersion, + 'com.android.support:support-annotations:'+project.supportVersion ) compile 'com.nineoldandroids:library:2.4.0' - compile 'com.flaviofaria:kenburnsview:1.0.6' + compile 'com.flaviofaria:kenburnsview:1.0.7' compile 'com.jpardogo.materialtabstrip:library:1.1.0' - compile 'com.github.ksoichiro:android-observablescrollview:1.5.2' - compile 'com.squareup.picasso:picasso:2.5.2' + compile 'com.github.ksoichiro:android-observablescrollview:1.6.0' + compile 'com.github.bumptech.glide:glide:3.7.0' } +ext { + bintrayRepo = 'maven' + bintrayName = 'MaterialViewPager' + orgName = 'florent37' -//https://github.com/danielemaddaluno/gradle-jcenter-publish - -// ./gradlew install bintrayUpload - - -def siteUrl = 'https://github.com/florent37/MaterialViewPager' // Homepage URL of the library -def gitUrl = 'https://github.com/florent37/MaterialViewPager.git' // Git repository URL -group = "com.github.florent37" // Maven Group ID for the artifact + publishedGroupId = 'com.github.florent37' + libraryName = 'MaterialViewPager' + artifact = 'materialviewpager' + libraryDescription = 'MaterialViewPager' -install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging 'aar' + siteUrl = 'https://github.com/florent37/MaterialViewPager' + gitUrl = 'https://github.com/florent37/MaterialViewPager.git' - // Add your description here - name 'MaterialViewPager' - description = '' - url siteUrl + libraryVersion = rootProject.ext.libraryVersion - // Set your license - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id 'florent37' - name 'Florent Champigny' - email 'champigny.florent@gmail.com' - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - - } - } - } - } -} + developerId = 'florent37' + developerName = 'Florent Champigny' + developerEmail = 'champigny.florent@gmail.com' -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' + licenseName = 'The Apache Software License, Version 2.0' + licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + allLicenses = ["Apache-2.0"] } -artifacts { - archives sourcesJar +if (project.rootProject.file('local.properties').exists()) { + apply from: rootProject.file('gradle/install-v1.gradle') + apply from: rootProject.file('gradle/bintray-android-v1.gradle') } - -Properties properties = new Properties() -File f = new File("local.properties") -if(f.exists()) { - properties.load(project.rootProject.file('local.properties').newDataInputStream()) -} - -// https://github.com/bintray/gradle-bintray-plugin -bintray { - - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") - - configurations = ['archives'] - pkg { - repo = "maven" - // it is the name that appears in bintray when logged - name = "MaterialViewPager" - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = ["Apache-2.0"] - publish = true - version { - gpg { - sign = true //Determines whether to GPG sign the files. The default is false - passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing' - } -// mavenCentralSync { -// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central. -// user = properties.getProperty("bintray.oss.user") //OSS user token -// password = properties.getProperty("bintray.oss.password") //OSS user password -// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually. -// } - } - } -} \ No newline at end of file diff --git a/materialviewpager/materialviewpager.iml b/materialviewpager/materialviewpager.iml index c2ae7bb9..a323cf64 100644 --- a/materialviewpager/materialviewpager.iml +++ b/materialviewpager/materialviewpager.iml @@ -1,5 +1,5 @@ - + @@ -12,10 +12,7 @@ - + @@ -37,13 +34,13 @@ - + - + @@ -51,6 +48,15 @@ + + + + + + + + + @@ -58,6 +64,7 @@ + @@ -65,47 +72,55 @@ + + + + + + + + + + + + - - - - - - - - + + + + + + + - - - + + - - - - + - + - - + + - - - - + - - - - + + + + + + + + \ No newline at end of file diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java index 18d79ad8..ee24e609 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPager.java @@ -20,7 +20,7 @@ import com.astuetz.PagerSlidingTabStrip; import com.github.florent37.materialviewpager.header.HeaderDesign; import com.github.florent37.materialviewpager.header.MaterialViewPagerImageHelper; -import com.nineoldandroids.view.ViewHelper; +import android.support.v4.view.ViewCompat; /** * Created by florentchampigny on 28/04/15. @@ -32,26 +32,40 @@ */ 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; /** * 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 @@ -59,30 +73,6 @@ public class MaterialViewPager extends FrameLayout implements ViewPager.OnPageCh */ private ViewGroup logoContainer; - /** - * 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; - - //region construct - public MaterialViewPager(Context context) { super(context); } @@ -97,132 +87,41 @@ public MaterialViewPager(Context context, AttributeSet attrs, int 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); } - //endregion - - - @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)); - } + protected void onRestoreInstanceState(Parcelable state) { + SavedState ss = (SavedState) state; + super.onRestoreInstanceState(ss.getSuperState()); - 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); - } + this.settings = ss.settings; + if (headerBackground != null) { + headerBackground.setBackgroundColor(this.settings.color); } - 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); + MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(this.getContext()); - addView(sample); - } + //-1*ss.yOffset restore to 0 + animator.restoreScroll(-1 * ss.yOffset, ss.settings); + MaterialViewPagerHelper.register(getContext(), animator); } - private void initialiseHeights() { - if (headerBackground != null) { - headerBackground.setBackgroundColor(this.settings.color); + @Override + protected Parcelable onSaveInstanceState() { + Parcelable superState = super.onSaveInstanceState(); - 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); - } + SavedState ss = new SavedState(superState); + //end + ss.settings = this.settings; + ss.yOffset = MaterialViewPagerHelper.getAnimator(getContext()).lastYOffset; + + return ss; } /** @@ -247,18 +146,18 @@ public PagerSlidingTabStrip getPagerTitleStrip() { /** * Retrieve the displayed toolbar + * + * @return the displayed toolbar */ - public void setToolbar(Toolbar toolbar) { - mToolbar = toolbar; + public Toolbar getToolbar() { + return mToolbar; } /** * Retrieve the displayed toolbar - * - * @return the displayed toolbar */ - public Toolbar getToolbar() { - return mToolbar; + public void setToolbar(Toolbar toolbar) { + mToolbar = toolbar; } /** @@ -270,7 +169,7 @@ public void setImageUrl(String imageUrl, int fadeDuration) { final ImageView headerBackgroundImage = (ImageView) findViewById(R.id.materialviewpager_imageHeader); //if using MaterialViewPagerImageHeader if (headerBackgroundImage != null) { - ViewHelper.setAlpha(headerBackgroundImage, settings.headerAlpha); + ViewCompat.setAlpha(headerBackgroundImage, settings.headerAlpha); MaterialViewPagerImageHelper.setImageUrl(headerBackgroundImage, imageUrl, fadeDuration); setImageHeaderDarkLayerAlpha(); } @@ -282,12 +181,12 @@ public void setImageUrl(String imageUrl, int fadeDuration) { * may remove Picasso */ public void setImageUrl(String imageUrl, int fadeDuration, OnImageLoadListener imageLoadListener) { - if (imageLoadListener != null) + if (imageLoadListener != null) { MaterialViewPagerImageHelper.setImageLoadListener(imageLoadListener); + } setImageUrl(imageUrl, fadeDuration); } - /** * change the header displayed image with a fade * may remove Picasso @@ -297,7 +196,7 @@ public void setImageDrawable(Drawable drawable, int fadeDuration) { final ImageView headerBackgroundImage = (ImageView) findViewById(R.id.materialviewpager_imageHeader); //if using MaterialViewPagerImageHeader if (headerBackgroundImage != null) { - ViewHelper.setAlpha(headerBackgroundImage, settings.headerAlpha); + ViewCompat.setAlpha(headerBackgroundImage, settings.headerAlpha); MaterialViewPagerImageHelper.setImageDrawable(headerBackgroundImage, drawable, fadeDuration); setImageHeaderDarkLayerAlpha(); } @@ -312,7 +211,7 @@ public void setImageHeaderDarkLayerAlpha() { //if using MaterialViewPagerImageHeader if (headerImageDarkLayerView != null) { headerImageDarkLayerView.setBackgroundColor(getResources().getColor(android.R.color.black)); - ViewHelper.setAlpha(headerImageDarkLayerView, settings.imageHeaderDarkLayerAlpha); + ViewCompat.setAlpha(headerImageDarkLayerView, settings.imageHeaderDarkLayerAlpha); } } @@ -320,46 +219,15 @@ public void setImageHeaderDarkLayerAlpha() { * Change the header color */ public void setColor(int color, int fadeDuration) { - if (MaterialViewPagerHelper.getAnimator(getContext()) != null) + if (MaterialViewPagerHelper.getAnimator(getContext()) != null) { MaterialViewPagerHelper.getAnimator(getContext()).setColor(color, fadeDuration * 2); - } - - @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; - } - - @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); + } } public ViewGroup getHeaderBackgroundContainer() { return headerBackgroundContainer; } - //region ViewPagerOnPageListener - - int lastPosition = -1; - @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (positionOffset >= 0.5) { @@ -377,14 +245,18 @@ public void notifyHeaderChanged() { onPageSelected(position); } + //region ViewPagerOnPageListener + @Override public void onPageSelected(int position) { - if (position == lastPosition || listener == null) + if (position == lastPosition || listener == null) { return; + } HeaderDesign headerDesign = listener.getHeaderDesign(position); - if (headerDesign == null) + if (headerDesign == null) { return; + } int fadeDuration = 400; int color = headerDesign.getColor(); @@ -410,9 +282,152 @@ public void onPageScrollStateChanged(int state) { } } + 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 CREATOR = + new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; public MaterialViewPagerSettings settings; public float yOffset; @@ -432,30 +447,6 @@ public void writeToParcel(Parcel out, int flags) { out.writeParcelable(this.settings, flags); out.writeFloat(this.yOffset); } - - //required field that makes Parcelables from a Parcel - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator() { - public SavedState createFromParcel(Parcel in) { - return new SavedState(in); - } - - public SavedState[] newArray(int size) { - return new SavedState[size]; - } - }; - } - - public void setMaterialViewPagerListener(Listener listener) { - this.listener = listener; - } - - public interface Listener { - HeaderDesign getHeaderDesign(int page); - } - - public interface OnImageLoadListener { - void OnImageLoad(ImageView imageView, Bitmap bitmap); } } diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 8d8a4373..368746bb 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -18,7 +18,7 @@ import com.nineoldandroids.animation.ArgbEvaluator; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.animation.ValueAnimator; -import com.nineoldandroids.view.ViewHelper; +import android.support.v4.view.ViewCompat; import java.util.ArrayList; import java.util.HashMap; @@ -36,65 +36,49 @@ /** * Created by florentchampigny on 24/04/15. - * + *

* Listen to Scrollable inside MaterialViewPager * When notified scroll, dispatch the current scroll to other scrollable - * + *

* Note : didn't want to translate the MaterialViewPager or intercept Scroll, * so added a ViewPager with scrollables containing a transparent placeholder on top - * + *

* When scroll, animate the MaterialViewPager Header (toolbar, logo, color ...) */ public class MaterialViewPagerAnimator { private static final String TAG = MaterialViewPagerAnimator.class.getSimpleName(); - - public static Boolean ENABLE_LOG = true; - - private Context context; - - //contains MaterialViewPager subviews references - private MaterialViewPagerHeader mHeader; - //duration of translate header enter animation private static final int ENTER_TOOLBAR_ANIMATION_DURATION = 600; - - //reference to the current MaterialViewPager - protected MaterialViewPager materialViewPager; - + public static Boolean ENABLE_LOG = true; //final toolbar layout elevation (if attr viewpager_enableToolbarElevation = true) public final float elevation; - //max scroll which will be dispatched for all scrollable public final float scrollMax; - // equals scrollMax in DP (saved to avoir convert to dp anytime I use it) public final float scrollMaxDp; - + //reference to the current MaterialViewPager + protected MaterialViewPager materialViewPager; protected float lastYOffset = -1; //the current yOffset protected float lastPercent = 0; //the current Percent - //contains the attributes given to MaterialViewPager from layout protected MaterialViewPagerSettings settings; - //list of all registered scrollers protected List scrollViewList = new ArrayList<>(); - //save all yOffsets of scrollables protected HashMap yOffsets = new HashMap<>(); - - //the last headerYOffset during scroll - private float headerYOffset = Float.MAX_VALUE; - - //the tmp headerAnimator (not null if animating, else null) - private Object headerAnimator; - boolean followScrollToolbarIsVisible = false; float firstScrollValue = Float.MIN_VALUE; boolean justToolbarAnimated = false; - //intial distance between pager & toolbat float initialDistance = -1; + private Context context; + //contains MaterialViewPager subviews references + private MaterialViewPagerHeader mHeader; + //the last headerYOffset during scroll + private float headerYOffset = Float.MAX_VALUE; + //the tmp headerAnimator (not null if animating, else null) + private Object headerAnimator; public MaterialViewPagerAnimator(MaterialViewPager materialViewPager) { @@ -113,41 +97,6 @@ public MaterialViewPagerAnimator(MaterialViewPager materialViewPager) { elevation = dpToPx(4, context); } - /** - * When notified for scroll, dispatch it to all registered scrollables - * - * @param source - * @param yOffset - */ - protected 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); - } - } - } - } - - /** - * 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); - } - } - /** * Called when a scroller(RecyclerView/ListView,ScrollView,WebView) scrolled by the user * @@ -156,13 +105,14 @@ private void setScrollOffset(Object scroll, float yOffset) { */ public boolean onMaterialScrolled(Object source, float yOffset) { - if(initialDistance == -1 || initialDistance == 0) { + if (initialDistance == -1 || initialDistance == 0) { initialDistance = mHeader.mPagerSlidingTabStrip.getTop() - mHeader.toolbar.getBottom(); } //only if yOffset changed - if (yOffset == lastYOffset) + if (yOffset == lastYOffset) { return false; + } float scrollTop = -yOffset; @@ -170,44 +120,50 @@ public boolean onMaterialScrolled(Object source, float yOffset) { //parallax scroll of the Background ImageView (the KenBurnsView) if (mHeader.headerBackground != null) { - if (this.settings.parallaxHeaderFactor != 0) - ViewHelper.setTranslationY(mHeader.headerBackground, scrollTop / this.settings.parallaxHeaderFactor); + if (this.settings.parallaxHeaderFactor != 0) { + ViewCompat.setTranslationY(mHeader.headerBackground, scrollTop / this.settings.parallaxHeaderFactor); + } - if (ViewHelper.getY(mHeader.headerBackground) >= 0) - ViewHelper.setY(mHeader.headerBackground, 0); + if (ViewCompat.getY(mHeader.headerBackground) >= 0) { + ViewCompat.setY(mHeader.headerBackground, 0); + } } - } - if (ENABLE_LOG) + if (ENABLE_LOG) { Log.d("yOffset", "" + yOffset); + } //dispatch the new offset to all registered scrollables dispatchScrollOffset(source, minMax(0, yOffset, scrollMaxDp)); float percent = yOffset / scrollMax; - if (ENABLE_LOG) + if (ENABLE_LOG) { Log.d("percent1", "" + percent); + } - if(percent != 0) { + if (percent != 0) { //distance between pager & toolbar - float newDistance = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom(); + float newDistance = ViewCompat.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom(); percent = 1 - newDistance / initialDistance; - if (ENABLE_LOG) + if (ENABLE_LOG) { Log.d("percent2", "" + percent); + } } - if(Float.isNaN(percent)) //fix for orientation change + if (Float.isNaN(percent)) //fix for orientation change + { return false; + } //fix quick scroll - if(percent == 0 && headerAnimator != null) { + if (percent == 0 && headerAnimator != null) { cancelHeaderAnimator(); - ViewHelper.setTranslationY(mHeader.toolbarLayout,0); + ViewCompat.setTranslationY(mHeader.toolbarLayout, 0); } percent = minMax(0, percent, 1); @@ -218,9 +174,9 @@ public boolean onMaterialScrolled(Object source, float yOffset) { setColorPercent(percent); } else { if (justToolbarAnimated) { - if (toolbarJoinsTabs()) + if (toolbarJoinsTabs()) { setColorPercent(1); - else if (lastPercent != percent) { + } else if (lastPercent != percent) { animateColorPercent(0, 200); } } @@ -229,36 +185,35 @@ else if (lastPercent != percent) { lastPercent = percent; //save the percent if (mHeader.mPagerSlidingTabStrip != null) { //move the viewpager indicator - //float newY = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) + scrollTop; + //float newY = ViewCompat.getY(mHeader.mPagerSlidingTabStrip) + scrollTop; - if (ENABLE_LOG) + if (ENABLE_LOG) { Log.d(TAG, "" + scrollTop); - + } //mHeader.mPagerSlidingTabStrip.setTranslationY(mHeader.getToolbar().getBottom()-mHeader.mPagerSlidingTabStrip.getY()); if (scrollTop <= 0) { - ViewHelper.setTranslationY(mHeader.mPagerSlidingTabStrip, scrollTop); - ViewHelper.setTranslationY(mHeader.toolbarLayoutBackground, scrollTop); + ViewCompat.setTranslationY(mHeader.mPagerSlidingTabStrip, scrollTop); + ViewCompat.setTranslationY(mHeader.toolbarLayoutBackground, scrollTop); //when - if (ViewHelper.getY(mHeader.mPagerSlidingTabStrip) < mHeader.getToolbar().getBottom()) { + if (ViewCompat.getY(mHeader.mPagerSlidingTabStrip) < mHeader.getToolbar().getBottom()) { float ty = mHeader.getToolbar().getBottom() - mHeader.mPagerSlidingTabStrip.getTop(); - ViewHelper.setTranslationY(mHeader.mPagerSlidingTabStrip, ty); - ViewHelper.setTranslationY(mHeader.toolbarLayoutBackground, ty); + ViewCompat.setTranslationY(mHeader.mPagerSlidingTabStrip, ty); + ViewCompat.setTranslationY(mHeader.toolbarLayoutBackground, ty); } } } - if (mHeader.mLogo != null) { //move the header logo to toolbar if (this.settings.hideLogoWithFade) { - ViewHelper.setAlpha(mHeader.mLogo, 1 - percent); - ViewHelper.setTranslationY(mHeader.mLogo, (mHeader.finalTitleY - mHeader.originalTitleY) * percent); + ViewCompat.setAlpha(mHeader.mLogo, 1 - percent); + ViewCompat.setTranslationY(mHeader.mLogo, (mHeader.finalTitleY - mHeader.originalTitleY) * percent); } else { - ViewHelper.setTranslationY(mHeader.mLogo, (mHeader.finalTitleY - mHeader.originalTitleY) * percent); - ViewHelper.setTranslationX(mHeader.mLogo, (mHeader.finalTitleX - mHeader.originalTitleX) * percent); + 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); @@ -285,38 +240,6 @@ else if (lastPercent != percent) { return true; } - private void cancelHeaderAnimator(){ - if(headerAnimator != null) { - if (headerAnimator instanceof ObjectAnimator) - ((ObjectAnimator) headerAnimator).cancel(); - else if (headerAnimator instanceof android.animation.ObjectAnimator) - ((android.animation.ObjectAnimator) headerAnimator).cancel(); - headerAnimator = null; - } - } - - private void scrollUp(float yOffset) { - if (ENABLE_LOG) - Log.d(TAG, "scrollUp"); - - followScrollToolbarLayout(yOffset); - } - - private void scrollDown(float yOffset) { - if (ENABLE_LOG) - Log.d(TAG, "scrollDown"); - if (yOffset > mHeader.toolbarLayout.getHeight() * 1.5f) { - animateEnterToolbarLayout(yOffset); - } else { - if (headerAnimator != null) { - followScrollToolbarIsVisible = true; - } else { - headerYOffset = Float.MAX_VALUE; - followScrollToolbarLayout(yOffset); - } - } - } - /** * Change the color of the statusbackground, toolbar, toolbarlayout and pagertitlestrip * With a color transition animation @@ -363,111 +286,34 @@ public void setColorPercent(float percent) { // toolbar & viewpager indicator & statusBaground setBackgroundColor( - colorWithAlpha(this.settings.color, percent), - mHeader.statusBackground + colorWithAlpha(this.settings.color, percent), + mHeader.statusBackground ); if (percent >= 1) { setBackgroundColor( - colorWithAlpha(this.settings.color, percent), - mHeader.toolbar, - mHeader.toolbarLayoutBackground, - mHeader.mPagerSlidingTabStrip + colorWithAlpha(this.settings.color, percent), + mHeader.toolbar, + mHeader.toolbarLayoutBackground, + mHeader.mPagerSlidingTabStrip ); } else { setBackgroundColor( - colorWithAlpha(this.settings.color, 0), - mHeader.toolbar, - mHeader.toolbarLayoutBackground, - mHeader.mPagerSlidingTabStrip + colorWithAlpha(this.settings.color, 0), + mHeader.toolbar, + mHeader.toolbarLayoutBackground, + mHeader.mPagerSlidingTabStrip ); } - if (this.settings.enableToolbarElevation && toolbarJoinsTabs()) + if (this.settings.enableToolbarElevation && toolbarJoinsTabs()) { setElevation( - (percent == 1) ? elevation : 0, - mHeader.toolbar, - mHeader.toolbarLayoutBackground, - mHeader.mPagerSlidingTabStrip, - mHeader.mLogo + (percent == 1) ? elevation : 0, + mHeader.toolbar, + mHeader.toolbarLayoutBackground, + mHeader.mPagerSlidingTabStrip, + mHeader.mLogo ); - } - - private boolean toolbarJoinsTabs() { - return (mHeader.toolbar.getBottom() == mHeader.mPagerSlidingTabStrip.getTop() + ViewHelper.getTranslationY(mHeader.mPagerSlidingTabStrip)); - } - - /** - * 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; - } - - if (ENABLE_LOG) - Log.d(TAG, "translationY " + translationY); - - ViewHelper.setTranslationY(mHeader.toolbarLayout, translationY); - } else { - ViewHelper.setTranslationY(mHeader.toolbarLayout, 0); - justToolbarAnimated = false; - } - - followScrollToolbarIsVisible = (ViewHelper.getY(mHeader.toolbarLayout) >= 0); - } - - /** - * Animate enter toolbarlayout - * - * @param yOffset - */ - private void animateEnterToolbarLayout(float yOffset) { - if (!followScrollToolbarIsVisible && headerAnimator != null) { - if (headerAnimator instanceof ObjectAnimator) - ((ObjectAnimator) headerAnimator).cancel(); - else if (headerAnimator instanceof android.animation.ObjectAnimator) - ((android.animation.ObjectAnimator) headerAnimator).cancel(); - headerAnimator = null; - } - - if (headerAnimator == null) { - if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { - headerAnimator = android.animation.ObjectAnimator.ofFloat(mHeader.toolbarLayout, "translationY", 0).setDuration(ENTER_TOOLBAR_ANIMATION_DURATION); - ((android.animation.ObjectAnimator) 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; - } - }); - ((android.animation.ObjectAnimator) headerAnimator).start(); - } else { - headerAnimator = ObjectAnimator.ofFloat(mHeader.toolbarLayout, "translationY", 0).setDuration(ENTER_TOOLBAR_ANIMATION_DURATION); - ((ObjectAnimator) headerAnimator).addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - followScrollToolbarIsVisible = true; - firstScrollValue = Float.MIN_VALUE; - justToolbarAnimated = true; - } - }); - ((ObjectAnimator) headerAnimator).start(); - } - headerYOffset = yOffset; } } @@ -475,15 +321,6 @@ public int getHeaderHeight() { return this.settings.headerHeight; } - protected boolean isNewYOffset(int yOffset) { - if (lastYOffset == -1) - return true; - else - return yOffset != lastYOffset; - } - - //region register scrollables - /** * Register a RecyclerView to the current MaterialViewPagerAnimator * Listen to RecyclerView.OnScrollListener so give to $[onScrollListener] your RecyclerView.OnScrollListener if you already use one @@ -493,7 +330,7 @@ protected boolean isNewYOffset(int yOffset) { * @param onScrollListener use it if you want to get a callback of the RecyclerView */ public void registerRecyclerView(final RecyclerView recyclerView, final RecyclerView.OnScrollListener onScrollListener) { - if (recyclerView != null) { + 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 @@ -506,16 +343,18 @@ public void registerRecyclerView(final RecyclerView recyclerView, final Recycler @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); - if (onScrollListener != null) + if (onScrollListener != null) { onScrollListener.onScrollStateChanged(recyclerView, newState); + } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); - if (onScrollListener != null) + if (onScrollListener != null) { onScrollListener.onScrolled(recyclerView, dx, dy); + } int yOffset = yOffsets.get(recyclerView); @@ -529,8 +368,9 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { } //only if yOffset changed - if (isNewYOffset(yOffset)) + if (isNewYOffset(yOffset)) { onMaterialScrolled(recyclerView, yOffset); + } } }); @@ -554,16 +394,18 @@ public void run() { public void registerScrollView(final ObservableScrollView scrollView, final ObservableScrollViewCallbacks observableScrollViewCallbacks) { if (scrollView != null) { scrollViewList.add(scrollView); //add to the scrollable list - if (scrollView.getParent() != null && scrollView.getParent().getParent() != null && scrollView.getParent().getParent() instanceof ViewGroup) + if (scrollView.getParent() != null && scrollView.getParent().getParent() != null && scrollView.getParent().getParent() instanceof ViewGroup) { scrollView.setTouchInterceptionViewGroup((ViewGroup) scrollView.getParent().getParent()); + } scrollView.setScrollViewCallbacks(new ObservableScrollViewCallbacks() { boolean firstZeroPassed; @Override public void onScrollChanged(int yOffset, boolean b, boolean b2) { - if (observableScrollViewCallbacks != null) + if (observableScrollViewCallbacks != null) { observableScrollViewCallbacks.onScrollChanged(yOffset, b, b2); + } //first time you get 0, don't share it to others scrolls if (yOffset == 0 && !firstZeroPassed) { @@ -572,20 +414,23 @@ public void onScrollChanged(int yOffset, boolean b, boolean b2) { } //only if yOffset changed - if (isNewYOffset(yOffset)) + if (isNewYOffset(yOffset)) { onMaterialScrolled(scrollView, yOffset); + } } @Override public void onDownMotionEvent() { - if (observableScrollViewCallbacks != null) + if (observableScrollViewCallbacks != null) { observableScrollViewCallbacks.onDownMotionEvent(); + } } @Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { - if (observableScrollViewCallbacks != null) + if (observableScrollViewCallbacks != null) { observableScrollViewCallbacks.onUpOrCancelMotionEvent(scrollState); + } } }); @@ -608,29 +453,34 @@ public void run() { */ public void registerWebView(final ObservableWebView webView, final ObservableScrollViewCallbacks observableScrollViewCallbacks) { if (webView != null) { - if (scrollViewList.isEmpty()) + if (scrollViewList.isEmpty()) { onMaterialScrolled(webView, webView.getCurrentScrollY()); + } scrollViewList.add(webView); //add to the scrollable list webView.setScrollViewCallbacks(new ObservableScrollViewCallbacks() { @Override public void onScrollChanged(int yOffset, boolean b, boolean b2) { - if (observableScrollViewCallbacks != null) + if (observableScrollViewCallbacks != null) { observableScrollViewCallbacks.onScrollChanged(yOffset, b, b2); + } - if (isNewYOffset(yOffset)) + if (isNewYOffset(yOffset)) { onMaterialScrolled(webView, yOffset); + } } @Override public void onDownMotionEvent() { - if (observableScrollViewCallbacks != null) + if (observableScrollViewCallbacks != null) { observableScrollViewCallbacks.onDownMotionEvent(); + } } @Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { - if (observableScrollViewCallbacks != null) + if (observableScrollViewCallbacks != null) { observableScrollViewCallbacks.onUpOrCancelMotionEvent(scrollState); + } } }); @@ -638,18 +488,16 @@ public void onUpOrCancelMotionEvent(ScrollState scrollState) { } } - //endregion - public 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); + if (!onMaterialScrolled(null, scroll)) { + restoreScroll(scroll, settings); } } - },100); + }, 100); } @@ -662,4 +510,168 @@ public void onViewPagerPageChanged() { onMaterialScrolled(visibleView, 0); } } + + /** + * When notified for scroll, dispatch it to all registered scrollables + * + * @param source + * @param yOffset + */ + protected 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); + } + } + } + } + + protected 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) { + if (headerAnimator instanceof ObjectAnimator) { + ((ObjectAnimator) headerAnimator).cancel(); + } else if (headerAnimator instanceof android.animation.ObjectAnimator) { + ((android.animation.ObjectAnimator) headerAnimator).cancel(); + } + headerAnimator = null; + } + } + + //region register scrollables + + private void scrollUp(float yOffset) { + if (ENABLE_LOG) { + Log.d(TAG, "scrollUp"); + } + + followScrollToolbarLayout(yOffset); + } + + private void scrollDown(float yOffset) { + if (ENABLE_LOG) { + Log.d(TAG, "scrollDown"); + } + if (yOffset > mHeader.toolbarLayout.getHeight() * 1.5f) { + animateEnterToolbarLayout(yOffset); + } else { + if (headerAnimator != null) { + followScrollToolbarIsVisible = true; + } else { + headerYOffset = Float.MAX_VALUE; + 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; + } + + if (ENABLE_LOG) { + Log.d(TAG, "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) { + if (headerAnimator instanceof ObjectAnimator) { + ((ObjectAnimator) headerAnimator).cancel(); + } else if (headerAnimator instanceof android.animation.ObjectAnimator) { + ((android.animation.ObjectAnimator) headerAnimator).cancel(); + } + headerAnimator = null; + } + + if (headerAnimator == null) { + if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { + headerAnimator = android.animation.ObjectAnimator.ofFloat(mHeader.toolbarLayout, "translationY", 0).setDuration(ENTER_TOOLBAR_ANIMATION_DURATION); + ((android.animation.ObjectAnimator) 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; + } + }); + ((android.animation.ObjectAnimator) headerAnimator).start(); + } else { + headerAnimator = ObjectAnimator.ofFloat(mHeader.toolbarLayout, "translationY", 0).setDuration(ENTER_TOOLBAR_ANIMATION_DURATION); + ((ObjectAnimator) headerAnimator).addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + followScrollToolbarIsVisible = true; + firstScrollValue = Float.MIN_VALUE; + justToolbarAnimated = true; + } + }); + ((ObjectAnimator) headerAnimator).start(); + } + headerYOffset = yOffset; + } + } } diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java index 67a9966a..2f2b402c 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHeader.java @@ -1,11 +1,12 @@ 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 com.nineoldandroids.view.ViewHelper; +import android.support.v4.view.ViewCompat; import static com.github.florent37.materialviewpager.Utils.dpToPx; @@ -101,11 +102,11 @@ public MaterialViewPagerHeader withLogo(View logo) { @Override public boolean onPreDraw() { //rotation fix, if not set, originalTitleY = Na - ViewHelper.setTranslationY(mLogo,0); - ViewHelper.setTranslationX(mLogo, 0); + ViewCompat.setTranslationY(mLogo,0); + ViewCompat.setTranslationX(mLogo, 0); - originalTitleY = ViewHelper.getY(mLogo); - originalTitleX = ViewHelper.getX(mLogo); + originalTitleY = ViewCompat.getY(mLogo); + originalTitleX = ViewCompat.getX(mLogo); originalTitleHeight = mLogo.getHeight(); finalTitleHeight = dpToPx(21, context); diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java index 2670c9be..fd307bde 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerHelper.java @@ -3,6 +3,7 @@ import android.app.Activity; import android.content.Context; import android.graphics.Color; +import android.support.v4.view.ViewCompat; import android.support.v7.widget.RecyclerView; import android.view.View; import android.webkit.WebSettings; @@ -11,13 +12,12 @@ import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks; import com.github.ksoichiro.android.observablescrollview.ObservableWebView; -import com.nineoldandroids.animation.ObjectAnimator; import java.util.concurrent.ConcurrentHashMap; /** * Created by florentchampigny on 25/04/15. - * + *

* 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 @@ -37,8 +37,9 @@ public static void register(Context context, MaterialViewPagerAnimator animator) } public static void unregister(Context context) { - if (context != null) + if (context != null) { hashMap.remove(context); + } } /** @@ -46,13 +47,13 @@ public static void unregister(Context context) { * Listen to RecyclerView.OnScrollListener so give to $[onScrollListener] your RecyclerView.OnScrollListener if you already use one * For loadmore or anything else * - * @param activity current context + * @param context current context * @param recyclerView the scrollable * @param onScrollListener use it if you want to get a callback of the RecyclerView */ - public static void registerRecyclerView(Activity activity, RecyclerView recyclerView, RecyclerView.OnScrollListener onScrollListener) { - if (activity != null && hashMap.containsKey(activity)) { - MaterialViewPagerAnimator animator = hashMap.get(activity); + public static void registerRecyclerView(Context context, RecyclerView recyclerView, RecyclerView.OnScrollListener onScrollListener) { + if (context != null && hashMap.containsKey(context)) { + MaterialViewPagerAnimator animator = hashMap.get(context); if (animator != null) { animator.registerRecyclerView(recyclerView, onScrollListener); } @@ -105,14 +106,6 @@ public static MaterialViewPagerAnimator getAnimator(Context context) { return hashMap.get(context); } - private static void webViewLoadJS(WebView webView, String js){ - if (android.os.Build.VERSION.SDK_INT >= 19) { - webView.evaluateJavascript(js, null); - }else{ - webView.loadUrl("javascript: " + js); - } - } - /** * Have to be called from WebView.WebViewClient.onPageFinished * ex : mWebView.setWebViewClient(new WebViewClient() { onPageFinished(WebView view, String url) { [HERE] }}); @@ -149,17 +142,19 @@ public static void injectHeader(final WebView webView, boolean withAnimation) { { final String js = "document.body.style.backround-color= white"; - webViewLoadJS(webView,js); + webViewLoadJS(webView, js); } - if (withAnimation) + if (withAnimation) { webView.postDelayed(new Runnable() { @Override public void run() { webView.setVisibility(View.VISIBLE); - ObjectAnimator.ofFloat(webView, "alpha", 0, 1).start(); + ViewCompat.setAlpha(webView, 0f); + ViewCompat.animate(webView).withLayer().alpha(1); } }, 400); + } } } } @@ -173,4 +168,12 @@ public static void preLoadInjectHeader(WebView mWebView) { mWebView.setVisibility(View.INVISIBLE); } + private static void webViewLoadJS(WebView webView, String js) { + if (android.os.Build.VERSION.SDK_INT >= 19) { + webView.evaluateJavascript(js, null); + } else { + webView.loadUrl("javascript: " + js); + } + } + } diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java index a8786f9f..cec68103 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerSettings.java @@ -10,7 +10,7 @@ /** * Created by florentchampigny on 29/04/15. - * + *

* Save attributes given to MaterialViewPager from layout */ public class MaterialViewPagerSettings implements Parcelable { @@ -18,23 +18,27 @@ 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 CREATOR = new Parcelable.Creator() { + public MaterialViewPagerSettings createFromParcel(Parcel source) { + return new MaterialViewPagerSettings(source); + } + + public MaterialViewPagerSettings[] newArray(int size) { + return new MaterialViewPagerSettings[size]; + } + }; protected int headerLayoutId; protected int pagerTitleStripId; protected int viewpagerId; - protected int logoLayoutId; protected int logoMarginTop; - protected int headerAdditionalHeight; - protected int headerHeight; protected int headerHeightPx; protected int color; - protected float headerAlpha; protected float parallaxHeaderFactor; protected float imageHeaderDarkLayerAlpha; - protected boolean hideToolbarAndTitle; protected boolean hideLogoWithFade; protected boolean enableToolbarElevation; @@ -43,12 +47,60 @@ public class MaterialViewPagerSettings implements Parcelable { protected boolean animatedHeaderImage; protected 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 */ - protected void handleAttributes(Context context, AttributeSet attrs){ + protected void handleAttributes(Context context, AttributeSet attrs) { try { TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.MaterialViewPager); { @@ -56,8 +108,9 @@ protected void handleAttributes(Context context, AttributeSet attrs){ } { pagerTitleStripId = styledAttrs.getResourceId(R.styleable.MaterialViewPager_viewpager_pagerTitleStrip, -1); - if(pagerTitleStripId == -1) + if (pagerTitleStripId == -1) { pagerTitleStripId = R.layout.material_view_pager_pagertitlestrip_standard; + } } { viewpagerId = styledAttrs.getResourceId(R.styleable.MaterialViewPager_viewpager_viewpager, -1); @@ -111,62 +164,5 @@ protected void handleAttributes(Context context, AttributeSet attrs){ } } - //region parcelable - - @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); - } - - 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; - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public MaterialViewPagerSettings createFromParcel(Parcel source) { - return new MaterialViewPagerSettings(source); - } - - public MaterialViewPagerSettings[] newArray(int size) { - return new MaterialViewPagerSettings[size]; - } - }; - //endregion } diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/Utils.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/Utils.java index 117b81bd..12c9da0a 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/Utils.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/Utils.java @@ -12,7 +12,7 @@ import android.widget.ListView; import android.widget.ScrollView; -import com.nineoldandroids.view.ViewHelper; +import android.support.v4.view.ViewCompat; import java.util.List; @@ -53,7 +53,6 @@ public static float minMax(float min, float value, float max) { return value; } - /** * modify the scale of multiples views * @@ -63,8 +62,8 @@ public static float minMax(float min, float value, float max) { public static void setScale(float scale, View... views) { for (View view : views) { if (view != null) { - ViewHelper.setScaleX(view, scale); - ViewHelper.setScaleY(view, scale); + ViewCompat.setScaleX(view, scale); + ViewCompat.setScaleY(view, scale); } } } @@ -77,8 +76,9 @@ public static void setScale(float scale, View... views) { */ public static void setElevation(float elevation, View... views) { for (View view : views) { - if (view != null) + if (view != null) { ViewCompat.setElevation(view, elevation); + } } } @@ -90,29 +90,30 @@ public static void setElevation(float elevation, View... views) { */ public static void setBackgroundColor(int color, View... views) { for (View view : views) { - if (view != null) + if (view != null) { view.setBackgroundColor(color); + } } } public static boolean canScroll(View view) { - if(view instanceof ScrollView) { - ScrollView scrollView = (ScrollView)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; + } 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){ + public static void scrollTo(Object scroll, float yOffset) { if (scroll instanceof RecyclerView) { //RecyclerView.scrollTo : UnsupportedOperationException //Moved to the RecyclerView.LayoutManager.scrollToPositionWithOffset diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java index b9db9da9..325475bb 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/adapter/RecyclerViewMaterialAdapter.java @@ -10,7 +10,10 @@ /** * Created by florentchampigny on 24/04/15. * A RecyclerView.Adapter which inject a header to the actual RecyclerView.Adapter + * + * Please use now MaterialViewPagerDecorator, or with Stagged Layout Manager */ +@Deprecated public class RecyclerViewMaterialAdapter extends RecyclerView.Adapter { //the constants value of the header view diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerHEaderDecorator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerHEaderDecorator.java new file mode 100644 index 00000000..a3a0a913 --- /dev/null +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerHEaderDecorator.java @@ -0,0 +1,47 @@ +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, null); + 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)); + } + } + } +} diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHeader.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHeader.java index 9d7c2e88..2988e65a 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHeader.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHeader.java @@ -3,17 +3,8 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.util.AttributeSet; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.DecelerateInterpolator; -import android.widget.ImageView; import com.flaviofaria.kenburnsview.KenBurnsView; -import com.nineoldandroids.animation.Animator; -import com.nineoldandroids.animation.AnimatorListenerAdapter; -import com.nineoldandroids.animation.ObjectAnimator; -import com.nineoldandroids.view.ViewHelper; -import com.squareup.picasso.Callback; -import com.squareup.picasso.Picasso; /** * Created by florentchampigny on 29/04/15. @@ -41,10 +32,9 @@ public MaterialViewPagerImageHeader(Context context, AttributeSet attrs, int def /** * change the image with a fade - * @param urlImage - * @param fadeDuration * - * TODO : remove Picasso + * @param urlImage + * @param fadeDuration TODO : remove Picasso */ public void setImageUrl(final String urlImage, final int fadeDuration) { MaterialViewPagerImageHelper.setImageUrl(this, urlImage, fadeDuration); @@ -52,6 +42,7 @@ public void setImageUrl(final String urlImage, final int fadeDuration) { /** * change the image with a fade + * * @param drawable * @param fadeDuration */ diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java index 3daae416..5ca8d1bc 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerImageHelper.java @@ -2,17 +2,18 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +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.resource.drawable.GlideDrawable; +import com.bumptech.glide.request.RequestListener; +import com.bumptech.glide.request.target.Target; import com.github.florent37.materialviewpager.MaterialViewPager; -import com.nineoldandroids.animation.Animator; -import com.nineoldandroids.animation.AnimatorListenerAdapter; -import com.nineoldandroids.animation.ObjectAnimator; -import com.nineoldandroids.view.ViewHelper; -import com.squareup.picasso.Callback; -import com.squareup.picasso.Picasso; /** * Created by florentchampigny on 12/06/15. @@ -23,75 +24,86 @@ public class MaterialViewPagerImageHelper { /** * change the image with a fade - * @param urlImage - * @param fadeDuration * - * TODO : remove Picasso + * @param urlImage + * @param fadeDuration TODO : remove Picasso */ public static void setImageUrl(final ImageView imageView, final String urlImage, final int fadeDuration) { - final float alpha = ViewHelper.getAlpha(imageView); + final float alpha = ViewCompat.getAlpha(imageView); final ImageView viewToAnimate = imageView; //fade to alpha=0 - final ObjectAnimator fadeOut = ObjectAnimator.ofFloat(viewToAnimate, "alpha", 0).setDuration(fadeDuration); - fadeOut.setInterpolator(new DecelerateInterpolator()); - fadeOut.addListener(new AnimatorListenerAdapter() { + fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() { @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); + public void onAnimationEnd(View view) { + super.onAnimationEnd(view); //change the image when alpha=0 - Picasso.with(imageView.getContext()).load(urlImage) - .centerCrop().fit().into(viewToAnimate, new Callback() { - @Override - public void onSuccess() { - - //then fade to alpha=1 - final ObjectAnimator fadeIn = ObjectAnimator.ofFloat(viewToAnimate, "alpha", alpha).setDuration(fadeDuration); - fadeIn.setInterpolator(new AccelerateInterpolator()); - fadeIn.start(); - if(imageLoadListener!=null){ - imageLoadListener.OnImageLoad(imageView,((BitmapDrawable)imageView.getDrawable()).getBitmap()); + Glide.with(imageView.getContext()).load(urlImage) + .centerCrop() + .listener(new RequestListener() { + @Override + public boolean onException(Exception e, String model, Target target, boolean isFirstResource) { + return false; } - } - - @Override - public void onError() { - } - }); + @Override + public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) { + //then fade to alpha=1 + fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter()); + if (imageLoadListener != null) { + imageLoadListener.OnImageLoad(imageView, ((BitmapDrawable) imageView.getDrawable()).getBitmap()); + } + return false; + } + }) + .into(viewToAnimate); } }); - fadeOut.start(); + } + + 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 = ViewHelper.getAlpha(imageView); + final float alpha = ViewCompat.getAlpha(imageView); final ImageView viewToAnimate = imageView; - //fade to alpha=0 - final ObjectAnimator fadeOut = ObjectAnimator.ofFloat(viewToAnimate, "alpha", 0).setDuration(fadeDuration); - fadeOut.setInterpolator(new DecelerateInterpolator()); - fadeOut.addListener(new AnimatorListenerAdapter() { + fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() { @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); + public void onAnimationEnd(View view) { + super.onAnimationEnd(view); //change the image when alpha=0 imageView.setImageDrawable(drawable); //then fade to alpha=1 - final ObjectAnimator fadeIn = ObjectAnimator.ofFloat(viewToAnimate, "alpha", alpha).setDuration(fadeDuration); - fadeIn.setInterpolator(new AccelerateInterpolator()); - fadeIn.start(); + fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter()); } }); - fadeOut.start(); } public static void setImageLoadListener(MaterialViewPager.OnImageLoadListener imageLoadListener) { diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerKenBurnsHeader.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerKenBurnsHeader.java index a21980ad..fab20264 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerKenBurnsHeader.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/header/MaterialViewPagerKenBurnsHeader.java @@ -3,17 +3,8 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.util.AttributeSet; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.DecelerateInterpolator; -import android.widget.ImageView; import com.flaviofaria.kenburnsview.KenBurnsView; -import com.nineoldandroids.animation.Animator; -import com.nineoldandroids.animation.AnimatorListenerAdapter; -import com.nineoldandroids.animation.ObjectAnimator; -import com.nineoldandroids.view.ViewHelper; -import com.squareup.picasso.Callback; -import com.squareup.picasso.Picasso; /** * Created by florentchampigny on 29/04/15. @@ -41,10 +32,9 @@ public MaterialViewPagerKenBurnsHeader(Context context, AttributeSet attrs, int /** * change the image with a fade - * @param urlImage - * @param fadeDuration * - * TODO : remove Picasso + * @param urlImage + * @param fadeDuration TODO : remove Picasso */ public void setImageUrl(final String urlImage, final int fadeDuration) { MaterialViewPagerImageHelper.setImageUrl(this, urlImage, fadeDuration); @@ -52,11 +42,12 @@ public void setImageUrl(final String urlImage, final int 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); + MaterialViewPagerImageHelper.setImageDrawable(this, drawable, fadeDuration); } } diff --git a/materialviewpagercontroller/build.gradle b/materialviewpagercontroller/build.gradle index b025c3be..34f71f99 100644 --- a/materialviewpagercontroller/build.gradle +++ b/materialviewpagercontroller/build.gradle @@ -1,16 +1,12 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'com.jfrog.bintray' - -version = project.MAVEN_VERSION android { - compileSdkVersion project.ANDROID_BUILD_SDK_VERSION - buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION + compileSdkVersion project.sdk + buildToolsVersion project.buildTools defaultConfig { - minSdkVersion project.ANDROID_BUILD_MIN_SDK_VERSION - targetSdkVersion project.ANDROID_BUILD_TARGET_SDK_VERSION + minSdkVersion project.minSdk + targetSdkVersion project.sdk versionCode 1 versionName "1.0" } @@ -24,7 +20,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.2.1' + compile 'com.android.support:appcompat-v7:'+project.supportVersion compile ('com.github.florent37:carpaccio:1.0.1@aar') { transitive = true @@ -35,101 +31,32 @@ dependencies { } } +ext { + bintrayRepo = 'maven' + bintrayName = 'MaterialViewPagerController' + orgName = 'florent37' -def siteUrl = 'https://github.com/florent37/MaterialViewPager' // Homepage URL of the library -def gitUrl = 'https://github.com/florent37/MaterialViewPager.git' // Git repository URL -group = "com.github.florent37" // Maven Group ID for the artifact - + publishedGroupId = 'com.github.florent37' + libraryName = 'MaterialViewPagerController' + artifact = 'materialviewpagercontroller' -install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging 'aar' + libraryDescription = 'MaterialViewPagerController' - // Add your description here - name 'MaterialViewPagerContoller' - description = '' - url siteUrl + siteUrl = 'https://github.com/florent37/MaterialViewPagerController' + gitUrl = 'https://github.com/florent37/MaterialViewPagerController.git' - // Set your license - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id 'florent37' - name 'Florent Champigny' - email 'champigny.florent@gmail.com' - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl + libraryVersion = rootProject.ext.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)) -} + developerId = 'florent37' + developerName = 'Florent Champigny' + developerEmail = 'champigny.florent@gmail.com' -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir + licenseName = 'The Apache Software License, Version 2.0' + licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + allLicenses = ["Apache-2.0"] } -artifacts { - archives javadocJar - archives sourcesJar -} - -Properties properties = new Properties() -File f = new File("local.properties") -if(f.exists()) { - properties.load(project.rootProject.file('local.properties').newDataInputStream()) -} - -// https://github.com/bintray/gradle-bintray-plugin -bintray { - - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") - - configurations = ['archives'] - pkg { - repo = "maven" - // it is the name that appears in bintray when logged - name = "MaterialViewPagerContoller" - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = ["Apache-2.0"] - publish = true - version { - gpg { - sign = true //Determines whether to GPG sign the files. The default is false - passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing' - } -// mavenCentralSync { -// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central. -// user = properties.getProperty("bintray.oss.user") //OSS user token -// password = properties.getProperty("bintray.oss.password") //OSS user password -// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually. -// } - } - } +if (project.rootProject.file('local.properties').exists()) { + apply from: rootProject.file('gradle/install-v1.gradle') + apply from: rootProject.file('gradle/bintray-android-v1.gradle') } diff --git a/materialviewpagercontroller/materialviewpagercontroller.iml b/materialviewpagercontroller/materialviewpagercontroller.iml index 82c2eada..6119a756 100644 --- a/materialviewpagercontroller/materialviewpagercontroller.iml +++ b/materialviewpagercontroller/materialviewpagercontroller.iml @@ -1,5 +1,5 @@ - + @@ -12,10 +12,7 @@ - + @@ -37,13 +34,13 @@ - + - + @@ -51,6 +48,15 @@ + + + + + + + + + @@ -58,6 +64,15 @@ + + + + + + + + + @@ -65,52 +80,51 @@ - + + + - - - + + - + + - - - + + - - - - + - + - - + - - - - + + + + + + \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 8d045952..d4cb910c 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,29 +1,13 @@ -apply plugin: 'android-sdk-manager' apply plugin: 'com.android.application' - -buildscript { - repositories { - maven { url 'https://maven.fabric.io/public' } - } - - dependencies { - classpath 'io.fabric.tools:gradle:1.+' - } -} - apply plugin: 'io.fabric' -repositories { - maven { url 'https://maven.fabric.io/public' } -} - android { - compileSdkVersion project.ANDROID_BUILD_SDK_VERSION - buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION + compileSdkVersion project.sdk + buildToolsVersion project.buildTools defaultConfig { - minSdkVersion project.ANDROID_BUILD_MIN_SDK_VERSION - targetSdkVersion project.ANDROID_BUILD_TARGET_SDK_VERSION + minSdkVersion project.minSdk + targetSdkVersion project.sdk versionCode 4 versionName "1.0" } @@ -62,8 +46,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:'+project.SUPPORT_VERSION - compile 'com.android.support:cardview-v7:'+project.SUPPORT_VERSION + compile 'com.android.support:appcompat-v7:'+project.supportVersion + compile 'com.android.support:cardview-v7:'+project.supportVersion //compile ('com.github.florent37:materialviewpager:1.0.6@aar'){ // transitive=true diff --git a/sample/sample.iml b/sample/sample.iml index 87ba5cef..470eaaaf 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -12,10 +12,7 @@