-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
library和sample拆分,library用java语言重写,library回归用support包
- Loading branch information
lilei
committed
Feb 19, 2019
1 parent
b44ef0c
commit 793b033
Showing
55 changed files
with
4,472 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
|
||
defaultConfig { | ||
minSdkVersion 15 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support:recyclerview-v7:28.0.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
library/src/androidTest/java/me/hiten/jkcardlayout/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.hiten.jkcardlayout; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("me.hiten.jkcardlayout.test", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest package="me.hiten.jkcardlayout" /> |
89 changes: 89 additions & 0 deletions
89
library/src/main/java/me/hiten/jkcardlayout/CardAnimatorManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package me.hiten.jkcardlayout; | ||
|
||
|
||
|
||
import android.animation.TypeEvaluator; | ||
import android.util.Property; | ||
import android.view.View; | ||
|
||
import java.util.LinkedList; | ||
import java.util.Random; | ||
|
||
public class CardAnimatorManager { | ||
|
||
public static class AnimatorInfoEvaluator implements TypeEvaluator<AnimatorInfo> { | ||
|
||
AnimatorInfo mTemp = new AnimatorInfo(); | ||
|
||
@Override | ||
public AnimatorInfo evaluate(float fraction, AnimatorInfo startValue, AnimatorInfo endValue) { | ||
mTemp.targetRotation = startValue.targetRotation+(endValue.targetRotation-startValue.targetRotation)*fraction; | ||
mTemp.targetXr = startValue.targetXr+(endValue.targetXr-startValue.targetXr)*fraction; | ||
mTemp.targetYr = startValue.targetYr+(endValue.targetYr-startValue.targetYr)*fraction; | ||
return mTemp; | ||
} | ||
} | ||
|
||
public static class AnimatorInfoProperty extends Property<View,AnimatorInfo>{ | ||
|
||
private float baseX; | ||
|
||
private float baseY; | ||
|
||
public AnimatorInfoProperty(float baseX,float baseY) { | ||
super(AnimatorInfo.class, null); | ||
this.baseX = baseX; | ||
this.baseY = baseY; | ||
} | ||
|
||
@Override | ||
public void set(View object, AnimatorInfo value) { | ||
object.setTranslationX(value.targetXr*baseX); | ||
object.setTranslationY(value.targetYr*baseY); | ||
object.setRotation(value.targetRotation); | ||
} | ||
|
||
@Override | ||
public AnimatorInfo get(View object) { | ||
return null; | ||
} | ||
} | ||
|
||
|
||
private LinkedList<AnimatorInfo> mStack = new LinkedList<>(); | ||
|
||
public AnimatorInfo takeAdd() { | ||
AnimatorInfo pop = null; | ||
if (mStack.size() > 0) { | ||
pop = mStack.pop(); | ||
} | ||
if (pop == null) { | ||
pop = new AnimatorInfo(); | ||
} | ||
return pop; | ||
} | ||
|
||
|
||
public void addRemoveToBackStack(AnimatorInfo animatorInfo) { | ||
mStack.push(animatorInfo); | ||
} | ||
|
||
public AnimatorInfo createRemove() { | ||
AnimatorInfo animatorInfo = new AnimatorInfo(); | ||
boolean b = new Random().nextBoolean(); | ||
animatorInfo.targetXr = b ? -1.0f : 1.0f; | ||
animatorInfo.targetYr = 1f; | ||
animatorInfo.targetRotation = 10; | ||
return animatorInfo; | ||
} | ||
|
||
|
||
public static class AnimatorInfo { | ||
float targetXr; | ||
float targetYr; | ||
float targetRotation; | ||
|
||
public static AnimatorInfo ZERO = new AnimatorInfo(); | ||
} | ||
|
||
} |
Oops, something went wrong.