From b4e7a160b5df0ad27dbdb655172e63a8deda259d Mon Sep 17 00:00:00 2001 From: Pedro Paulo Amorim Date: Mon, 14 Sep 2015 10:23:22 -0300 Subject: [PATCH 1/2] Clean-up A lot of thinks removed, like a unnecessary libraries and raise the API to 11 (why 9?). --- .gitignore | 45 +++++++- .idea/.name | 1 - .idea/compiler.xml | 22 ---- .idea/copyright/profiles_settings.xml | 3 - .idea/encodings.xml | 7 -- .idea/gradle.xml | 19 ---- .idea/misc.xml | 73 ------------- .idea/modules.xml | 10 -- .idea/runConfigurations.xml | 12 -- .idea/vcs.xml | 6 - Library/.gitignore | 1 - Library/Library.iml | 97 ----------------- Library/build.gradle | 25 ----- Library/proguard-rules.pro | 17 --- .../java/com/cjj/ApplicationTest.java | 13 --- Library/src/main/AndroidManifest.xml | 7 -- .../java/com/cjj/MaterialHeadListener.java | 17 --- app/.gitignore | 1 - app/app.iml | 103 ------------------ app/build.gradle | 23 ++-- app/proguard-rules.pro | 17 --- .../ApplicationTest.java | 13 --- build.gradle | 7 +- library/build.gradle | 18 +++ library/src/main/AndroidManifest.xml | 1 + .../main/java/com/cjj/CircleProgressBar.java | 3 - .../java/com/cjj/MaterialHeadListener.java | 23 ++++ .../main/java/com/cjj/MaterialHeadView.java | 28 ++--- .../com/cjj/MaterialProgressDrawable.java | 5 - .../java/com/cjj/MaterialRefreshLayout.java | 35 ++---- .../java/com/cjj/MaterialRefreshListener.java | 3 - .../main/java/com/cjj/MaterialWaveView.java | 6 +- .../src/main/java/com/cjj/Util.java | 3 - .../src/main/res/values/attrs.xml | 0 .../res/values/attrs_circle_progressbar.xml | 0 .../src/main/res/values/colors.xml | 0 .../src/main/res/values/strings.xml | 0 settings.gradle | 2 +- 38 files changed, 111 insertions(+), 555 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/runConfigurations.xml delete mode 100644 .idea/vcs.xml delete mode 100644 Library/.gitignore delete mode 100644 Library/Library.iml delete mode 100644 Library/build.gradle delete mode 100644 Library/proguard-rules.pro delete mode 100644 Library/src/androidTest/java/com/cjj/ApplicationTest.java delete mode 100644 Library/src/main/AndroidManifest.xml delete mode 100644 Library/src/main/java/com/cjj/MaterialHeadListener.java delete mode 100644 app/.gitignore delete mode 100644 app/app.iml delete mode 100644 app/proguard-rules.pro delete mode 100644 app/src/androidTest/java/com/cjj/android_materialrefreshlayout/ApplicationTest.java create mode 100644 library/build.gradle create mode 100644 library/src/main/AndroidManifest.xml rename {Library => library}/src/main/java/com/cjj/CircleProgressBar.java (99%) create mode 100644 library/src/main/java/com/cjj/MaterialHeadListener.java rename {Library => library}/src/main/java/com/cjj/MaterialHeadView.java (88%) rename {Library => library}/src/main/java/com/cjj/MaterialProgressDrawable.java (99%) rename {Library => library}/src/main/java/com/cjj/MaterialRefreshLayout.java (94%) rename {Library => library}/src/main/java/com/cjj/MaterialRefreshListener.java (82%) rename {Library => library}/src/main/java/com/cjj/MaterialWaveView.java (97%) rename {Library => library}/src/main/java/com/cjj/Util.java (93%) rename {Library => library}/src/main/res/values/attrs.xml (100%) rename {Library => library}/src/main/res/values/attrs_circle_progressbar.xml (100%) rename {Library => library}/src/main/res/values/colors.xml (100%) rename {Library => library}/src/main/res/values/strings.xml (100%) diff --git a/.gitignore b/.gitignore index 9c4de58..badb0ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,40 @@ -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries +# Custom +_site + +# Ant +MANIFEST.MF +./*.jar +build.num +build + +# ADT +.classpath +.project +.settings +local.properties +bin +gen +_layouts +proguard.cfg + +# OSX .DS_Store -/build -/captures + +# Github +gh-pages + +# Gradle +.gradle +build + +# IDEA +*.iml +*.ipr +*.iws +out +.idea + +# Maven +target +release.properties +pom.xml.* \ No newline at end of file diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 487786b..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Android-MaterialRefreshLayout \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 9a8b7e5..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index ecd30e7..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 55d4d82..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 6653418..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.8 - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 760a3c6..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Library/.gitignore b/Library/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/Library/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/Library/Library.iml b/Library/Library.iml deleted file mode 100644 index 5af817e..0000000 --- a/Library/Library.iml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Library/build.gradle b/Library/build.gradle deleted file mode 100644 index 14901c5..0000000 --- a/Library/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion 22 - buildToolsVersion "23.0.0 rc3" - - defaultConfig { - minSdkVersion 9 - targetSdkVersion 22 - 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.nineoldandroids:library:2.4.0' -} diff --git a/Library/proguard-rules.pro b/Library/proguard-rules.pro deleted file mode 100644 index 8debfde..0000000 --- a/Library/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in D:\as\sdk-install/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/Library/src/androidTest/java/com/cjj/ApplicationTest.java b/Library/src/androidTest/java/com/cjj/ApplicationTest.java deleted file mode 100644 index 891e0a5..0000000 --- a/Library/src/androidTest/java/com/cjj/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.cjj; - -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/Library/src/main/AndroidManifest.xml b/Library/src/main/AndroidManifest.xml deleted file mode 100644 index 309e0af..0000000 --- a/Library/src/main/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Library/src/main/java/com/cjj/MaterialHeadListener.java b/Library/src/main/java/com/cjj/MaterialHeadListener.java deleted file mode 100644 index 8bc7b82..0000000 --- a/Library/src/main/java/com/cjj/MaterialHeadListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.cjj; - -/** - * Created by cjj on 2015/9/7. - */ -public interface MaterialHeadListener { - - public void onComlete(MaterialRefreshLayout materialRefreshLayout); - - public void onBegin(MaterialRefreshLayout materialRefreshLayout); - - public void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction); - - public void onRelease(MaterialRefreshLayout materialRefreshLayout, float fraction); - - public void onRefreshing(MaterialRefreshLayout materialRefreshLayout); -} diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/app/app.iml b/app/app.iml deleted file mode 100644 index 127a6ed..0000000 --- a/app/app.iml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 795aac9..12a4976 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,28 +1,21 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 22 - buildToolsVersion "23.0.0 rc3" + compileSdkVersion 23 + buildToolsVersion "23.0.1" defaultConfig { applicationId "com.cjj.android_materialrefreshlayout" - minSdkVersion 9 - targetSdkVersion 22 + minSdkVersion 11 + targetSdkVersion 23 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 project(':Library') - compile 'com.android.support:recyclerview-v7:22.2.1' - compile 'com.android.support:cardview-v7:22.2.1' + compile project(':library') + compile 'com.android.support:appcompat-v7:23.0.1' + compile 'com.android.support:recyclerview-v7:23.0.1' + compile 'com.android.support:cardview-v7:23.0.1' } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index 8debfde..0000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in D:\as\sdk-install/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/app/src/androidTest/java/com/cjj/android_materialrefreshlayout/ApplicationTest.java b/app/src/androidTest/java/com/cjj/android_materialrefreshlayout/ApplicationTest.java deleted file mode 100644 index 4cf3be3..0000000 --- a/app/src/androidTest/java/com/cjj/android_materialrefreshlayout/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.cjj.android_materialrefreshlayout; - -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/build.gradle b/build.gradle index 9405f3f..9b18c6e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,9 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { repositories { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.android.tools.build:gradle:1.3.0' } } diff --git a/library/build.gradle b/library/build.gradle new file mode 100644 index 0000000..2a7f5d1 --- /dev/null +++ b/library/build.gradle @@ -0,0 +1,18 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.1" + + defaultConfig { + minSdkVersion 11 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } +} + +dependencies { + compile 'com.android.support:appcompat-v7:23.0.1' + compile 'com.android.support:support-v4:23.0.1' +} diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml new file mode 100644 index 0000000..b3ef730 --- /dev/null +++ b/library/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/Library/src/main/java/com/cjj/CircleProgressBar.java b/library/src/main/java/com/cjj/CircleProgressBar.java similarity index 99% rename from Library/src/main/java/com/cjj/CircleProgressBar.java rename to library/src/main/java/com/cjj/CircleProgressBar.java index a43d383..c664578 100644 --- a/Library/src/main/java/com/cjj/CircleProgressBar.java +++ b/library/src/main/java/com/cjj/CircleProgressBar.java @@ -35,9 +35,6 @@ import android.view.animation.Animation; import android.widget.ImageView; -import com.nineoldandroids.animation.ObjectAnimator; -import com.nineoldandroids.view.ViewHelper; - /** * The author is lsjwzh(MaterialLoadingProgressBar) link{https://github.com/lsjwzh/MaterialLoadingProgressBar}, * I did some slight modifications diff --git a/library/src/main/java/com/cjj/MaterialHeadListener.java b/library/src/main/java/com/cjj/MaterialHeadListener.java new file mode 100644 index 0000000..7e9eef9 --- /dev/null +++ b/library/src/main/java/com/cjj/MaterialHeadListener.java @@ -0,0 +1,23 @@ +package com.cjj; +/* +* Copyright (C) 2015 Pedro Paulo de Amorim +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +public interface MaterialHeadListener { + void onComlete(MaterialRefreshLayout materialRefreshLayout); + void onBegin(MaterialRefreshLayout materialRefreshLayout); + void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction); + void onRelease(MaterialRefreshLayout materialRefreshLayout, float fraction); + void onRefreshing(MaterialRefreshLayout materialRefreshLayout); +} diff --git a/Library/src/main/java/com/cjj/MaterialHeadView.java b/library/src/main/java/com/cjj/MaterialHeadView.java similarity index 88% rename from Library/src/main/java/com/cjj/MaterialHeadView.java rename to library/src/main/java/com/cjj/MaterialHeadView.java index b79d409..8540f31 100644 --- a/Library/src/main/java/com/cjj/MaterialHeadView.java +++ b/library/src/main/java/com/cjj/MaterialHeadView.java @@ -1,25 +1,15 @@ package com.cjj; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.content.Context; -import android.graphics.Color; +import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.util.Log; import android.view.Gravity; import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.AnimationSet; import android.widget.FrameLayout; -import android.widget.LinearLayout; -import com.nineoldandroids.animation.AnimatorSet; -import com.nineoldandroids.animation.ObjectAnimator; -import com.nineoldandroids.view.ViewHelper; - -/** - * Created by cjj on 2015/9/7. - */ public class MaterialHeadView extends FrameLayout implements MaterialHeadListener{ private MaterialWaveView materialWaveView; private CircleProgressBar circleProgressBar; @@ -152,9 +142,9 @@ public void onComlete(MaterialRefreshLayout materialRefreshLayout) { if(circleProgressBar != null) { circleProgressBar.onComlete(materialRefreshLayout); - ViewHelper.setTranslationY(circleProgressBar,0); - ViewHelper.setScaleX(circleProgressBar,0); - ViewHelper.setScaleY(circleProgressBar,0); + ViewCompat.setTranslationY(circleProgressBar,0); + ViewCompat.setScaleX(circleProgressBar, 0); + ViewCompat.setScaleY(circleProgressBar,0); } @@ -182,9 +172,9 @@ public void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction) { circleProgressBar.onPull(materialRefreshLayout, fraction); float a = Util.limitValue(1,fraction); - ViewHelper.setScaleX(circleProgressBar, 1); - ViewHelper.setScaleY(circleProgressBar, 1); - ViewHelper.setAlpha(circleProgressBar, a); + ViewCompat.setScaleX(circleProgressBar, 1); + ViewCompat.setScaleY(circleProgressBar, 1); + ViewCompat.setAlpha(circleProgressBar, a); } } diff --git a/Library/src/main/java/com/cjj/MaterialProgressDrawable.java b/library/src/main/java/com/cjj/MaterialProgressDrawable.java similarity index 99% rename from Library/src/main/java/com/cjj/MaterialProgressDrawable.java rename to library/src/main/java/com/cjj/MaterialProgressDrawable.java index 4da1032..0527542 100644 --- a/Library/src/main/java/com/cjj/MaterialProgressDrawable.java +++ b/library/src/main/java/com/cjj/MaterialProgressDrawable.java @@ -43,11 +43,6 @@ import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; -/** - * Fancy progress indicator for Material theme. - * - * @hide - */ public class MaterialProgressDrawable extends Drawable implements Animatable { // Maps to ProgressBar.Large style public static final int LARGE = 0; diff --git a/Library/src/main/java/com/cjj/MaterialRefreshLayout.java b/library/src/main/java/com/cjj/MaterialRefreshLayout.java similarity index 94% rename from Library/src/main/java/com/cjj/MaterialRefreshLayout.java rename to library/src/main/java/com/cjj/MaterialRefreshLayout.java index 6c3ac93..5ecba93 100644 --- a/Library/src/main/java/com/cjj/MaterialRefreshLayout.java +++ b/library/src/main/java/com/cjj/MaterialRefreshLayout.java @@ -1,14 +1,16 @@ package com.cjj; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; import android.os.Build; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; -import android.util.Log; import android.view.Gravity; -import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -16,15 +18,6 @@ import android.widget.AbsListView; import android.widget.FrameLayout; -import com.nineoldandroids.animation.Animator; -import com.nineoldandroids.animation.AnimatorListenerAdapter; -import com.nineoldandroids.animation.ObjectAnimator; -import com.nineoldandroids.animation.ValueAnimator; -import com.nineoldandroids.view.ViewHelper; - -/** - * Created by cjj on 2015/9/7. - */ public class MaterialRefreshLayout extends FrameLayout { public static final String Tag = "cjj_log"; @@ -163,18 +156,10 @@ protected void onAttachedToWindow() { } setWaveHeight(Util.dip2px(getContext(), waveHeight)); - setHeaderHeight(Util.dip2px(getContext(), headHeight)); materialHeadView = new MaterialHeadView(getContext()); - if(isShowWave) - { - materialHeadView.setWaveColor(waveColor); - }else - { - materialHeadView.setWaveColor(0x00000000); - } - + materialHeadView.setWaveColor(isShowWave ? waveColor : Color.WHITE); materialHeadView.showProgressArrow(showArrow); materialHeadView.setProgressColors(colorSchemeColors); materialHeadView.setProgressStokeWidth(3); @@ -237,7 +222,7 @@ public boolean onTouchEvent(MotionEvent e) { } if (!isOverlay) - ViewHelper.setTranslationY(mChildView, offsetY); + ViewCompat.setTranslationY(mChildView, offsetY); } return true; @@ -259,7 +244,7 @@ public boolean onTouchEvent(MotionEvent e) { } else { - if (ViewHelper.getTranslationY(mChildView) >= mHeadHeight) { + if (ViewCompat.getTranslationY(mChildView) >= mHeadHeight) { createAnimatorTranslationY(mChildView, mHeadHeight, mHeadLayout); updateListener(); } else { @@ -334,14 +319,14 @@ public void setProgressValue(int progressValue) } public void createAnimatorTranslationY(final View v, final float h, final FrameLayout fl) { - ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(v, "translationY", ViewHelper.getTranslationY(v), h); + ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(v, "translationY", ViewCompat.getTranslationY(v), h); objectAnimator.setDuration(200); objectAnimator.setInterpolator(new DecelerateInterpolator()); objectAnimator.start(); objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { - float height = ViewHelper.getTranslationY(v); + float height = ViewCompat.getTranslationY(v); fl.getLayoutParams().height = (int) height; fl.requestLayout(); } @@ -385,7 +370,7 @@ public void setWaveHigher() { public void finishRefreshing() { if (mChildView != null) { - ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mChildView, "translationY", ViewHelper.getTranslationY(mChildView), 0); + ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mChildView, "translationY", ViewCompat.getTranslationY(mChildView), 0); objectAnimator.setDuration(200); objectAnimator.setInterpolator(new DecelerateInterpolator()); objectAnimator.start(); diff --git a/Library/src/main/java/com/cjj/MaterialRefreshListener.java b/library/src/main/java/com/cjj/MaterialRefreshListener.java similarity index 82% rename from Library/src/main/java/com/cjj/MaterialRefreshListener.java rename to library/src/main/java/com/cjj/MaterialRefreshListener.java index 3112b10..61c0129 100644 --- a/Library/src/main/java/com/cjj/MaterialRefreshListener.java +++ b/library/src/main/java/com/cjj/MaterialRefreshListener.java @@ -1,8 +1,5 @@ package com.cjj; -/** - * Created by cjj on 2015/9/8. - */ public abstract class MaterialRefreshListener { public void onfinish(){}; public abstract void onRefresh(MaterialRefreshLayout materialRefreshLayout); diff --git a/Library/src/main/java/com/cjj/MaterialWaveView.java b/library/src/main/java/com/cjj/MaterialWaveView.java similarity index 97% rename from Library/src/main/java/com/cjj/MaterialWaveView.java rename to library/src/main/java/com/cjj/MaterialWaveView.java index d9b668d..43b7b92 100644 --- a/Library/src/main/java/com/cjj/MaterialWaveView.java +++ b/library/src/main/java/com/cjj/MaterialWaveView.java @@ -1,5 +1,6 @@ package com.cjj; +import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; @@ -10,11 +11,6 @@ import android.view.animation.BounceInterpolator; import android.view.animation.DecelerateInterpolator; -import com.nineoldandroids.animation.ValueAnimator; - -/** - * Created by cjj on 2015/9/7. - */ public class MaterialWaveView extends View implements MaterialHeadListener { private int waveHeight; private int headHeight; diff --git a/Library/src/main/java/com/cjj/Util.java b/library/src/main/java/com/cjj/Util.java similarity index 93% rename from Library/src/main/java/com/cjj/Util.java rename to library/src/main/java/com/cjj/Util.java index 1e9d310..1cfa6d2 100644 --- a/Library/src/main/java/com/cjj/Util.java +++ b/library/src/main/java/com/cjj/Util.java @@ -2,9 +2,6 @@ import android.content.Context; -/** - * Created by Administrator on 2015/9/6. - */ public class Util { public static int dip2px(Context context, float dpValue) { diff --git a/Library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml similarity index 100% rename from Library/src/main/res/values/attrs.xml rename to library/src/main/res/values/attrs.xml diff --git a/Library/src/main/res/values/attrs_circle_progressbar.xml b/library/src/main/res/values/attrs_circle_progressbar.xml similarity index 100% rename from Library/src/main/res/values/attrs_circle_progressbar.xml rename to library/src/main/res/values/attrs_circle_progressbar.xml diff --git a/Library/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml similarity index 100% rename from Library/src/main/res/values/colors.xml rename to library/src/main/res/values/colors.xml diff --git a/Library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml similarity index 100% rename from Library/src/main/res/values/strings.xml rename to library/src/main/res/values/strings.xml diff --git a/settings.gradle b/settings.gradle index 0fa46f5..3306997 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':Library' +include ':app', ':library' From 656a8bb57b39f6ad2952393c271a4f2ba05074fe Mon Sep 17 00:00:00 2001 From: Pedro Paulo Amorim Date: Mon, 14 Sep 2015 10:43:03 -0300 Subject: [PATCH 2/2] Minor changes Animating with support library --- .../main/java/com/cjj/MaterialHeadView.java | 3 +- .../java/com/cjj/MaterialRefreshLayout.java | 48 +++++++++---------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/library/src/main/java/com/cjj/MaterialHeadView.java b/library/src/main/java/com/cjj/MaterialHeadView.java index 8540f31..bd62ed8 100644 --- a/library/src/main/java/com/cjj/MaterialHeadView.java +++ b/library/src/main/java/com/cjj/MaterialHeadView.java @@ -197,8 +197,7 @@ public void onRefreshing(MaterialRefreshLayout materialRefreshLayout) { - public void scaleView(View v,float a,float b) - { + public void scaleView(View v,float a,float b) { ObjectAnimator ax = ObjectAnimator.ofFloat(v,"scaleX",a,b); ObjectAnimator ay = ObjectAnimator.ofFloat(v,"scaleY",a,b); AnimatorSet animSet = new AnimatorSet(); diff --git a/library/src/main/java/com/cjj/MaterialRefreshLayout.java b/library/src/main/java/com/cjj/MaterialRefreshLayout.java index 5ecba93..63447ac 100644 --- a/library/src/main/java/com/cjj/MaterialRefreshLayout.java +++ b/library/src/main/java/com/cjj/MaterialRefreshLayout.java @@ -1,14 +1,12 @@ package com.cjj; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; import android.os.Build; import android.support.v4.view.ViewCompat; +import android.support.v4.view.ViewPropertyAnimatorCompat; +import android.support.v4.view.ViewPropertyAnimatorUpdateListener; import android.util.AttributeSet; import android.view.Gravity; import android.view.MotionEvent; @@ -140,7 +138,9 @@ private void init(Context context, AttributeSet attrs, int defstyleAttr) { protected void onAttachedToWindow() { super.onAttachedToWindow(); - FrameLayout headViewLayout = new FrameLayout(getContext()); + Context context = getContext(); + + FrameLayout headViewLayout = new FrameLayout(context); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0); layoutParams.gravity = Gravity.TOP; headViewLayout.setLayoutParams(layoutParams); @@ -155,10 +155,10 @@ protected void onAttachedToWindow() { return; } - setWaveHeight(Util.dip2px(getContext(), waveHeight)); - setHeaderHeight(Util.dip2px(getContext(), headHeight)); + setWaveHeight(Util.dip2px(context, waveHeight)); + setHeaderHeight(Util.dip2px(context, headHeight)); - materialHeadView = new MaterialHeadView(getContext()); + materialHeadView = new MaterialHeadView(context); materialHeadView.setWaveColor(isShowWave ? waveColor : Color.WHITE); materialHeadView.showProgressArrow(showArrow); materialHeadView.setProgressColors(colorSchemeColors); @@ -319,24 +319,18 @@ public void setProgressValue(int progressValue) } public void createAnimatorTranslationY(final View v, final float h, final FrameLayout fl) { - ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(v, "translationY", ViewCompat.getTranslationY(v), h); - objectAnimator.setDuration(200); - objectAnimator.setInterpolator(new DecelerateInterpolator()); - objectAnimator.start(); - objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { + ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(v); + viewPropertyAnimatorCompat.setDuration(200); + viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator()); + viewPropertyAnimatorCompat.translationY(h); + viewPropertyAnimatorCompat.start(); + viewPropertyAnimatorCompat.setUpdateListener(new ViewPropertyAnimatorUpdateListener() { + @Override public void onAnimationUpdate(View view) { float height = ViewCompat.getTranslationY(v); fl.getLayoutParams().height = (int) height; fl.requestLayout(); } }); - objectAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - } - }); } /** @@ -370,10 +364,12 @@ public void setWaveHigher() { public void finishRefreshing() { if (mChildView != null) { - ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mChildView, "translationY", ViewCompat.getTranslationY(mChildView), 0); - objectAnimator.setDuration(200); - objectAnimator.setInterpolator(new DecelerateInterpolator()); - objectAnimator.start(); + ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView); + viewPropertyAnimatorCompat.setDuration(200); + viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView)); + viewPropertyAnimatorCompat.translationY(0); + viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator()); + viewPropertyAnimatorCompat.start(); if (mMaterialHeadListener != null) { mMaterialHeadListener.onComlete(this); } @@ -388,7 +384,7 @@ public void finishRefreshing() { } isRefreshing = false; progressValue = 0; - setProgressValue(0); + setProgressValue(0); } public void finishRefresh()