├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── vcs.xml
├── encodings.xml
├── modules.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── demo
├── .gitignore
├── demo_menu.gif
├── demo_chrome_home.gif
├── demo_drawerlayout.gif
├── demo_xiaoma_intro.gif
├── src
│ └── main
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ │ ├── actionbar_ic_more.png
│ │ │ ├── actionbar_ic_windows.png
│ │ │ ├── xiaoma_intro_img_red.png
│ │ │ ├── xiaoma_intro_img_blue.png
│ │ │ ├── xiaoma_intro_img_green.png
│ │ │ ├── xiaoma_intro_top_text1.png
│ │ │ ├── xiaoma_intro_top_text2.png
│ │ │ ├── xiaoma_intro_top_text3.png
│ │ │ ├── xiaoma_intro_top_text4.png
│ │ │ ├── xiaoma_intro_bottom_text1.png
│ │ │ ├── xiaoma_intro_img_ask_icon.png
│ │ │ ├── xiaoma_intro_img_low_icon.png
│ │ │ ├── xiaoma_intro_img_orange.png
│ │ │ ├── xiaoma_intro_img_purple.png
│ │ │ ├── xiaoma_intro_img_xiaoma.png
│ │ │ ├── xiaoma_intro_img_yellow.png
│ │ │ ├── xiaoma_intro_page3_img1.png
│ │ │ ├── xiaoma_intro_page3_img2.png
│ │ │ ├── xiaoma_intro_page3_img3.png
│ │ │ ├── xiaoma_intro_page3_img4.png
│ │ │ ├── xiaoma_intro_page3_img5.png
│ │ │ ├── xiaoma_intro_page3_img6.png
│ │ │ ├── xiaoma_intro_page4_img1.png
│ │ │ ├── xiaoma_intro_page4_img2.png
│ │ │ ├── xiaoma_intro_page4_img3.png
│ │ │ ├── xiaoma_intro_page4_img4.png
│ │ │ ├── xiaoma_intro_img_carpay_ind.png
│ │ │ ├── xiaoma_intro_img_compe_icon.png
│ │ │ ├── xiaoma_intro_img_keepup_ind.png
│ │ │ ├── xiaoma_intro_img_newcar_ind.png
│ │ │ ├── xiaoma_intro_img_real_icon.png
│ │ │ ├── xiaoma_intro_img_sign_icon.png
│ │ │ ├── xiaoma_intro_img_take_icon.png
│ │ │ ├── xiaoma_intro_img_deep_purple.png
│ │ │ ├── xiaoma_intro_img_deposit_icon.png
│ │ │ ├── xiaoma_intro_img_deserv_icon.png
│ │ │ ├── xiaoma_intro_img_privacy_icon.png
│ │ │ ├── xiaoma_intro_img_promise_icon.png
│ │ │ └── xiaoma_intro_img_usedcar_ind.png
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── styles.xml
│ │ │ └── dimens.xml
│ │ ├── drawable
│ │ │ ├── chrome_home_head_input_bg.xml
│ │ │ └── btn_bg.xml
│ │ ├── menu
│ │ │ └── menu_main.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ ├── demo_material_menu.xml
│ │ │ ├── material_menu_option.xml
│ │ │ ├── material_menu_x.xml
│ │ │ ├── xiaoma_intro_page_base.xml
│ │ │ ├── material_menu_back.xml
│ │ │ ├── material_menu_y.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── demo_drawerlayout.xml
│ │ │ ├── xiaoma_intro_scene1_text.xml
│ │ │ ├── chrome_home_head_state_expand.xml
│ │ │ ├── chrome_home_head_state_collapse.xml
│ │ │ ├── demo_chrome_home.xml
│ │ │ ├── demo_xiaoma_intro.xml
│ │ │ ├── xiaoma_intro_scene3.xml
│ │ │ ├── xiaoma_intro_scene4.xml
│ │ │ ├── xiaoma_intro_scene1.xml
│ │ │ ├── xiaoma_intro_scene2.xml
│ │ │ ├── xiaoma_intro_scene4_text.xml
│ │ │ ├── xiaoma_intro_scene2_text.xml
│ │ │ └── xiaoma_intro_scene3_text.xml
│ │ ├── java
│ │ └── com
│ │ │ └── linfaxin
│ │ │ └── transitionplayer
│ │ │ └── demo
│ │ │ ├── MainActivity.java
│ │ │ ├── DrawerLayoutDemo.java
│ │ │ ├── MaterialMenuDemo.java
│ │ │ ├── ChromeHomeDemo.java
│ │ │ └── XiaoMaIntroDemo.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
├── build.gradle
└── demo.iml
├── library
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── linfaxin
│ │ └── transitionplayer
│ │ ├── control
│ │ ├── PlayControl.java
│ │ └── ModifyAnimatorsPlayControl.java
│ │ ├── interpolators
│ │ ├── WrappedTimeInterpolator.java
│ │ ├── LockEndTimeInterpolator.java
│ │ ├── LockStartTimeInterpolator.java
│ │ ├── ReverseTimeInterpolator.java
│ │ └── MultiTimeInterpolator.java
│ │ ├── transitions
│ │ ├── ChangeTextColor.java
│ │ ├── ChangeBackground.java
│ │ ├── ChangeAlpha.java
│ │ ├── ChangeScale.java
│ │ ├── ChangeRotate.java
│ │ ├── ChangeTransition.java
│ │ └── AbsChangeValue.java
│ │ ├── AnimatorUtils.java
│ │ └── TransitionPlayer.java
├── build.gradle
├── proguard-rules.pro
└── library.iml
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── TransitionPlayer.iml
├── README.md
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | TransitionPlayer
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':demo', ':library'
2 |
--------------------------------------------------------------------------------
/demo/demo_menu.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/demo_menu.gif
--------------------------------------------------------------------------------
/demo/demo_chrome_home.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/demo_chrome_home.gif
--------------------------------------------------------------------------------
/demo/demo_drawerlayout.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/demo_drawerlayout.gif
--------------------------------------------------------------------------------
/demo/demo_xiaoma_intro.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/demo_xiaoma_intro.gif
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/actionbar_ic_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/actionbar_ic_more.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/actionbar_ic_windows.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/actionbar_ic_windows.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_red.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_blue.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_green.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_top_text1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_top_text1.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_top_text2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_top_text2.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_top_text3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_top_text3.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_top_text4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_top_text4.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_bottom_text1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_bottom_text1.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_ask_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_ask_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_low_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_low_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_orange.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_orange.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_purple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_purple.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_xiaoma.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_xiaoma.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_yellow.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img1.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img2.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img3.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img4.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img5.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page3_img6.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page4_img1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page4_img1.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page4_img2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page4_img2.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page4_img3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page4_img3.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page4_img4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_page4_img4.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_carpay_ind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_carpay_ind.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_compe_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_compe_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_keepup_ind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_keepup_ind.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_newcar_ind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_newcar_ind.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_real_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_real_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_sign_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_sign_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_take_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_take_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_deep_purple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_deep_purple.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_deposit_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_deposit_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_deserv_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_deserv_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_privacy_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_privacy_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_promise_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_promise_icon.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_usedcar_ind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/TransitionPlayer/master/demo/src/main/res/drawable-xhdpi/xiaoma_intro_img_usedcar_ind.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TransitionPlayerDemo
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/demo/src/main/res/drawable/chrome_home_head_input_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demo/src/main/res/drawable/btn_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/demo/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/demo/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/control/PlayControl.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.control;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.transitions.everywhere.Transition;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by linfaxin on 2015/8/8.
10 | * Email: linlinfaxin@163.com
11 | */
12 | public interface PlayControl {
13 | void onPreRunAnimator(Transition transition, ArrayList animators);
14 | }
15 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/interpolators/WrappedTimeInterpolator.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.interpolators;
2 |
3 | import android.animation.TimeInterpolator;
4 |
5 | /**
6 | * Created by linfaxin on 2015/8/9.
7 | * Email: linlinfaxin@163.com
8 | */
9 | public abstract class WrappedTimeInterpolator implements TimeInterpolator{
10 | TimeInterpolator wrapped;
11 | public WrappedTimeInterpolator(TimeInterpolator wrapped) {
12 | this.wrapped = wrapped;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/interpolators/LockEndTimeInterpolator.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.interpolators;
2 |
3 | import android.animation.TimeInterpolator;
4 |
5 | /**
6 | * Created by linfaxin on 2015/8/9.
7 | * Email: linlinfaxin@163.com
8 | */
9 | public class LockEndTimeInterpolator extends WrappedTimeInterpolator{
10 | public LockEndTimeInterpolator(TimeInterpolator wrapped) {
11 | super(wrapped);
12 | }
13 | @Override
14 | public float getInterpolation(float input) {
15 | return 1;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/interpolators/LockStartTimeInterpolator.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.interpolators;
2 |
3 | import android.animation.TimeInterpolator;
4 |
5 | /**
6 | * Created by linfaxin on 2015/8/9.
7 | * Email: linlinfaxin@163.com
8 | */
9 | public class LockStartTimeInterpolator extends WrappedTimeInterpolator{
10 | public LockStartTimeInterpolator(TimeInterpolator wrapped) {
11 | super(wrapped);
12 | }
13 | @Override
14 | public float getInterpolation(float input) {
15 | return 0;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/interpolators/ReverseTimeInterpolator.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.interpolators;
2 |
3 | import android.animation.TimeInterpolator;
4 |
5 | /**
6 | * Created by linfaxin on 2015/8/9.
7 | * Email: linlinfaxin@163.com
8 | */
9 | public class ReverseTimeInterpolator extends WrappedTimeInterpolator{
10 | public ReverseTimeInterpolator(TimeInterpolator wrapped) {
11 | super(wrapped);
12 | }
13 | @Override
14 | public float getInterpolation(float input) {
15 | return wrapped.getInterpolation(1-input);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 22
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile "com.github.andkulikov:transitions-everywhere:1.4.0"
24 | }
25 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/demo/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Administrator\Desktop\java\android-sdk-windows/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Administrator\Desktop\java\android-sdk-windows/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/demo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.linfaxin.transitionplayer.demo"
9 | minSdkVersion 14
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:22.2.0'
25 | compile 'com.daimajia.swipelayout:library:1.2.0'
26 | compile project(':library')
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/TransitionPlayer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/transitions/ChangeTextColor.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.transitions;
2 |
3 | import android.animation.ArgbEvaluator;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | /**
8 | * Created by linfaxin on 2015/8/9.
9 | * Email: linlinfaxin@163.com
10 | */
11 | public class ChangeTextColor extends AbsChangeValue{
12 | public ChangeTextColor() {
13 | super(new ArgbEvaluator(), "textColor", "hintTextColor");
14 | }
15 |
16 | @Override
17 | protected Object getPropertyValue(View view, String propertyName) {
18 | if(view instanceof TextView){
19 | if("textColor".equals(propertyName)){
20 | return ((TextView) view).getCurrentTextColor();
21 | }
22 | if("hintTextColor".equals(propertyName)){
23 | return ((TextView) view).getCurrentHintTextColor();
24 | }
25 | }
26 | return super.getPropertyValue(view, propertyName);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/demo_material_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/material_menu_option.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
19 |
26 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/material_menu_x.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
20 |
27 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/linfaxin/transitionplayer/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.demo;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.ActionBarActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 |
9 | public class MainActivity extends ActionBarActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 | }
16 |
17 | public void ShowDrawerLayoutDemo(View view) {
18 | startActivity(new Intent(this, DrawerLayoutDemo.class));
19 | }
20 |
21 | public void ShowMaterialMenuDemo(View view) {
22 | startActivity(new Intent(this, MaterialMenuDemo.class));
23 | }
24 |
25 | public void ShowChromeHomeDemo(View view) {
26 | startActivity(new Intent(this, ChromeHomeDemo.class));
27 | }
28 |
29 | public void ShowXiaoMaIntroDemo(View view) {
30 | startActivity(new Intent(this, XiaoMaIntroDemo.class));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_page_base.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
19 |
20 |
29 |
30 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/control/ModifyAnimatorsPlayControl.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.control;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ValueAnimator;
5 | import android.transitions.everywhere.Transition;
6 |
7 | import com.linfaxin.transitionplayer.AnimatorUtils;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by linfaxin on 2015/8/8.
13 | * Email: linlinfaxin@163.com
14 | */
15 | public abstract class ModifyAnimatorsPlayControl implements PlayControl{
16 | @Override
17 | public void onPreRunAnimator(Transition transition, ArrayList animators) {
18 | ArrayList newAnimators = new ArrayList<>();
19 | for(int i=0, size=animators.size(); i
2 |
6 |
14 |
21 |
29 |
--------------------------------------------------------------------------------
/demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/material_menu_y.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
22 |
30 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/transitions/ChangeBackground.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.transitions;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ArgbEvaluator;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.ValueAnimator;
7 | import android.graphics.drawable.ColorDrawable;
8 | import android.graphics.drawable.Drawable;
9 | import android.transitions.everywhere.Transition;
10 | import android.transitions.everywhere.TransitionValues;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | /**
15 | * Created by linfaxin on 2015/5/29.
16 | * Email: linlinfaxin@163.com
17 | */
18 | public class ChangeBackground extends AbsChangeValue {
19 | private static final String FIELD_NAME = "backgroundColor";
20 |
21 | public ChangeBackground() {
22 | super(new ArgbEvaluator(), FIELD_NAME);
23 | }
24 |
25 | @Override
26 | protected Object getPropertyValue(View view, String propertyName) {
27 | if(FIELD_NAME.equals(propertyName)){
28 | Drawable drawable = view.getBackground();
29 | if(drawable instanceof ColorDrawable){
30 | return ((ColorDrawable) drawable).getColor();
31 | }
32 | }
33 | return super.getPropertyValue(view, propertyName);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
17 |
22 |
27 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/demo_drawerlayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
21 |
22 |
27 |
32 |
33 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/transitions/ChangeAlpha.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.transitions;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.transitions.everywhere.Transition;
6 | import android.transitions.everywhere.TransitionValues;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | /**
11 | * Created by linfaxin on 2015/5/29.
12 | * Email: linlinfaxin@163.com
13 | */
14 | public class ChangeAlpha extends Transition {
15 | private static final String PROPNAME_ALPHA = "android:alpha:alpha";
16 |
17 | @Override
18 | public void captureStartValues(TransitionValues transitionValues) {
19 | transitionValues.values.put(PROPNAME_ALPHA, transitionValues.view.getAlpha());
20 | }
21 |
22 | @Override
23 | public void captureEndValues(TransitionValues transitionValues) {
24 | transitionValues.values.put(PROPNAME_ALPHA, transitionValues.view.getAlpha());
25 | }
26 |
27 | @Override
28 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
29 | TransitionValues endValues) {
30 | if (startValues == null || endValues == null) {
31 | return null;
32 | }
33 | final View view = endValues.view;
34 | float startAlpha = (Float) startValues.values.get(PROPNAME_ALPHA);
35 | float endAlpha = (Float) endValues.values.get(PROPNAME_ALPHA);
36 | if (startAlpha != endAlpha) {
37 | view.setAlpha(startAlpha);
38 | return ObjectAnimator.ofFloat(view, "alpha", startAlpha, endAlpha);
39 | }
40 | return null;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TransitionPlayer
2 | Android library to control Transition animates. A simple way to create a interactive animation.
3 | 
4 |
5 | ## Demo1 SimpleTransition
6 | 
7 | ### Code:
8 | ```java
9 | ......
10 | TransitionManager.beginDelayedTransition(mSceneRoot, transitionPlayer);
11 |
12 | imageView.setRotation(360);
13 | imageView.setRotationX(270);
14 | imageView.setRotationY(180);
15 | imageView.setTranslationX(70 * getResources().getDisplayMetrics().density);
16 | imageView.setScaleX(0.2f);
17 | imageView.setScaleY(0f);
18 | imageView.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_bright));
19 | ......
20 | drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
21 | public void onDrawerSlide(View drawerView, float slideOffset) {
22 | transitionPlayer.setCurrentFraction(slideOffset);
23 | }
24 | });
25 | ```
26 |
27 | ## License
28 |
29 | MIT License.
30 |
31 | ## Demo2 MaterialMenu
32 | 
33 | ### Code:
34 | ```java
35 | ......
36 | int[] layouts = new int[]{R.layout.material_menu_option, R.layout.material_menu_back, R.layout.material_menu_y};
37 | Scene scene = Scene.getSceneForLayout(mSceneRoot, layout[random.nextInt(layouts.length)], context);
38 | TransitionManager.go(scene, transitionPlayer);
39 | ......
40 | drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
41 | public void onDrawerSlide(View drawerView, float slideOffset) {
42 | transitionPlayer.setCurrentFraction(slideOffset);
43 | }
44 | });
45 | ```
46 |
47 |
48 |
49 | ## Demo3 ChromeAppIndexPage
50 | 
51 | ### Code:
52 | [ChromeHomeDemo.java](demo/src/main/java/com/linfaxin/transitionplayer/demo/ChromeHomeDemo.java)
53 |
54 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/interpolators/MultiTimeInterpolator.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.interpolators;
2 |
3 | import android.animation.TimeInterpolator;
4 | import android.util.Pair;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by linfaxin on 2015/8/9.
10 | * Email: linlinfaxin@163.com
11 | */
12 | public class MultiTimeInterpolator implements TimeInterpolator{
13 | ArrayList> pairs = new ArrayList<>();
14 | private int totalWeight = 0;
15 | public MultiTimeInterpolator(TimeInterpolator... interpolators){
16 | addInterpolators(interpolators);
17 | }
18 |
19 | public void addInterpolators(TimeInterpolator... interpolators){
20 | for(TimeInterpolator interpolator : interpolators){
21 | addInterpolator(interpolator, 1);
22 | }
23 | }
24 | public void addInterpolator(TimeInterpolator interpolator){
25 | addInterpolator(interpolator, 1);
26 | }
27 |
28 | public void addInterpolator(TimeInterpolator interpolator, float weight){
29 | if(interpolator==null || weight<0) return;
30 | pairs.add(new Pair<>(interpolator, weight));
31 | totalWeight += weight;
32 | }
33 |
34 | @Override
35 | public float getInterpolation(float input) {
36 | float weightSum = 0;
37 | for(Pair pair : pairs){
38 | float weight = pair.second;
39 | float weightStart = weightSum;
40 | float weightEnd = weightStart + weight;
41 | float inputWeight = input * totalWeight;
42 | if(inputWeight > weightStart && inputWeight <= weightEnd){
43 | float convertInput = (inputWeight - weightStart) / weight;
44 | return pair.first.getInterpolation(convertInput);
45 | }
46 | weightSum = weightEnd;
47 | }
48 | return 0;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/linfaxin/transitionplayer/demo/DrawerLayoutDemo.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.widget.DrawerLayout;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.transitions.everywhere.TransitionManager;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.view.ViewTreeObserver;
10 | import android.widget.ImageView;
11 |
12 | import com.linfaxin.transitionplayer.TransitionPlayer;
13 |
14 | /**
15 | * Created by linfaxin on 2015/8/1.
16 | * Email: linlinfaxin@163.com
17 | */
18 | public class DrawerLayoutDemo extends ActionBarActivity {
19 | DrawerLayout drawerLayout;
20 | ImageView imageView;
21 | ViewGroup mSceneRoot;
22 | TransitionPlayer transitionPlayer = new TransitionPlayer();
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.demo_drawerlayout);
27 | drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
28 | imageView = (ImageView) findViewById(R.id.imageView);
29 | mSceneRoot = (ViewGroup) findViewById(R.id.sceneRootView);
30 |
31 | imageView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
32 | @Override
33 | public boolean onPreDraw() {
34 | imageView.getViewTreeObserver().removeOnPreDrawListener(this);
35 | //after layout is ok, then change view
36 | TransitionManager.beginDelayedTransition(mSceneRoot, transitionPlayer);
37 |
38 | imageView.setRotation(360);
39 | imageView.setRotationX(270);
40 | imageView.setRotationY(180);
41 | imageView.setTranslationX(70 * getResources().getDisplayMetrics().density);
42 | imageView.setScaleX(0.2f);
43 | imageView.setScaleY(0f);
44 | imageView.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_bright));
45 | return false;
46 | }
47 | });
48 |
49 | drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
50 | @Override
51 | public void onDrawerSlide(View drawerView, float slideOffset) {
52 | super.onDrawerSlide(drawerView, slideOffset);
53 | transitionPlayer.setCurrentFraction(slideOffset);
54 | }
55 | });
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_scene1_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
31 |
32 |
39 |
40 |
50 |
51 |
61 |
62 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/chrome_home_head_state_expand.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
29 |
30 |
38 |
39 |
46 |
47 |
58 |
59 |
65 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/chrome_home_head_state_collapse.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
29 |
30 |
38 |
39 |
48 |
49 |
60 |
61 |
66 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/transitions/ChangeScale.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.transitions;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.transitions.everywhere.Transition;
7 | import android.transitions.everywhere.TransitionValues;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | /**
12 | * Created by linfaxin on 2015/5/29.
13 | * Email: linlinfaxin@163.com
14 | */
15 | public class ChangeScale extends Transition {
16 | private static final String PROPNAME_NAME1 = "android:scale:scalex";
17 | private static final String PROPNAME_NAME2 = "android:scale:scaley";
18 | private static final String FIELD_NAME1 = "scaleX";
19 | private static final String FIELD_NAME2 = "scaleY";
20 |
21 | @Override
22 | public void captureStartValues(TransitionValues transitionValues) {
23 | transitionValues.values.put(PROPNAME_NAME1, transitionValues.view.getScaleX());
24 | transitionValues.values.put(PROPNAME_NAME2, transitionValues.view.getScaleY());
25 | }
26 |
27 | @Override
28 | public void captureEndValues(TransitionValues transitionValues) {
29 | transitionValues.values.put(PROPNAME_NAME1, transitionValues.view.getScaleX());
30 | transitionValues.values.put(PROPNAME_NAME2, transitionValues.view.getScaleY());
31 | }
32 |
33 | @Override
34 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
35 | TransitionValues endValues) {
36 | if (startValues == null || endValues == null) {
37 | return null;
38 | }
39 | final View view = endValues.view;
40 | float startValueX = (Float) startValues.values.get(PROPNAME_NAME1);
41 | float startValueY = (Float) startValues.values.get(PROPNAME_NAME2);
42 | float endValueX = (Float) endValues.values.get(PROPNAME_NAME1);
43 | float endValueY = (Float) endValues.values.get(PROPNAME_NAME2);
44 | AnimatorSet animatorSet = new AnimatorSet();
45 | if (startValueX != endValueX) {
46 | view.setScaleX(startValueX);
47 | animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME1, startValueX, endValueX));
48 | }
49 | if (startValueY != endValueY) {
50 | view.setScaleY(startValueY);
51 | animatorSet.playTogether( ObjectAnimator.ofFloat(view, FIELD_NAME2, startValueY, endValueY));
52 | }
53 | if(animatorSet.getChildAnimations()!=null && animatorSet.getChildAnimations().size()>0){
54 | return animatorSet;
55 | }
56 | return null;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/demo_chrome_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
12 |
16 |
23 |
25 |
30 |
35 |
36 |
38 |
43 |
48 |
49 |
51 |
56 |
61 |
62 |
63 |
64 |
65 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/demo_xiaoma_intro.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
16 |
17 |
18 |
23 |
24 |
25 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
41 |
42 |
43 |
44 |
45 |
46 |
50 |
51 |
64 |
65 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/linfaxin/transitionplayer/demo/MaterialMenuDemo.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.widget.DrawerLayout;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.transitions.everywhere.Scene;
7 | import android.transitions.everywhere.TransitionManager;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.ViewTreeObserver;
11 |
12 | import com.linfaxin.transitionplayer.TransitionPlayer;
13 |
14 | import java.util.Random;
15 |
16 | /**
17 | * Created by linfaxin on 2015/8/1.
18 | * Email: linlinfaxin@163.com
19 | */
20 | public class MaterialMenuDemo extends ActionBarActivity {
21 | DrawerLayout drawerLayout;
22 | ViewGroup mSceneRoot;
23 | TransitionPlayer transitionPlayer = new TransitionPlayer();
24 | int[] layouts = new int[]{R.layout.material_menu_option, R.layout.material_menu_back,
25 | R.layout.material_menu_x, R.layout.material_menu_y};
26 | int currentLayoutIndex = 0;
27 | boolean willOpen = true;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.demo_material_menu);
33 | drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
34 | mSceneRoot = (ViewGroup) findViewById(R.id.sceneRootView);
35 |
36 |
37 | drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
38 | @Override
39 | public void onDrawerSlide(View drawerView, float slideOffset) {
40 | super.onDrawerSlide(drawerView, slideOffset);
41 | transitionPlayer.setCurrentFraction(willOpen ? slideOffset : 1-slideOffset);
42 | }
43 |
44 | @Override
45 | public void onDrawerClosed(View drawerView) {
46 | super.onDrawerClosed(drawerView);
47 | preTransition();
48 | willOpen = true;
49 | }
50 |
51 | @Override
52 | public void onDrawerOpened(View drawerView) {
53 | super.onDrawerOpened(drawerView);
54 | preTransition();
55 | willOpen = false;
56 | }
57 | });
58 |
59 | preTransition();
60 | }
61 |
62 | private void preTransition(){
63 | Random r = new Random();
64 | mSceneRoot.removeAllViews();
65 |
66 | int toIndex = r.nextInt(layouts.length);
67 | while (toIndex == currentLayoutIndex){
68 | toIndex = r.nextInt(layouts.length);
69 | }
70 |
71 | //lock current layout
72 | View.inflate(this, layouts[currentLayoutIndex], mSceneRoot);
73 | //pre next layout
74 | final Scene scene = Scene.getSceneForLayout(mSceneRoot, layouts[toIndex], MaterialMenuDemo.this);
75 | mSceneRoot.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
76 | @Override
77 | public boolean onPreDraw() {
78 | mSceneRoot.getViewTreeObserver().removeOnPreDrawListener(this);
79 | TransitionManager.go(scene, transitionPlayer);
80 | return false;
81 | }
82 | });
83 |
84 | currentLayoutIndex = toIndex;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/transitions/ChangeRotate.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.transitions;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.transitions.everywhere.Transition;
7 | import android.transitions.everywhere.TransitionValues;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | /**
12 | * Created by linfaxin on 2015/5/29.
13 | * Email: linlinfaxin@163.com
14 | */
15 | public class ChangeRotate extends Transition {
16 | private static final String PROPNAME_NAME = "android:rotate:rotate";
17 | private static final String PROPNAME_NAME_X = "android:rotate:rotateX";
18 | private static final String PROPNAME_NAME_Y = "android:rotate:rotateY";
19 | private static final String FIELD_NAME = "rotation";
20 | private static final String FIELD_NAME_X = "rotationX";
21 | private static final String FIELD_NAME_Y = "rotationY";
22 |
23 | @Override
24 | public void captureStartValues(TransitionValues transitionValues) {
25 | transitionValues.values.put(PROPNAME_NAME, transitionValues.view.getRotation());
26 | transitionValues.values.put(PROPNAME_NAME_X, transitionValues.view.getRotationX());
27 | transitionValues.values.put(PROPNAME_NAME_Y, transitionValues.view.getRotationY());
28 | }
29 |
30 | @Override
31 | public void captureEndValues(TransitionValues transitionValues) {
32 | transitionValues.values.put(PROPNAME_NAME, transitionValues.view.getRotation());
33 | transitionValues.values.put(PROPNAME_NAME_X, transitionValues.view.getRotationX());
34 | transitionValues.values.put(PROPNAME_NAME_Y, transitionValues.view.getRotationY());
35 | }
36 |
37 | @Override
38 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
39 | TransitionValues endValues) {
40 | if (startValues == null || endValues == null) {
41 | return null;
42 | }
43 | final View view = endValues.view;
44 | float startValue = (Float) startValues.values.get(PROPNAME_NAME);
45 | float startValueX = (Float) startValues.values.get(PROPNAME_NAME_X);
46 | float startValueY = (Float) startValues.values.get(PROPNAME_NAME_Y);
47 | float endValue = (Float) endValues.values.get(PROPNAME_NAME);
48 | float endValueX = (Float) endValues.values.get(PROPNAME_NAME_X);
49 | float endValueY = (Float) endValues.values.get(PROPNAME_NAME_Y);
50 | AnimatorSet animatorSet = new AnimatorSet();
51 | if (startValue != endValue) {
52 | view.setRotation(startValue);
53 | animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME, startValue, endValue));
54 | }
55 | if (startValueX != endValueX) {
56 | view.setRotationX(startValueX);
57 | animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME_X, startValueX, endValueX));
58 | }
59 | if (startValueY != endValueY) {
60 | view.setRotationY(startValueY);
61 | animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME_Y, startValueY, endValueY));
62 | }
63 | if(animatorSet.getChildAnimations()!=null && animatorSet.getChildAnimations().size()>0){
64 | return animatorSet;
65 | }
66 | return null;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/transitions/ChangeTransition.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.transitions;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.transitions.everywhere.Transition;
7 | import android.transitions.everywhere.TransitionValues;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | /**
12 | * Created by linfaxin on 2015/5/29.
13 | * Email: linlinfaxin@163.com
14 | */
15 | public class ChangeTransition extends Transition {
16 | private static final String PROPNAME_NAME1 = "android:transition:translationx";
17 | private static final String PROPNAME_NAME2 = "android:transition:translationy";
18 | // private static final String PROPNAME_NAME3 = "android:transition:translationz";
19 | private static final String FIELD_NAME1 = "translationX";
20 | private static final String FIELD_NAME2 = "translationY";
21 | // private static final String FIELD_NAME3 = "translationZ";
22 |
23 | @Override
24 | public void captureStartValues(TransitionValues transitionValues) {
25 | transitionValues.values.put(PROPNAME_NAME1, transitionValues.view.getTranslationX());
26 | transitionValues.values.put(PROPNAME_NAME2, transitionValues.view.getTranslationY());
27 | // transitionValues.values.put(PROPNAME_NAME3, transitionValues.view.getTranslationZ());
28 | }
29 |
30 | @Override
31 | public void captureEndValues(TransitionValues transitionValues) {
32 | transitionValues.values.put(PROPNAME_NAME1, transitionValues.view.getTranslationX());
33 | transitionValues.values.put(PROPNAME_NAME2, transitionValues.view.getTranslationY());
34 | // transitionValues.values.put(PROPNAME_NAME3, transitionValues.view.getTranslationZ());
35 | }
36 |
37 | @Override
38 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
39 | TransitionValues endValues) {
40 | if (startValues == null || endValues == null) {
41 | return null;
42 | }
43 | final View view = endValues.view;
44 | float startValueX = (Float) startValues.values.get(PROPNAME_NAME1);
45 | float startValueY = (Float) startValues.values.get(PROPNAME_NAME2);
46 | // float startValueZ = (Float) startValues.values.get(PROPNAME_NAME3);
47 | float endValueX = (Float) endValues.values.get(PROPNAME_NAME1);
48 | float endValueY = (Float) endValues.values.get(PROPNAME_NAME2);
49 | // float endValueZ = (Float) endValues.values.get(PROPNAME_NAME3);
50 | AnimatorSet animatorSet = new AnimatorSet();
51 | if (startValueX != endValueX) {
52 | view.setTranslationX(startValueX);
53 | animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME1, startValueX, endValueX));
54 | }
55 | if (startValueY != endValueY) {
56 | view.setTranslationY(startValueY);
57 | animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME2, startValueY, endValueY));
58 | }
59 | // if (startValueZ != endValueZ) {
60 | // view.setTranslationZ(startValueZ);
61 | // animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME3, startValueZ, endValueZ));
62 | // }
63 | if(animatorSet.getChildAnimations()!=null && animatorSet.getChildAnimations().size()>0){
64 | return animatorSet;
65 | }
66 | return null;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_scene3.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
30 |
31 |
32 |
41 |
42 |
43 |
52 |
53 |
63 |
64 |
65 |
74 |
75 |
83 |
84 |
85 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_scene4.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
31 |
32 |
41 |
42 |
51 |
52 |
61 |
62 |
72 |
73 |
82 |
83 |
92 |
93 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_scene1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
31 |
32 |
42 |
43 |
51 |
52 |
61 |
62 |
72 |
73 |
83 |
84 |
91 |
92 |
93 |
100 |
101 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_scene2.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
22 |
32 |
33 |
43 |
44 |
54 |
55 |
65 |
66 |
67 |
74 |
75 |
85 |
86 |
96 |
97 |
105 |
106 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/AnimatorUtils.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.PropertyValuesHolder;
7 | import android.animation.ValueAnimator;
8 | import android.annotation.TargetApi;
9 | import android.os.Build;
10 | import android.transitions.everywhere.Transition;
11 | import android.transitions.everywhere.TransitionSet;
12 |
13 | import com.linfaxin.transitionplayer.interpolators.ReverseTimeInterpolator;
14 |
15 | import java.lang.reflect.Field;
16 | import java.lang.reflect.Method;
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | /**
21 | * Created by linfaxin on 2015/8/8.
22 | * Email: linlinfaxin@163.com
23 | */
24 | public class AnimatorUtils {
25 |
26 | public static List splitAnimatorByValues(ValueAnimator animator){
27 | ArrayList animators = new ArrayList<>();
28 | PropertyValuesHolder[] valuesHolders = animator.getValues();
29 | if(valuesHolders!=null && valuesHolders.length>0){
30 | for(PropertyValuesHolder valuesHolder : valuesHolders){
31 | ValueAnimator clone = animator.clone();
32 | if(clone instanceof ObjectAnimator){
33 | ((ObjectAnimator) clone).setPropertyName(valuesHolder.getPropertyName());
34 | }
35 | clone.setValues(valuesHolder);
36 | animators.add(clone);
37 | }
38 | }else{
39 | animators.add(animator);
40 | }
41 | return animators;
42 | }
43 |
44 | public static float getAnimatorDurationScale() {
45 | try {
46 | Method method = ValueAnimator.class.getDeclaredMethod("getDurationScale");
47 | method.setAccessible(true);
48 | float scale = ((Float) method.invoke(ValueAnimator.class)).floatValue();
49 | if(scale<=0){
50 | method = ValueAnimator.class.getDeclaredMethod("setDurationScale", float.class);
51 | method.setAccessible(true);
52 | method.invoke(ValueAnimator.class, 1);
53 | return 1;
54 | }
55 | return scale;
56 | } catch (Exception ignore) {
57 | }
58 | return 1;
59 | }
60 |
61 | public static List collectValueAnimators(Animator animator){
62 | ArrayList valueAnimators = new ArrayList();
63 | for(Animator anim : collectAnimators(animator)){
64 | if(anim instanceof ValueAnimator){
65 | valueAnimators.add((ValueAnimator) anim);
66 | }
67 | }
68 | return valueAnimators;
69 | }
70 |
71 | public static List collectAnimators(Animator animator){
72 | if(animator instanceof AnimatorSet){
73 | return collectAnimatorsFromSet((AnimatorSet) animator);
74 |
75 | }else{
76 | ArrayList animators = new ArrayList();
77 | animators.add(animator);
78 | return animators;
79 | }
80 | }
81 |
82 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
83 | public static List collectAnimatorsFromSet(AnimatorSet animatorSet){
84 | ArrayList animators = new ArrayList();
85 | for(Animator animator : animatorSet.getChildAnimations()){
86 | animators.addAll(collectAnimators(animator));
87 | }
88 | return animators;
89 | }
90 |
91 | public static List collectAnimators(Transition transition){
92 | if(transition instanceof TransitionSet){
93 | return collectAnimatorsFromSet((TransitionSet) transition);
94 | }
95 | return collectAnimatorsFromTransition(transition);
96 | }
97 |
98 | private static List collectAnimatorsFromSet(TransitionSet transitionSet){
99 | ArrayList animators = new ArrayList();
100 | for(int i=0, count = transitionSet.getTransitionCount(); i collectAnimatorsFromTransition(Transition transition){
107 | try {
108 | Field field = Transition.class.getDeclaredField("mAnimators");
109 | field.setAccessible(true);
110 | return (List) field.get(transition);
111 | } catch (Exception e) {
112 | e.printStackTrace();
113 | }
114 | return new ArrayList();
115 | }
116 |
117 | public static void reverseAnimator(Animator animator){
118 | if(animator instanceof ValueAnimator){
119 | animator.setInterpolator(new ReverseTimeInterpolator(((ValueAnimator)animator).getInterpolator()));
120 | }else if(Build.VERSION.SDK_INT>=18){
121 | animator.setInterpolator(new ReverseTimeInterpolator(animator.getInterpolator()));
122 | }
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_scene4_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
25 |
32 |
40 |
41 |
42 |
48 |
53 |
60 |
68 |
69 |
70 |
76 |
81 |
88 |
96 |
97 |
98 |
104 |
109 |
116 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/TransitionPlayer.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer;
2 |
3 | import android.animation.Animator;
4 | import android.animation.TimeInterpolator;
5 | import android.animation.ValueAnimator;
6 | import android.os.Build;
7 | import android.transitions.everywhere.ChangeBounds;
8 | import android.transitions.everywhere.Fade;
9 | import android.transitions.everywhere.Transition;
10 | import android.transitions.everywhere.TransitionSet;
11 | import android.transitions.everywhere.TransitionValues;
12 | import android.view.ViewGroup;
13 | import android.view.animation.LinearInterpolator;
14 |
15 | import com.linfaxin.transitionplayer.control.PlayControl;
16 | import com.linfaxin.transitionplayer.transitions.ChangeAlpha;
17 | import com.linfaxin.transitionplayer.transitions.ChangeBackground;
18 | import com.linfaxin.transitionplayer.transitions.ChangeRotate;
19 | import com.linfaxin.transitionplayer.transitions.ChangeScale;
20 | import com.linfaxin.transitionplayer.transitions.ChangeTextColor;
21 | import com.linfaxin.transitionplayer.transitions.ChangeTransition;
22 |
23 | import java.lang.reflect.Method;
24 | import java.util.ArrayList;
25 | import java.util.LinkedHashMap;
26 |
27 | /**
28 | * Created by linfaxin on 2015/5/27.
29 | * Email: linlinfaxin@163.com
30 | */
31 | public class TransitionPlayer extends TransitionSet {
32 | private LinkedHashMap> animMap = new LinkedHashMap<>();
33 | private PlayControl playControl;
34 | public final ChangeBounds changeBounds = new ChangeBounds();
35 | public final ChangeAlpha changeAlpha = new ChangeAlpha();
36 | public final ChangeRotate changeRotate = new ChangeRotate();
37 | public final ChangeScale changeScale = new ChangeScale();
38 | public final ChangeTransition changeTransition = new ChangeTransition();
39 | public final ChangeBackground changeBackground = new ChangeBackground();
40 | public final ChangeTextColor changeTextColor = new ChangeTextColor();
41 | public final Fade fadeOut = new Fade(Fade.OUT);
42 | public final Fade fadeIn = new Fade(Fade.IN);
43 |
44 | public TransitionPlayer() {
45 |
46 | setOrdering(TransitionSet.ORDERING_TOGETHER);
47 | setDuration(300);
48 |
49 | addTransition(changeBounds);
50 | addTransition(changeAlpha);
51 | addTransition(changeRotate);
52 | addTransition(changeScale);
53 | addTransition(changeTransition);
54 | addTransition(changeBackground);
55 | addTransition(changeTextColor);
56 |
57 | addTransition(fadeOut);
58 | addTransition(fadeIn);
59 |
60 | setInterpolator(new LinearInterpolator());
61 | }
62 |
63 | private void reflectSetupStartEndListeners() {
64 | try {
65 | Method method = TransitionSet.class.getDeclaredMethod("setupStartEndListeners");
66 | method.setAccessible(true);
67 | method.invoke(this);
68 | } catch (Exception ignore) {
69 | }
70 | }
71 |
72 | @Override
73 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
74 | TransitionValues endValues) {
75 | return null;
76 | }
77 |
78 | @Override
79 | protected void runAnimators() {
80 | reflectSetupStartEndListeners();
81 | animMap.clear();
82 | for(int i=0, count = getTransitionCount(); i valueAnimators = new ArrayList<>();
85 | for(Animator animator : AnimatorUtils.collectAnimators(transition)){
86 | valueAnimators.addAll(AnimatorUtils.collectValueAnimators(animator));
87 | }
88 |
89 | //insure animator's duration, startDelay, Interpolator same as this transition
90 | long duration = (long) (getDuration()/ AnimatorUtils.getAnimatorDurationScale());
91 | long startDelay = getStartDelay();
92 | TimeInterpolator interpolator = getInterpolator();
93 | for (ValueAnimator animator : valueAnimators) {
94 | if (duration >= 0) animator.setDuration(duration);
95 | if (startDelay >= 0) animator.setStartDelay(startDelay + animator.getStartDelay());
96 | if (interpolator != null) animator.setInterpolator(interpolator);
97 | }
98 |
99 | animMap.put(transition, valueAnimators);
100 | //you can change transition's duration, startDelay and Interpolator at here
101 | if(playControl!=null) playControl.onPreRunAnimator(transition, valueAnimators);
102 | }
103 |
104 | }
105 |
106 | public ArrayList getAllAnimator(){
107 | ArrayList animators = new ArrayList<>();
108 | for(ArrayList value : animMap.values()){
109 | animators.addAll(value);
110 | }
111 | return animators;
112 | }
113 |
114 | public void setCurrentFraction(float fraction){
115 | if(Build.VERSION.SDK_INT>Build.VERSION_CODES.LOLLIPOP){
116 | for (ValueAnimator valueAnimator : getAllAnimator()) {
117 | valueAnimator.setCurrentFraction(fraction);
118 | }
119 | }else{
120 | setCurrentPlayTime((long) (fraction * getDuration()));
121 | }
122 | }
123 | public void setCurrentPlayTime(long playTime){
124 | for (ValueAnimator valueAnimator : getAllAnimator()) {
125 | playTime -= valueAnimator.getStartDelay();
126 | if(playTime<0) playTime=0;
127 | valueAnimator.setCurrentPlayTime(playTime);
128 | }
129 | }
130 |
131 | public PlayControl getPlayControl() {
132 | return playControl;
133 | }
134 |
135 | public void setPlayControl(PlayControl playControl) {
136 | this.playControl = playControl;
137 | }
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_scene2_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
30 |
31 |
37 |
38 |
47 |
48 |
57 |
58 |
59 |
67 |
68 |
78 |
79 |
85 |
86 |
87 |
88 |
96 |
97 |
107 |
108 |
114 |
115 |
116 |
117 |
125 |
126 |
127 |
136 |
137 |
145 |
146 |
155 |
156 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/linfaxin/transitionplayer/demo/ChromeHomeDemo.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.demo;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.TimeInterpolator;
7 | import android.animation.ValueAnimator;
8 | import android.os.Bundle;
9 | import android.support.v7.app.ActionBarActivity;
10 | import android.transitions.everywhere.ChangeBounds;
11 | import android.transitions.everywhere.Scene;
12 | import android.transitions.everywhere.Transition;
13 | import android.transitions.everywhere.TransitionManager;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.view.ViewTreeObserver;
17 | import android.view.animation.DecelerateInterpolator;
18 |
19 | import com.daimajia.swipe.SwipeLayout;
20 | import com.linfaxin.transitionplayer.AnimatorUtils;
21 | import com.linfaxin.transitionplayer.interpolators.LockEndTimeInterpolator;
22 | import com.linfaxin.transitionplayer.interpolators.LockStartTimeInterpolator;
23 | import com.linfaxin.transitionplayer.interpolators.MultiTimeInterpolator;
24 | import com.linfaxin.transitionplayer.interpolators.ReverseTimeInterpolator;
25 | import com.linfaxin.transitionplayer.transitions.ChangeAlpha;
26 | import com.linfaxin.transitionplayer.TransitionPlayer;
27 | import com.linfaxin.transitionplayer.control.ModifyAnimatorsPlayControl;
28 | import com.linfaxin.transitionplayer.transitions.ChangeTextColor;
29 |
30 | /**
31 | * Created by linfaxin on 2015/8/2.
32 | * Email: linlinfaxin@163.com
33 | */
34 | public class ChromeHomeDemo extends ActionBarActivity{
35 | SwipeLayout swipeLayout;
36 | TransitionPlayer transitionPlayer = new TransitionPlayer();
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.demo_chrome_home);
41 |
42 | swipeLayout = (SwipeLayout) findViewById(R.id.swipeLayout);
43 | swipeLayout.getDragEdgeMap().clear();
44 | swipeLayout.addDrag(SwipeLayout.DragEdge.Top, swipeLayout.getChildAt(0));
45 |
46 | swipeLayout.addRevealListener(R.id.placeHolder, new SwipeLayout.OnRevealListener() {
47 | @Override
48 | public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
49 | transitionPlayer.setCurrentFraction(fraction);
50 |
51 | }
52 | });
53 |
54 | swipeLayout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
55 | @Override
56 | public boolean onPreDraw() {
57 | swipeLayout.getViewTreeObserver().removeOnPreDrawListener(this);
58 | ViewGroup mSceneRoot = (ViewGroup) findViewById(R.id.sceneRootView);
59 | Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.chrome_home_head_state_expand, ChromeHomeDemo.this);
60 |
61 | transitionPlayer.setPlayControl(new ModifyAnimatorsPlayControl() {
62 | @Override
63 | protected Animator onModifyAnimator(Transition transition, ValueAnimator animator) {
64 | if (!(animator instanceof ObjectAnimator)) return animator;
65 | Object target = ((ObjectAnimator) animator).getTarget();
66 | if (!(target instanceof View)) return animator;
67 | View targetView = (View) target;
68 |
69 | //input view
70 | if (targetView.getId() == R.id.editText) {
71 | if (transition instanceof ChangeBounds) {
72 | AnimatorSet animatorSet = new AnimatorSet();
73 | for (ValueAnimator subAnimator : AnimatorUtils.splitAnimatorByValues(animator)) {
74 | animatorSet.playTogether(subAnimator);
75 |
76 | //let input view fast animate to right edge
77 | if (subAnimator instanceof ObjectAnimator
78 | && "right".equals(((ObjectAnimator) subAnimator).getPropertyName())) {
79 | MultiTimeInterpolator multi = new MultiTimeInterpolator();
80 | TimeInterpolator i = animator.getInterpolator();
81 | multi.addInterpolator(i, 6);
82 | LockEndTimeInterpolator end = new LockEndTimeInterpolator(i);
83 | multi.addInterpolator(end, 4);
84 | subAnimator.setInterpolator(multi);
85 | }
86 | }
87 | return animatorSet;
88 | } else if (transition instanceof ChangeTextColor) {
89 | TimeInterpolator i = animator.getInterpolator();
90 | LockEndTimeInterpolator end = new LockEndTimeInterpolator(i);
91 | ReverseTimeInterpolator r = new ReverseTimeInterpolator(i);
92 | animator.setInterpolator(new MultiTimeInterpolator(i, end, r));
93 | }
94 | }
95 |
96 | //logo view
97 | if (targetView.getId() == R.id.imageView && transition instanceof ChangeAlpha) {
98 | MultiTimeInterpolator multi = new MultiTimeInterpolator();
99 | TimeInterpolator i = new DecelerateInterpolator(1.6f);
100 | TimeInterpolator start = new LockStartTimeInterpolator(i);
101 | multi.addInterpolator(start, 4);
102 | multi.addInterpolator(i, 6);
103 | animator.setInterpolator(multi);
104 | }
105 | return animator;
106 | }
107 | });
108 |
109 |
110 |
111 | TransitionManager.go(scene, transitionPlayer);
112 |
113 | //after start transition, then init click.
114 | mSceneRoot.findViewById(R.id.editText).setOnClickListener(new View.OnClickListener() {
115 | @Override
116 | public void onClick(View v) {
117 | swipeLayout.close();
118 | }
119 | });
120 |
121 | return false;
122 | }
123 | });
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/library/src/main/java/com/linfaxin/transitionplayer/transitions/AbsChangeValue.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.transitions;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.RectEvaluator;
7 | import android.animation.TypeEvaluator;
8 | import android.transitions.everywhere.Transition;
9 | import android.transitions.everywhere.TransitionValues;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import java.lang.reflect.Method;
15 | import java.util.ArrayList;
16 |
17 | /**
18 | * Created by linfaxin on 2015/8/9.
19 | * Email: linlinfaxin@163.com
20 | */
21 | public abstract class AbsChangeValue extends Transition {
22 | protected String[] valueNames;
23 | protected final String propertyPrefix;
24 | private TypeEvaluator typeEvaluator;
25 |
26 | public AbsChangeValue(String... valueNames) {
27 | this(null, valueNames);
28 | }
29 | public AbsChangeValue(TypeEvaluator typeEvaluator, String... valueNames) {
30 | setTypeEvaluator(typeEvaluator);
31 | this.valueNames = valueNames;
32 | propertyPrefix = "android:" + getClass().getSimpleName() + ":";
33 | }
34 |
35 | public void setTypeEvaluator(TypeEvaluator typeEvaluator) {
36 | this.typeEvaluator = typeEvaluator;
37 | }
38 |
39 | @Override
40 | public void captureStartValues(TransitionValues transitionValues) {
41 | for(String valueName : valueNames) {
42 | transitionValues.values.put(propertyPrefix + valueName, getPropertyValue(transitionValues.view, valueName));
43 | }
44 | }
45 |
46 | @Override
47 | public void captureEndValues(TransitionValues transitionValues) {
48 | for(String valueName : valueNames) {
49 | transitionValues.values.put(propertyPrefix + valueName, getPropertyValue(transitionValues.view, valueName));
50 | }
51 | }
52 |
53 |
54 | @Override
55 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
56 | TransitionValues endValues) {
57 | if (startValues == null || endValues == null) {
58 | return null;
59 | }
60 | AnimatorSet animatorSet = new AnimatorSet();
61 | final View view = endValues.view;
62 |
63 | for(String valueName : valueNames) {
64 | Object startValue = startValues.values.get(propertyPrefix + valueName);
65 | Object endValue = endValues.values.get(propertyPrefix + valueName);
66 | if(startValue!=null && endValue!=null && startValue.getClass()!=endValue.getClass()) continue;
67 | Class c = null;
68 | if(startValue!=null) c= startValue.getClass();
69 | else if(endValue!=null) c=endValue.getClass();
70 | if(c==null) continue;
71 | ObjectAnimator animator;
72 | if(c==Float.class || c==float.class){
73 | animator = ObjectAnimator.ofFloat(view, valueName, (Float) startValue, (Float) endValue);
74 | animatorSet.playTogether(animator);
75 |
76 | }else if(c==Integer.class || c==int.class){
77 | animator = ObjectAnimator.ofInt(view, valueName, (Integer) startValue, (Integer) endValue);
78 | animatorSet.playTogether(animator);
79 |
80 | }else{
81 | animator = ObjectAnimator.ofObject(view, valueName, typeEvaluator, startValue, endValue);
82 | animatorSet.playTogether(animator);
83 | }
84 | setPropertyValue(view, valueName, startValue);
85 | if(typeEvaluator!=null) animator.setEvaluator(typeEvaluator);
86 | }
87 |
88 | ArrayList animators = animatorSet.getChildAnimations();
89 | if(animators!=null && animators.size()>0){
90 | if(animators.size()==1) return animators.get(0);
91 | return animatorSet;
92 | }
93 | return null;
94 | }
95 |
96 | protected Object getPropertyValue(View view, String propertyName){
97 | Class c = view.getClass();
98 | while(c!=Object.class){
99 | try {
100 | String methodName = getMethodName("get", propertyName);
101 | Method m = c.getDeclaredMethod(methodName);
102 | m.setAccessible(true);
103 | return m.invoke(view);
104 | }catch (Exception ignore){
105 | }
106 | c = c.getSuperclass();
107 | }
108 | return null;
109 | }
110 |
111 | // We try several different types when searching for appropriate setter/getter functions.
112 | // The caller may have supplied values in a type that does not match the setter/getter
113 | // functions (such as the integers 0 and 1 to represent floating point values for alpha).
114 | // Also, the use of generics in constructors means that we end up with the Object versions
115 | // of primitive types (Float vs. float). But most likely, the setter/getter functions
116 | // will take primitive types instead.
117 | // So we supply an ordered array of other types to try before giving up.
118 | private static Class[] FLOAT_VARIANTS = {float.class, Float.class, double.class, int.class,
119 | Double.class, Integer.class};
120 | private static Class[] INTEGER_VARIANTS = {int.class, Integer.class, float.class, double.class,
121 | Float.class, Double.class};
122 | private static Class[] DOUBLE_VARIANTS = {double.class, Double.class, float.class, int.class,
123 | Float.class, Integer.class};
124 | protected void setPropertyValue(View view, String propertyName, Object value){
125 | Class c = view.getClass();
126 | Class valueType = value.getClass();
127 | while(c!=Object.class){
128 | String methodName = getMethodName("set", propertyName);
129 | Class[] typeVariants;
130 | if (valueType.equals(Float.class)) {
131 | typeVariants = FLOAT_VARIANTS;
132 | } else if (valueType.equals(Integer.class)) {
133 | typeVariants = INTEGER_VARIANTS;
134 | } else if (valueType.equals(Double.class)) {
135 | typeVariants = DOUBLE_VARIANTS;
136 | } else {
137 | typeVariants = new Class[1];
138 | typeVariants[0] = valueType;
139 | }
140 | for (Class typeVariant : typeVariants) {
141 | try {
142 | Method m = c.getMethod(methodName, typeVariant);
143 | m.setAccessible(true);
144 | m.invoke(view, value);
145 | return;
146 | } catch (Exception e) {
147 | // Swallow the error and keep trying other variants
148 | }
149 | }
150 | c = c.getSuperclass();
151 | }
152 | }
153 |
154 | /**
155 | * Utility method to derive a setter/getter method name from a property name, where the
156 | * prefix is typically "set" or "get" and the first letter of the property name is
157 | * capitalized.
158 | *
159 | * @param prefix The precursor to the method name, before the property name begins, typically
160 | * "set" or "get".
161 | * @param propertyName The name of the property that represents the bulk of the method name
162 | * after the prefix. The first letter of this word will be capitalized in the resulting
163 | * method name.
164 | * @return String the property name converted to a method name according to the conventions
165 | * specified above.
166 | */
167 | static String getMethodName(String prefix, String propertyName) {
168 | if (propertyName == null || propertyName.length() == 0) {
169 | // shouldn't get here
170 | return prefix;
171 | }
172 | char firstLetter = Character.toUpperCase(propertyName.charAt(0));
173 | String theRest = propertyName.substring(1);
174 | return prefix + firstLetter + theRest;
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/demo/demo.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/xiaoma_intro_scene3_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
29 |
30 |
39 |
40 |
46 |
47 |
48 |
49 |
57 |
58 |
67 |
68 |
74 |
75 |
76 |
77 |
85 |
86 |
95 |
96 |
102 |
103 |
104 |
105 |
106 |
114 |
115 |
121 |
122 |
130 |
131 |
132 |
133 |
140 |
141 |
147 |
148 |
156 |
157 |
158 |
159 |
167 |
168 |
174 |
175 |
183 |
184 |
185 |
186 |
193 |
194 |
201 |
202 |
209 |
210 |
217 |
218 |
219 |
220 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/linfaxin/transitionplayer/demo/XiaoMaIntroDemo.java:
--------------------------------------------------------------------------------
1 | package com.linfaxin.transitionplayer.demo;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.v4.view.PagerAdapter;
6 | import android.support.v4.view.ViewPager;
7 | import android.transitions.everywhere.Fade;
8 | import android.transitions.everywhere.Scene;
9 | import android.transitions.everywhere.TransitionManager;
10 | import android.transitions.everywhere.TransitionSet;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.animation.AlphaAnimation;
14 | import android.view.animation.Interpolator;
15 | import android.widget.ImageView;
16 | import android.widget.Scroller;
17 |
18 | import com.linfaxin.transitionplayer.TransitionPlayer;
19 |
20 | import java.lang.reflect.Field;
21 | import java.util.ArrayList;
22 | import java.util.List;
23 |
24 | /**
25 | * Created by linfaxin on 2015/8/14.
26 | * Email: linlinfaxin@163.com
27 | */
28 | public class XiaoMaIntroDemo extends Activity implements ViewPager.OnPageChangeListener {
29 |
30 | private ViewPager extraPager;
31 |
32 | private Scene pageScene1_2;
33 | private Scene pageScene2_3;
34 | private Scene pageScene3_4;
35 |
36 | TransitionPlayer customTransition1_2 = new TransitionPlayer();
37 | TransitionPlayer customTransition2_3 = new TransitionPlayer();
38 | TransitionPlayer customTransition3_4 = new TransitionPlayer();
39 |
40 | private Scene textScene1;
41 | private Scene textScene2;
42 | private Scene textScene3;
43 | private Scene textScene4;
44 | private ViewGroup mTextSceneRoot;
45 |
46 | private View mStartBtn;
47 | private View mPathBtn;
48 | private AlphaAnimation mShowAnimation;
49 | private AlphaAnimation mHideAnimation;
50 | private AlphaAnimation mTextHideAnimation;
51 |
52 | private int[] resIdArray3 = new int[] {
53 | R.id.low_price_item, R.id.real_source_item,
54 | R.id.keep_privacy_item, R.id.has_deposit_item,
55 | R.id.is_profession_item, R.id.best_server_item
56 | };
57 |
58 | private int[] resIdArray4 = new int[] {
59 | R.id.fast_ask_item, R.id.fase_price_item,
60 | R.id.fast_sign_item, R.id.fast_take_item
61 | };
62 |
63 | @Override
64 | protected void onCreate(Bundle savedInstanceState) {
65 | super.onCreate(savedInstanceState);
66 | setContentView(R.layout.demo_xiaoma_intro);
67 |
68 | extraPager = (ViewPager) findViewById(R.id.extra_pager);
69 | initSmoothScrollToViewPager(extraPager);
70 |
71 | mStartBtn = findViewById(R.id.start);
72 | View.OnClickListener finishClick = new View.OnClickListener() {
73 | @Override
74 | public void onClick(View v) {
75 | finish();
76 | }
77 | };
78 | mStartBtn.setOnClickListener(finishClick);
79 | mStartBtn.setVisibility(View.INVISIBLE);
80 | mPathBtn = findViewById(R.id.through);
81 | mPathBtn.setOnClickListener(finishClick);
82 |
83 | mShowAnimation = new AlphaAnimation(0.0f, 1.0f);
84 | mHideAnimation = new AlphaAnimation(1.0f, 0.0f);
85 | mTextHideAnimation = new AlphaAnimation(1.0f, 0.0f);
86 | mShowAnimation.setDuration(400);
87 | mHideAnimation.setDuration(400);
88 | mTextHideAnimation.setDuration(400);
89 | mShowAnimation.setFillAfter(true);
90 | mHideAnimation.setFillAfter(true);
91 | mTextHideAnimation.setFillAfter(true);
92 |
93 | final List viewArray = new ArrayList();
94 | View view1 = View.inflate(this, R.layout.xiaoma_intro_page_base, null);
95 | ((ImageView) view1.findViewById(R.id.title)).setImageResource(R.drawable.xiaoma_intro_top_text1);
96 | view1.findViewById(R.id.description).setVisibility(View.VISIBLE);
97 | viewArray.add(view1);
98 |
99 | View view2 = View.inflate(this, R.layout.xiaoma_intro_page_base, null);
100 | ((ImageView) view2.findViewById(R.id.title)).setImageResource(R.drawable.xiaoma_intro_top_text2);
101 | view2.findViewById(R.id.description).setVisibility(View.GONE);
102 | viewArray.add(view2);
103 |
104 | View view3 = View.inflate(this, R.layout.xiaoma_intro_page_base, null);
105 | ((ImageView) view3.findViewById(R.id.title)).setImageResource(R.drawable.xiaoma_intro_top_text3);
106 | view3.findViewById(R.id.description).setVisibility(View.GONE);
107 | viewArray.add(view3);
108 |
109 | View view4 = View.inflate(this, R.layout.xiaoma_intro_page_base, null);
110 | ((ImageView) view4.findViewById(R.id.title)).setImageResource(R.drawable.xiaoma_intro_top_text4);
111 | view4.findViewById(R.id.description).setVisibility(View.GONE);
112 | viewArray.add(view4);
113 |
114 | pageScene1_2 = Scene.getSceneForLayout((ViewGroup)findViewById(R.id.root_view_1_to_2), R.layout.xiaoma_intro_scene2, this);
115 | pageScene2_3 = Scene.getSceneForLayout((ViewGroup)findViewById(R.id.root_view_2_to_3), R.layout.xiaoma_intro_scene3, this);
116 | pageScene3_4 = Scene.getSceneForLayout((ViewGroup)findViewById(R.id.root_view_3_to_4), R.layout.xiaoma_intro_scene4, this);
117 | extraPager.postDelayed(new Runnable() {
118 | @Override
119 | public void run() {
120 | TransitionManager.go(pageScene1_2, customTransition1_2);
121 | TransitionManager.go(pageScene2_3, customTransition2_3);
122 | TransitionManager.go(pageScene3_4, customTransition3_4);
123 | }
124 | }, 50);
125 |
126 | mTextSceneRoot = (ViewGroup) findViewById(R.id.text_root_view);
127 | textScene1 = Scene.getSceneForLayout(mTextSceneRoot, R.layout.xiaoma_intro_scene1_text, this);
128 | textScene2 = Scene.getSceneForLayout(mTextSceneRoot, R.layout.xiaoma_intro_scene2_text, this);
129 | textScene3 = Scene.getSceneForLayout(mTextSceneRoot, R.layout.xiaoma_intro_scene3_text, this);
130 | textScene4 = Scene.getSceneForLayout(mTextSceneRoot, R.layout.xiaoma_intro_scene4_text, this);
131 |
132 | extraPager.setAdapter(new PagerAdapter() {
133 | @Override
134 | public int getCount() {
135 | return 4;
136 | }
137 |
138 | @Override
139 | public boolean isViewFromObject(View view, Object o) {
140 | return view == o;
141 | }
142 |
143 | @Override
144 | public void destroyItem(ViewGroup container, int position, Object object) {
145 | container.removeView((View) object);
146 | }
147 |
148 | @Override
149 | public Object instantiateItem(ViewGroup container, int position) {
150 | container.addView(viewArray.get(position));
151 | return viewArray.get(position);
152 | }
153 | });
154 | extraPager.addOnPageChangeListener(this);
155 | }
156 |
157 | @Override
158 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
159 | if(positionOffset==0 && position>0){//避免一页结束时,细微的闪移
160 | return;
161 | }
162 | switch (position){
163 | case -1:
164 | case 0:
165 | pageScene1_2.getSceneRoot().setVisibility(View.VISIBLE);
166 | pageScene2_3.getSceneRoot().setVisibility(View.INVISIBLE);
167 | pageScene3_4.getSceneRoot().setVisibility(View.INVISIBLE);
168 | customTransition1_2.setCurrentFraction(positionOffset);
169 | break;
170 | case 1:
171 | pageScene2_3.getSceneRoot().setVisibility(View.VISIBLE);
172 | pageScene1_2.getSceneRoot().setVisibility(View.INVISIBLE);
173 | pageScene3_4.getSceneRoot().setVisibility(View.INVISIBLE);
174 | customTransition2_3.setCurrentFraction(positionOffset);
175 | break;
176 | case 2:
177 | pageScene3_4.getSceneRoot().setVisibility(View.VISIBLE);
178 | pageScene1_2.getSceneRoot().setVisibility(View.INVISIBLE);
179 | pageScene2_3.getSceneRoot().setVisibility(View.INVISIBLE);
180 | customTransition3_4.setCurrentFraction(positionOffset);
181 | break;
182 | case 3:
183 | pageScene3_4.getSceneRoot().setVisibility(View.VISIBLE);
184 | pageScene1_2.getSceneRoot().setVisibility(View.INVISIBLE);
185 | pageScene2_3.getSceneRoot().setVisibility(View.INVISIBLE);
186 | customTransition3_4.setCurrentFraction(1);
187 | break;
188 | }
189 | }
190 |
191 | private int lastPosition = 0;
192 | @Override
193 | public void onPageSelected(int position) {
194 | switch (position) {
195 | case 0:
196 | TransitionManager.go(textScene1);
197 | break;
198 | case 1:
199 | TransitionManager.go(textScene2);
200 | break;
201 | case 2:
202 | if (lastPosition != 3) {
203 | TransitionSet set = new TransitionSet();
204 | for (int i = 0; i < resIdArray3.length ;i++) {
205 | Fade fade = new Fade(Fade.MODE_IN);
206 | fade.addTarget(resIdArray3[i]);
207 | set.addTransition(fade);
208 | }
209 | set.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
210 | set.setDuration(400);
211 | set.setStartDelay(400);
212 | TransitionManager.go(textScene3, set);
213 | } else {
214 | mStartBtn.startAnimation(mHideAnimation);
215 | mShowAnimation.setDuration(400);
216 | mPathBtn.startAnimation(mShowAnimation);
217 | TransitionManager.go(textScene3);
218 | mStartBtn.setClickable(false);
219 | }
220 | break;
221 | case 3:
222 | TransitionSet set4 = new TransitionSet();
223 | for (int i = 0; i < resIdArray4.length ;i++) {
224 | Fade fade = new Fade(Fade.MODE_IN);
225 | fade.addTarget(resIdArray4[i]);
226 | set4.addTransition(fade);
227 | }
228 | set4.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
229 | set4.setDuration(400);
230 | set4.setStartDelay(400);
231 | TransitionManager.go(textScene4, set4);
232 | mPathBtn.startAnimation(mHideAnimation);
233 | mShowAnimation.setDuration(1000);
234 | mStartBtn.startAnimation(mShowAnimation);
235 | mStartBtn.setClickable(true);
236 | break;
237 | default:
238 | break;
239 | }
240 | lastPosition = position;
241 | }
242 |
243 | @Override
244 | public void onPageScrollStateChanged(int state) {
245 | if(state==ViewPager.SCROLL_STATE_DRAGGING){
246 | mTextSceneRoot.startAnimation(mTextHideAnimation);
247 | }else{
248 | mTextSceneRoot.clearAnimation();
249 | }
250 | }
251 |
252 | private void initSmoothScrollToViewPager(ViewPager viewPager){
253 | try {
254 | Interpolator sInterpolator = new Interpolator() {
255 | public float getInterpolation(float t) {
256 | t -= 1.0f;
257 | return t * t * t * t * t + 1.0f;
258 | }
259 | };
260 | Field field = ViewPager.class.getDeclaredField("mScroller");
261 | field.setAccessible(true);
262 | field.set(viewPager, new Scroller(this, sInterpolator){
263 | @Override
264 | public void startScroll(int startX, int startY, int dx, int dy, int duration) {
265 | super.startScroll(startX, startY, dx, dy, duration * 2);
266 | }
267 | });
268 | } catch (Exception e) {
269 | e.printStackTrace();
270 | }
271 | }
272 | }
--------------------------------------------------------------------------------