Skip to content
Browse files

Compatibility to API Level 8 by using different animations for differ…

…ent system versions.
  • Loading branch information...
1 parent 6318e1d commit e324e8f54569785908bd3c43e775bf42f1642a94 @roughike committed
View
2 .idea/gradle.xml
@@ -6,7 +6,7 @@
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="F:\Program Files\Android\Android Studio\gradle\gradle-2.8" />
- <option name="gradleJvm" value="1.8" />
+ <option name="gradleJvm" value="1.7" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
View
2 .idea/misc.xml
@@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
View
2 .idea/vcs.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
- <mapping directory="" vcs="" />
+ <mapping directory="" vcs="Git" />
</component>
</project>
View
4 sample/sample.iml
@@ -81,11 +81,11 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" exported="" name="animated-vector-drawable-23.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.2.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.2.0" level="project" />
- <orderEntry type="library" exported="" name="appcompat-v7-23.2.0" level="project" />
- <orderEntry type="library" exported="" name="animated-vector-drawable-23.2.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.2.0" level="project" />
+ <orderEntry type="library" exported="" name="appcompat-v7-23.2.0" level="project" />
<orderEntry type="module" module-name="swipe-selector" exported="" />
</component>
</module>
View
30 swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -1,5 +1,7 @@
package com.roughike.swipeselector;
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.ShapeDrawable;
@@ -121,7 +123,7 @@ private SwipeAdapter(ViewPager viewPager, ViewGroup indicatorContainer, int indi
* Using the Java Builder Pattern here, because the SwipeSelector class was getting
* messy and that's where most will look at. This class is protected, and contains no
* methods that the users can use, so it's OK for this to look like absolute vomit.
- *
+ * <p/>
* At least that's my opinion. But my opinions are always right.
*/
protected static class Builder {
@@ -144,7 +146,8 @@ private SwipeAdapter(ViewPager viewPager, ViewGroup indicatorContainer, int indi
private int descriptionTextAppearance;
private int descriptionGravity;
- protected Builder(){}
+ protected Builder() {
+ }
protected Builder viewPager(ViewPager viewPager) {
this.viewPager = viewPager;
@@ -336,7 +339,7 @@ public void destroyItem(ViewGroup container, int position, Object object) {
@Override
public int getCount() {
- return mItems != null? mItems.size() : 0;
+ return mItems != null ? mItems.size() : 0;
}
@Override
@@ -423,16 +426,16 @@ private int getGravity(int gravity) {
int realGravityValue;
switch (gravity) {
- case 0 :
+ case 0:
realGravityValue = Gravity.START;
break;
- case 1 :
+ case 1:
realGravityValue = Gravity.CENTER_HORIZONTAL;
break;
- case 2 :
+ case 2:
realGravityValue = Gravity.END;
break;
- default :
+ default:
throw new IllegalArgumentException("Invalid value " +
"specified for swipe_descriptionGravity. " +
"Use \"left\", \"center\", \"right\" or leave " +
@@ -473,9 +476,10 @@ private void animate(float alpha, ImageView button) {
.setDuration(120)
.start();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
- button.animate()
- .alpha(alpha)
- .setDuration(120);
+ ObjectAnimator.ofFloat(button, "alpha",
+ alpha == 1 ? 0 : alpha, alpha == 1 ? alpha : 0)
+ .setDuration(120)
+ .start();
} else {
setAlpha(alpha, button);
}
@@ -483,10 +487,10 @@ private void animate(float alpha, ImageView button) {
@SuppressWarnings("deprecation")
private void setAlpha(float alpha, ImageView button) {
- if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
button.setAlpha(alpha);
- else {
- button.setAlpha((int) (alpha*255));
+ } else {
+ button.setAlpha((int) (alpha * 255));
}
}
}
View
7 swipe-selector/swipe-selector.iml
@@ -65,6 +65,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+ <excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
@@ -82,15 +83,17 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
+ <excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+ <excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" exported="" name="animated-vector-drawable-23.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.2.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.2.0" level="project" />
- <orderEntry type="library" exported="" name="appcompat-v7-23.2.0" level="project" />
- <orderEntry type="library" exported="" name="animated-vector-drawable-23.2.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.2.0" level="project" />
+ <orderEntry type="library" exported="" name="appcompat-v7-23.2.0" level="project" />
</component>
</module>

0 comments on commit e324e8f

Please sign in to comment.
Something went wrong with that request. Please try again.