From 4dc777acf7f9d032600f3fd0d5694412272a38b6 Mon Sep 17 00:00:00 2001 From: ChengXi <505591443@qq.com> Date: Sun, 15 Jun 2014 18:26:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/libraries/support_v4_19_0_1.xml | 11 ++ .idea/libraries/support_v4_19_1_0.xml | 11 -- .idea/misc.xml | 131 ++++-------------- GuideBackgroundColorAnimation.iml | 1 - build.gradle | 2 +- build/intermediates/dex-cache/cache.xml | 17 +++ .../library/unspecified/AndroidManifest.xml | 17 +++ .../library/unspecified/R.txt | 7 + .../library/unspecified/classes.jar | Bin 0 -> 5058 bytes .../res/drawable-hdpi-v4/ic_launcher.png | Bin 0 -> 9397 bytes .../res/drawable-mdpi-v4/ic_launcher.png | Bin 0 -> 5237 bytes .../res/drawable-xhdpi-v4/ic_launcher.png | Bin 0 -> 14383 bytes .../res/drawable-xxhdpi-v4/ic_launcher.png | Bin 0 -> 19388 bytes .../unspecified/res/layout/activity_main.xml | 17 +++ .../res/values-w820dp-v13/values.xml | 9 ++ .../library/unspecified/res/values/values.xml | 16 +++ gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 3 +- library/library.iml | 36 ++--- .../library/ColorAnimationView.java | 41 +++--- sample/build.gradle | 2 +- sample/sample.iml | 37 ++--- .../sample/SampleActivity.java | 37 +++-- 23 files changed, 185 insertions(+), 212 deletions(-) create mode 100644 .idea/libraries/support_v4_19_0_1.xml delete mode 100644 .idea/libraries/support_v4_19_1_0.xml create mode 100644 build/intermediates/dex-cache/cache.xml create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/AndroidManifest.xml create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/R.txt create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/classes.jar create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/res/drawable-hdpi-v4/ic_launcher.png create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/res/drawable-mdpi-v4/ic_launcher.png create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/res/drawable-xhdpi-v4/ic_launcher.png create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/res/drawable-xxhdpi-v4/ic_launcher.png create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/res/layout/activity_main.xml create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/res/values-w820dp-v13/values.xml create mode 100644 build/intermediates/exploded-aar/GuideBackgroundColorAnimation/library/unspecified/res/values/values.xml diff --git a/.idea/libraries/support_v4_19_0_1.xml b/.idea/libraries/support_v4_19_0_1.xml new file mode 100644 index 0000000..617c323 --- /dev/null +++ b/.idea/libraries/support_v4_19_0_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_v4_19_1_0.xml b/.idea/libraries/support_v4_19_1_0.xml deleted file mode 100644 index faa34d9..0000000 --- a/.idea/libraries/support_v4_19_1_0.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 7215f0d..17b9276 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,121 +1,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - - - + + + + + + + + + + Android API 19 Platform + + + + + + - Android API 14 Platform - + - - - - - - - - - - + + + + + + + + + + @@ -57,21 +57,13 @@ - - - - - - - - - - + + - + diff --git a/library/src/main/java/cn/taurusxi/guidebackgroundcoloranimation/library/ColorAnimationView.java b/library/src/main/java/cn/taurusxi/guidebackgroundcoloranimation/library/ColorAnimationView.java index 05bec1f..5de747f 100644 --- a/library/src/main/java/cn/taurusxi/guidebackgroundcoloranimation/library/ColorAnimationView.java +++ b/library/src/main/java/cn/taurusxi/guidebackgroundcoloranimation/library/ColorAnimationView.java @@ -20,25 +20,15 @@ public class ColorAnimationView private static final int GREEN = 0xff80ff80; private static final int DURATION = 3000; ValueAnimator colorAnim = null; - private ViewPager mViewPager; + private PageChangeListener mPageChangeListener; - OnPageChangeListener onPageChangeListener; + ViewPager.OnPageChangeListener onPageChangeListener; - public void setOnPageChangeListener(OnPageChangeListener onPageChangeListener) { + public void setOnPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { this.onPageChangeListener = onPageChangeListener; } - /** - * This is used by calling the default OnPageChangeListener for viewpager - * */ - public static interface OnPageChangeListener{ - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) ; - - public void onPageSelected(int position) ; - - public void onPageScrollStateChanged(int state) ; - } /** @@ -51,24 +41,20 @@ public static interface OnPageChangeListener{ /** * This is the only method you need care about. * @param mViewPager ,you need set the adpater before you call this. - * @param obj ,this is a Object implements the interface(ColorAnimationView.OnPageChangeListener) - * so,you can call back. * @param count ,this param set the count of the viewpaper's child * @param colors ,this param set the change color use (int... colors), * so,you could set any length if you want.And by default. * if you set nothing , don't worry i have already creat * a default good change color! * */ - public void setmViewPager(ViewPager mViewPager,Object obj, int count, int... colors) { - this.mViewPager = mViewPager; + public void setmViewPager(ViewPager mViewPager, int count, int... colors) { +// this.mViewPager = mViewPager; if (mViewPager.getAdapter() == null) { throw new IllegalStateException( "ViewPager does not have adapter instance."); } mPageChangeListener.setViewPagerChildCount(count); - if(obj instanceof OnPageChangeListener){ - setOnPageChangeListener((OnPageChangeListener)obj); - } + mViewPager.setOnPageChangeListener(mPageChangeListener); if (colors.length == 0) { createDefaultAnimation(); @@ -134,7 +120,7 @@ private void createDefaultAnimation() { @Override public void onAnimationUpdate(ValueAnimator animation) { invalidate(); - long playtime = colorAnim.getCurrentPlayTime(); +// long playtime = colorAnim.getCurrentPlayTime(); } private class PageChangeListener @@ -159,15 +145,22 @@ public int getViewPagerChildCount() { ColorAnimationView.this.seek(progress); } // call the method by default - onPageChangeListener.onPageScrolled(position,positionOffset,positionOffsetPixels); + if (onPageChangeListener!=null){ + onPageChangeListener.onPageScrolled(position,positionOffset,positionOffsetPixels); + } + } @Override public void onPageSelected(int position) { - onPageChangeListener.onPageSelected(position); + if (onPageChangeListener!=null) { + onPageChangeListener.onPageSelected(position); + } } @Override public void onPageScrollStateChanged(int state) { - onPageChangeListener.onPageScrollStateChanged(state); + if (onPageChangeListener!=null) { + onPageChangeListener.onPageScrollStateChanged(state); + } } } } diff --git a/sample/build.gradle b/sample/build.gradle index dc5d62e..cecdf87 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'android' android { compileSdkVersion 19 - buildToolsVersion "19.0.3" + buildToolsVersion "19.1.0" defaultConfig { minSdkVersion 14 diff --git a/sample/sample.iml b/sample/sample.iml index ec07a65..d55b455 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -22,19 +22,19 @@ - + - - - - - - - - - - + + + + + + + + + + @@ -56,21 +56,12 @@ - - - - - - - - - - - + + - + diff --git a/sample/src/main/java/cn/taurusxi/guidebackgroundcoloranimation/sample/SampleActivity.java b/sample/src/main/java/cn/taurusxi/guidebackgroundcoloranimation/sample/SampleActivity.java index b91df61..f4b6e57 100644 --- a/sample/src/main/java/cn/taurusxi/guidebackgroundcoloranimation/sample/SampleActivity.java +++ b/sample/src/main/java/cn/taurusxi/guidebackgroundcoloranimation/sample/SampleActivity.java @@ -17,7 +17,7 @@ public class SampleActivity extends FragmentActivity - implements ColorAnimationView.OnPageChangeListener { + { private static final int[] resource = new int[]{R.drawable.welcome1, R.drawable.welcome4, R.drawable.welcome3, R.drawable.welcome4}; private static final String TAG = SampleActivity.class.getSimpleName(); @@ -45,28 +45,27 @@ protected void onCreate(Bundle savedInstanceState) { * Third: If you call this method like below, make the colors no data, it will create * a change color by default. * */ - colorAnimationView.setmViewPager(viewPager, this, resource.length); - // Four : Also ,you can call this method like this: - // colorAnimationView.setmViewPager(viewPager,this,resource.length,0xffFF8080,0xff8080FF,0xffffffff,0xff80ff80); - } + colorAnimationView.setmViewPager(viewPager, resource.length); + colorAnimationView.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + Log.e("TAG","onPageScrolled"); + } - // 实现 OnPageChangeListener的回调方法 - //Implement OnPageChangeListener callback methods - @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - Log.e(TAG, "call onPageScrolled method"); - } + @Override + public void onPageSelected(int position) { + Log.e("TAG","onPageSelected"); + } - // 实现 OnPageChangeListener的回调方法 - //Implement OnPageChangeListener callback methods - @Override public void onPageSelected(int position) { - Log.e(TAG, "call onPageSelected method"); + @Override + public void onPageScrollStateChanged(int state) { + Log.e("TAG","onPageScrollStateChanged"); + } + }); + // Four : Also ,you can call this method like this: + // colorAnimationView.setmViewPager(viewPager,this,resource.length,0xffFF8080,0xff8080FF,0xffffffff,0xff80ff80); } - // 实现 OnPageChangeListener的回调方法 - //Implement OnPageChangeListener callback methods - @Override public void onPageScrollStateChanged(int state) { - Log.e(TAG, "call onPageScrollStateChanged method"); - } public class MyFragmentStatePager