├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── CONTRIBUTING.md
├── README.md
├── build.gradle
├── circle.yml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pre-lollipop-activity-transition
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── kogitune
│ │ └── pre_lollipop_activity_transition
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── kogitune
│ └── activity_transition
│ ├── ActivityTransition.java
│ ├── ActivityTransitionLauncher.java
│ ├── BuildConfigUtils.java
│ ├── ExitActivityTransition.java
│ ├── core
│ ├── MoveData.java
│ ├── TransitionAnimation.java
│ ├── TransitionBundleFactory.java
│ └── TransitionData.java
│ └── fragment
│ ├── ExitFragmentTransition.java
│ ├── FragmentTransition.java
│ └── FragmentTransitionLauncher.java
├── sample-app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── kogitune
│ │ └── prelollipoptransition
│ │ ├── ApplicationTest.java
│ │ ├── ListViewActivityTest.java
│ │ └── MainActivityTest.java
│ ├── debug
│ └── AndroidManifest.xml
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── kogitune
│ │ └── prelollipoptransition
│ │ ├── ListViewActivity.java
│ │ ├── MainActivity.java
│ │ ├── SubActivity.java
│ │ ├── SubActivity2.java
│ │ ├── fragment
│ │ ├── EndFragment.java
│ │ ├── ListViewFragment.java
│ │ ├── StartFragment.java
│ │ └── SubFragment.java
│ │ └── support_fragment
│ │ ├── SupportEndFragment.java
│ │ └── SupportStartFragment.java
│ └── res
│ ├── drawable
│ └── photo.jpg
│ ├── layout
│ ├── activity_list_view.xml
│ ├── activity_main.xml
│ ├── activity_sub.xml
│ ├── activity_sub2.xml
│ ├── fragment_end.xml
│ ├── fragment_list_view.xml
│ ├── fragment_start.xml
│ ├── fragment_sub.xml
│ ├── list_row.xml
│ ├── support_fragment_end.xml
│ └── support_fragment_start.xml
│ ├── menu
│ ├── menu_list_view.xml
│ ├── menu_main.xml
│ └── menu_sub.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea
4 | .DS_Store
5 | /build
6 | *.apk
7 | *.iml
8 | manifest-merger-release-report.txt
9 | keys.gradle
10 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | PreLollipopTransition
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/.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 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contribution
2 | 1. Fork it ( http://github.com/takahirom/PreLollipopTransition/fork )
3 | 2. Create your feature branch (git checkout -b my-new-feature)
4 | 3. Commit your changes (git commit -am 'Add some feature')
5 | 4. Push to the branch (git push origin my-new-feature)
6 | 5. Create new Pull Request
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PreLollipopTransition
2 |
3 |  [](https://android-arsenal.com/api?level=14)
4 |
5 | Simple tool which help you to implement activity and fragment transition for pre-Lollipop devices.
6 |
7 | 
8 |
9 | ## Download
10 | In your app build.gradle add
11 |
12 | ```groovy
13 | dependencies {
14 | compile 'com.kogitune:pre-lollipop-activity-transition:1.x.x'
15 | }
16 | ```
17 |
18 | [  ](https://bintray.com/takahirom/maven/PreLollipopTransition/_latestVersion)
19 |
20 | ## Code
21 | ### Activity
22 | Start Activity in first activity.
23 |
24 | ```java
25 | findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() {
26 | @Override
27 | public void onClick(View v) {
28 | final Intent intent = new Intent(MainActivity.this, SubActivity.class);
29 | ActivityTransitionLauncher.with(MainActivity.this).from(v).launch(intent);
30 | }
31 | });
32 | ```
33 |
34 | Receive intent in second activity.
35 |
36 | ```java
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_sub);
41 | ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState);
42 | }
43 | ```
44 |
45 | #### If you want the exit animation, you can do like this.
46 |
47 | ```java
48 | private ExitActivityTransition exitTransition;
49 | @Override
50 | protected void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 | setContentView(R.layout.activity_sub2);
53 | exitTransition = ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState);
54 | }
55 | @Override
56 | public void onBackPressed() {
57 | exitTransition.exit(this);
58 | }
59 | ```
60 |
61 | #### If you want to use `startActivityForResult`, you should do below.
62 | 1. Use `createBundle()`.
63 | 2. Put Extra to intent.
64 | 3. Call overridePendingTransition after `startActivityForResult`.
65 |
66 | ```java
67 | Bundle transitionBundle = ActivityTransitionLauncher.with(MainActivity.this).from(v).createBundle();
68 | intent.putExtras(transitionBundle);
69 | startActivityForResult(intent, REQUEST_CODE);
70 | // you should prevent default activity transition animation
71 | overridePendingTransition(0, 0);
72 | ```
73 |
74 | ### Fragment
75 | Start fragment transition in first fragment.
76 |
77 | ```java
78 | @Override
79 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
80 | View v = inflater.inflate(R.layout.support_fragment_start, container, false);
81 | v.setOnClickListener(new View.OnClickListener() {
82 | @Override
83 | public void onClick(View view) {
84 | final EndFragment toFragment = new EndFragment();
85 | FragmentTransitionLauncher
86 | .with(view.getContext())
87 | .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))
88 | .from(view.findViewById(R.id.imageView)).prepare(toFragment);
89 | getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit();
90 | }
91 | });
92 | return v;
93 | }
94 | ```
95 |
96 | Start animation in second fragment.
97 | ```java
98 | @Override
99 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
100 | View v = inflater.inflate(R.layout.support_fragment_end, container, false);
101 | final ExitFragmentTransition exitFragmentTransition = FragmentTransition.with(this).to(v.findViewById(R.id.fragment_imageView)).start(savedInstanceState);
102 | exitFragmentTransition.startExitListening();
103 | return v;
104 | }
105 | ```
106 |
107 | If you want to pass argument to second fragment, you should use `Fragment#getArguments()` after call prepare().
108 |
109 | ```java
110 | final EndFragment toFragment = new EndFragment();
111 | FragmentTransitionLauncher
112 | .with(view.getContext())
113 | .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))
114 | .from(view.findViewById(R.id.imageView)).prepare(toFragment);
115 | toFragment.getArguments().putString("stringArgKey", "this is value");
116 | getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit();
117 | ```
118 |
119 | ## Sample
120 | 
121 |
122 | ## Contributors
123 | * [shiraji](http://www.github.com/shiraji)
124 | * [lovejjfg](https://github.com/lovejjfg)
125 |
126 | ## Thanks
127 | Sample Photo
128 | Luke Ma
129 | https://www.flickr.com/photos/lukema/12499338274/in/photostream/
130 |
131 | DevBytes: Custom Activity Animations
132 | https://www.youtube.com/watch?v=CPxkoe2MraA
133 |
134 | ## License
135 |
136 | This project is released under the Apache License, Version 2.0.
137 |
138 | * [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
139 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | buildscript {
19 | repositories {
20 | jcenter()
21 | }
22 | dependencies {
23 | classpath 'com.android.tools.build:gradle:2.3.0'
24 | }
25 | }
26 |
27 | allprojects {
28 | repositories {
29 | jcenter()
30 | }
31 |
32 | rootProject.ext {
33 | BuildTools = "25.0.2"
34 | MinSdk = 14
35 | TargetSdk = 22
36 | CompileSdk = 25
37 | SupportLibrary = "25.3.1"
38 | }
39 | }
40 | // Improve CI build performance
41 | // http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.
42 |
43 | project.ext.preDexLibs = !project.hasProperty('disablePreDex')
44 |
45 | subprojects {
46 | project.plugins.whenPluginAdded { plugin ->
47 | if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
48 | project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
49 | } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
50 | project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | general:
2 | artifacts:
3 | - 'sample-app/build/spoon'
4 | machine:
5 | java:
6 | version: openjdk8
7 | dependencies:
8 | pre:
9 | - mkdir $ANDROID_HOME/licenses; ls -l $ANDROID_HOME/licenses
10 | - echo -e "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
11 | - echo -e "504667f4c0de7af1a06de9f4b1727b84351f2910" > "${ANDROID_HOME}/licenses/android-sdk-preview-license"
12 | - echo y | android update sdk --no-ui --all --filter "android-25"
13 | - echo y | android update sdk --no-ui --all --filter "android-22"
14 | - echo y | android update sdk --no-ui --all --filter "build-tools-25.0.2"
15 | - echo y | android update sdk --no-ui --all --filter "extra-google-m2repository"
16 | - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"
17 | - echo y | android update sdk --no-ui --all --filter "extra-android-support"
18 | test:
19 | override:
20 | # create sdcard image file
21 | - mksdcard -l e 512M mysdcard.img
22 | # start the emulator
23 | - emulator -avd circleci-android22 -no-audio -no-window -sdcard mysdcard.img:
24 | background: true
25 | parallel: true
26 | # wait for it to have booted
27 | - ./gradlew assembleDebugAndroidTest -PdisablePreDex
28 | - circle-android wait-for-boot
29 | # wait a little longer, just in case :)
30 | - sleep 30
31 | # confirm devices
32 | - adb devices
33 | # uninstall app
34 | # - adb uninstall com.kogitune.prelollipoptransition
35 | # run tests against the emulator using spoon.
36 | - ./gradlew spoonDebugAndroidTest --stop -PdisablePreDex
37 | - ./gradlew spoonDebugAndroidTest -PdisablePreDex
38 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2015 takahirom
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | #
17 |
18 | # Project-wide Gradle settings.
19 |
20 | # IDE (e.g. Android Studio) users:
21 | # Gradle settings configured through the IDE *will override*
22 | # any settings specified in this file.
23 |
24 | # For more details on how to configure your build environment visit
25 | # http://www.gradle.org/docs/current/userguide/build_environment.html
26 |
27 | # Specifies the JVM arguments used for the daemon process.
28 | # The setting is particularly useful for tweaking memory settings.
29 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
30 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
31 |
32 | # When configured, Gradle will run in incubating parallel mode.
33 | # This option should only be used with decoupled projects. More details, visit
34 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
35 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/takahirom/PreLollipopTransition/90c6e12b5dd40a52dd57cb6560cfefe1804ba36d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2015 takahirom
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | #
17 |
18 | #Thu Apr 06 06:36:52 ICT 2017
19 | distributionBase=GRADLE_USER_HOME
20 | distributionPath=wrapper/dists
21 | zipStoreBase=GRADLE_USER_HOME
22 | zipStorePath=wrapper/dists
23 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
24 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | key
3 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | buildscript {
19 | repositories {
20 | jcenter()
21 | }
22 | dependencies {
23 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
24 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
25 | }
26 | }
27 | apply plugin: 'com.android.library'
28 | apply plugin: 'com.github.dcendents.android-maven'
29 | apply plugin: 'com.jfrog.bintray'
30 |
31 | android {
32 | compileSdkVersion rootProject.ext.CompileSdk
33 | buildToolsVersion rootProject.ext.BuildTools
34 |
35 | defaultConfig {
36 | minSdkVersion rootProject.ext.MinSdk
37 | targetSdkVersion rootProject.ext.TargetSdk
38 | versionCode 1
39 | versionName "1.0"
40 | }
41 | buildTypes {
42 | release {
43 | minifyEnabled false
44 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
45 | }
46 | }
47 | }
48 |
49 | dependencies {
50 | compile fileTree(dir: 'libs', include: ['*.jar'])
51 | }
52 |
53 | group = 'com.kogitune'
54 | version = '1.3.3'
55 |
56 |
57 | def siteUrl = 'https://github.com/takahirom/PreLollipopTransition'
58 | def gitUrl = 'https://github.com/takahirom/PreLollipopTransition.git'
59 | bintray {
60 | user = "takahirom"
61 | if (file("key").exists()) {
62 | key = file("key").text
63 | }
64 |
65 | configurations = ['archives'] //When uploading configuration files
66 | publish = true
67 | pkg {
68 | repo = 'maven'
69 | name = 'PreLollipopTransition'
70 | desc = 'Simple tool which help you to implement activity transition for pre-Lollipop devices'
71 | websiteUrl = siteUrl
72 | issueTrackerUrl = 'https://github.com/takahirom/PreLollipopTransition/issues'
73 | vcsUrl = gitUrl
74 | licenses = ['Apache-2.0']
75 | labels = ['aar', 'android', 'animation']
76 | publicDownloadNumbers = true
77 | }
78 | }
79 | dependencies {
80 | compile fileTree(dir: 'libs', include: ['*.jar'])
81 | provided "com.android.support:support-v4:$rootProject.ext.SupportLibrary"
82 | }
83 |
84 | task sourcesJar(type: Jar) {
85 | from android.sourceSets.main.java.srcDirs
86 | classifier = 'sources'
87 | }
88 |
89 | task javadoc(type: Javadoc) {
90 | source = android.sourceSets.main.java.srcDirs
91 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
92 | }
93 |
94 | task javadocJar(type: Jar, dependsOn: javadoc) {
95 | classifier = 'javadoc'
96 | from javadoc.destinationDir
97 | }
98 | artifacts {
99 | archives javadocJar
100 | archives sourcesJar
101 | }
102 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/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 /Applications/android-sdk-macosx-l/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 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/androidTest/java/com/kogitune/pre_lollipop_activity_transition/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.pre_lollipop_activity_transition;
19 |
20 | import android.app.Application;
21 | import android.test.ApplicationTestCase;
22 |
23 | /**
24 | * Testing Fundamentals
25 | */
26 | public class ApplicationTest extends ApplicationTestCase {
27 | public ApplicationTest() {
28 | super(Application.class);
29 | }
30 | }
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/ActivityTransition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition;
19 |
20 | import android.animation.Animator;
21 | import android.animation.TimeInterpolator;
22 | import android.content.Intent;
23 | import android.os.Bundle;
24 | import android.view.View;
25 | import android.view.animation.DecelerateInterpolator;
26 |
27 | import com.kogitune.activity_transition.core.MoveData;
28 | import com.kogitune.activity_transition.core.TransitionAnimation;
29 |
30 | public class ActivityTransition {
31 | private int duration = 1000;
32 | private View toView;
33 | private TimeInterpolator interpolator;
34 | private Animator.AnimatorListener listener;
35 | private final Intent fromIntent;
36 |
37 | private ActivityTransition(Intent intent) {
38 | this.fromIntent = intent;
39 | }
40 |
41 | public static ActivityTransition with(Intent intent) {
42 | return new ActivityTransition(intent);
43 | }
44 |
45 | public ActivityTransition to(View toView) {
46 | this.toView = toView;
47 | return this;
48 | }
49 |
50 | public ActivityTransition duration(int duration) {
51 | this.duration = duration;
52 | return this;
53 | }
54 |
55 | public ActivityTransition interpolator(TimeInterpolator interpolator) {
56 | this.interpolator = interpolator;
57 | return this;
58 | }
59 | public ActivityTransition enterListener(Animator.AnimatorListener listener) {
60 | this.listener = listener;
61 | return this;
62 | }
63 |
64 | public ExitActivityTransition start(Bundle savedInstanceState) {
65 | if (interpolator == null) {
66 | interpolator = new DecelerateInterpolator();
67 | }
68 |
69 | final Bundle bundle = fromIntent.getExtras();
70 | final MoveData moveData = TransitionAnimation.startAnimation(toView, bundle, savedInstanceState, duration, interpolator, listener);
71 | return new ExitActivityTransition(moveData);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/ActivityTransitionLauncher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition;
19 |
20 | import android.app.Activity;
21 | import android.content.Intent;
22 | import android.graphics.Bitmap;
23 | import android.os.Bundle;
24 | import android.view.View;
25 |
26 | import com.kogitune.activity_transition.core.TransitionBundleFactory;
27 |
28 | public class ActivityTransitionLauncher {
29 | private static final String TAG = "TransitionLauncher";
30 |
31 | private final Activity activity;
32 | private View fromView;
33 | private Bitmap bitmap;
34 |
35 |
36 | private ActivityTransitionLauncher(Activity activity) {
37 | this.activity = activity;
38 | }
39 |
40 | public static ActivityTransitionLauncher with(Activity activity) {
41 | return new ActivityTransitionLauncher(activity);
42 | }
43 |
44 | public ActivityTransitionLauncher from(View fromView) {
45 | this.fromView = fromView;
46 | return this;
47 | }
48 |
49 | public ActivityTransitionLauncher image(final Bitmap bitmap) {
50 | this.bitmap = bitmap;
51 | return this;
52 | }
53 |
54 | public Bundle createBundle() {
55 | return TransitionBundleFactory.createTransitionBundle(activity, fromView, bitmap);
56 | }
57 |
58 | public void launch(Intent intent) {
59 | intent.putExtras(createBundle());
60 | activity.startActivity(intent);
61 | activity.overridePendingTransition(0, 0);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/BuildConfigUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition;
19 |
20 | import android.content.Context;
21 |
22 | import java.lang.reflect.Field;
23 |
24 | public class BuildConfigUtils {
25 | public static Object getBuildConfigValue(Context context, String fieldName) {
26 | try {
27 | Class> clazz = Class.forName(context.getPackageName() + ".BuildConfig");
28 | Field field = clazz.getField(fieldName);
29 | return field.get(null);
30 | } catch (ClassNotFoundException e) {
31 | e.printStackTrace();
32 | } catch (NoSuchFieldException e) {
33 | e.printStackTrace();
34 | } catch (IllegalAccessException e) {
35 | e.printStackTrace();
36 | }
37 | return null;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/ExitActivityTransition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition;
19 |
20 | import android.animation.Animator;
21 | import android.animation.TimeInterpolator;
22 | import android.app.Activity;
23 | import android.view.animation.DecelerateInterpolator;
24 |
25 | import com.kogitune.activity_transition.core.MoveData;
26 | import com.kogitune.activity_transition.core.TransitionAnimation;
27 |
28 | public class ExitActivityTransition {
29 | private final MoveData moveData;
30 | private TimeInterpolator interpolator;
31 | private Animator.AnimatorListener listener;
32 |
33 |
34 | public ExitActivityTransition(MoveData moveData) {
35 | this.moveData = moveData;
36 | }
37 |
38 | public ExitActivityTransition interpolator(TimeInterpolator interpolator) {
39 | this.interpolator = interpolator;
40 | return this;
41 | }
42 | public ExitActivityTransition exitListener(Animator.AnimatorListener listener) {
43 | this.listener = listener;
44 | return this;
45 | }
46 |
47 | public void exit(final Activity activity) {
48 | if (interpolator == null) {
49 | interpolator = new DecelerateInterpolator();
50 | }
51 | TransitionAnimation.startExitAnimation(moveData, interpolator, new Runnable() {
52 | @Override
53 | public void run() {
54 | activity.finish();
55 | activity.overridePendingTransition(0, 0);
56 | }
57 | },listener);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/core/MoveData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition.core;
19 |
20 | import android.view.View;
21 |
22 | public class MoveData {
23 | public int leftDelta;
24 | public int topDelta;
25 | public float widthScale;
26 | public float heightScale;
27 | public int duration = 1000;
28 | public View toView;
29 | }
30 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/core/TransitionAnimation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom, shiraji
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition.core;
19 |
20 | import android.animation.Animator;
21 | import android.animation.TimeInterpolator;
22 | import android.content.Context;
23 | import android.graphics.Bitmap;
24 | import android.graphics.BitmapFactory;
25 | import android.graphics.drawable.BitmapDrawable;
26 | import android.os.Bundle;
27 | import android.support.v4.view.ViewCompat;
28 | import android.view.ContextThemeWrapper;
29 | import android.view.View;
30 | import android.view.ViewTreeObserver;
31 | import android.widget.ImageView;
32 |
33 | import java.lang.ref.WeakReference;
34 |
35 | public class TransitionAnimation {
36 | public static final Object lock = new Object();
37 | private static final String TAG = "Transition";
38 | private static final int MAX_TIME_TO_WAIT = 3000;
39 | public static WeakReference bitmapCache;
40 | public static boolean isImageFileReady = false;
41 |
42 | public static MoveData startAnimation(final View toView, Bundle transitionBundle, Bundle savedInstanceState, final int duration, final TimeInterpolator interpolator, final Animator.AnimatorListener listener) {
43 | Context context = toView.getContext();
44 | if (context instanceof ContextThemeWrapper) {
45 | context = ((ContextThemeWrapper) context).getBaseContext();
46 | }
47 |
48 | final TransitionData transitionData = new TransitionData(context, transitionBundle);
49 | if (transitionData.imageFilePath != null) {
50 | setImageToView(toView, transitionData.imageFilePath);
51 | }
52 |
53 | final MoveData moveData = new MoveData();
54 | moveData.toView = toView;
55 | moveData.duration = duration;
56 | if (savedInstanceState == null) {
57 |
58 | ViewTreeObserver observer = toView.getViewTreeObserver();
59 | observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
60 |
61 | @Override
62 | public boolean onPreDraw() {
63 | toView.getViewTreeObserver().removeOnPreDrawListener(this);
64 |
65 | int[] screenLocation = new int[2];
66 | toView.getLocationOnScreen(screenLocation);
67 | moveData.leftDelta = transitionData.thumbnailLeft - screenLocation[0];
68 | moveData.topDelta = transitionData.thumbnailTop - screenLocation[1];
69 |
70 | moveData.widthScale = (float) transitionData.thumbnailWidth / toView.getWidth();
71 | moveData.heightScale = (float) transitionData.thumbnailHeight / toView.getHeight();
72 | runEnterAnimation(moveData, interpolator, listener);
73 | return true;
74 | }
75 | });
76 | }
77 | return moveData;
78 | }
79 |
80 |
81 | private static void runEnterAnimation(MoveData moveData, TimeInterpolator interpolator, Animator.AnimatorListener listener) {
82 | final View toView = moveData.toView;
83 | toView.setPivotX(0);
84 | toView.setPivotY(0);
85 | toView.setScaleX(moveData.widthScale);
86 | toView.setScaleY(moveData.heightScale);
87 | toView.setTranslationX(moveData.leftDelta);
88 | toView.setTranslationY(moveData.topDelta);
89 |
90 | toView.animate()
91 | .setDuration(moveData.duration)
92 | .scaleX(1)
93 | .scaleY(1)
94 | .translationX(0)
95 | .translationY(0)
96 | .setListener(listener)
97 | .setInterpolator(interpolator);
98 | }
99 |
100 | private static void setImageToView(View toView, String imageFilePath) {
101 | Bitmap bitmap;
102 | if (bitmapCache == null || (bitmap = bitmapCache.get()) == null) {
103 | synchronized (lock) {
104 | while (!isImageFileReady) {
105 | try {
106 | lock.wait(MAX_TIME_TO_WAIT);
107 | } catch (InterruptedException e) {
108 | }
109 | }
110 | }
111 | // Cant get bitmap by static field
112 | bitmap = BitmapFactory.decodeFile(imageFilePath);
113 | } else {
114 | bitmapCache.clear();
115 | }
116 | setImageToView(toView, bitmap);
117 | }
118 |
119 | private static void setImageToView(View toView, Bitmap bitmap) {
120 | if (toView instanceof ImageView) {
121 | final ImageView toImageView = (ImageView) toView;
122 | toImageView.setImageBitmap(bitmap);
123 | } else {
124 | ViewCompat.setBackground(toView, new BitmapDrawable(toView.getResources(), bitmap));
125 | }
126 | }
127 |
128 | public static void startExitAnimation(MoveData moveData, TimeInterpolator interpolator, final Runnable endAction, Animator.AnimatorListener listener) {
129 | View view = moveData.toView;
130 | int duration = moveData.duration;
131 | int leftDelta = moveData.leftDelta;
132 | int topDelta = moveData.topDelta;
133 | float widthScale = moveData.widthScale;
134 | float heightScale = moveData.heightScale;
135 | view.animate()
136 | .setDuration(duration)
137 | .scaleX(widthScale).scaleY(heightScale)
138 | .setInterpolator(interpolator)
139 | .translationX(leftDelta)
140 | .setListener(listener)
141 | .translationY(topDelta);
142 | view.postDelayed(endAction, duration);
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/core/TransitionBundleFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom, shiraji
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition.core;
19 |
20 | import android.content.Context;
21 | import android.graphics.Bitmap;
22 | import android.os.Bundle;
23 | import android.util.Log;
24 | import android.view.View;
25 |
26 | import com.kogitune.activity_transition.BuildConfigUtils;
27 |
28 | import java.io.BufferedOutputStream;
29 | import java.io.File;
30 | import java.io.FileNotFoundException;
31 | import java.io.FileOutputStream;
32 | import java.io.IOException;
33 | import java.lang.ref.WeakReference;
34 |
35 | public class TransitionBundleFactory {
36 | public static final String TEMP_IMAGE_FILE_NAME = "activity_transition_image.png";
37 | private static final String TAG = "Transition";
38 |
39 | public static Bundle createTransitionBundle(Context context, View fromView, Bitmap bitmap) {
40 | // Bitmap is Optional
41 | String imageFilePath = null;
42 | if (bitmap != null) {
43 | TransitionAnimation.bitmapCache = new WeakReference<>(bitmap);
44 | imageFilePath = saveImage(context, bitmap);
45 | }
46 | int[] screenLocation = new int[2];
47 | fromView.getLocationOnScreen(screenLocation);
48 | final TransitionData transitionData = new TransitionData(context, screenLocation[0], screenLocation[1], fromView.getMeasuredWidth(), fromView.getMeasuredHeight(), imageFilePath);
49 | return transitionData.getBundle();
50 | }
51 |
52 | private static String saveImage(final Context context, final Bitmap bitmap) {
53 | final String imageSavePath = context.getFilesDir().getAbsolutePath() + "/activity_transition/";
54 | new File(imageSavePath).mkdirs();
55 | final File imageFile = new File(imageSavePath, TEMP_IMAGE_FILE_NAME);
56 | final String imageFilePath = imageFile.getAbsolutePath();
57 | new Thread(new Runnable() {
58 | @Override
59 | public void run() {
60 | TransitionAnimation.isImageFileReady = false;
61 | Boolean isDebug = (Boolean) BuildConfigUtils.getBuildConfigValue(context, "DEBUG");
62 | BufferedOutputStream bos = null;
63 | try {
64 | if (imageFile.exists()) {
65 | imageFile.delete();
66 | }
67 | imageFile.createNewFile();
68 | bos = new BufferedOutputStream(new FileOutputStream(imageFile));
69 | bitmap.compress(Bitmap.CompressFormat.JPEG, 50, bos);
70 | } catch (FileNotFoundException e) {
71 | if (isDebug) {
72 | Log.i(TAG, "file not found", e);
73 | }
74 | } catch (IOException e) {
75 | if (isDebug) {
76 | Log.i(TAG, "can't create file", e);
77 | }
78 | } finally {
79 | try {
80 | bos.close();
81 | } catch (Exception e) {
82 | if (isDebug) {
83 | //IOException, NullPointerException
84 | Log.i(TAG, "fail save image", e);
85 | }
86 | }
87 | TransitionAnimation.isImageFileReady = true;
88 | }
89 | synchronized (TransitionAnimation.lock) {
90 | TransitionAnimation.lock.notify();
91 | }
92 | }
93 | }).start();
94 | return imageFilePath;
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/core/TransitionData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition.core;
19 |
20 | import android.content.Context;
21 | import android.os.Bundle;
22 |
23 | import com.kogitune.activity_transition.BuildConfigUtils;
24 |
25 | public class TransitionData {
26 | public static final String EXTRA_IMAGE_LEFT = ".left";
27 | public static final String EXTRA_IMAGE_TOP = ".top";
28 | public static final String EXTRA_IMAGE_WIDTH = ".width";
29 | public static final String EXTRA_IMAGE_HEIGHT = ".height";
30 | public static final String EXTRA_IMAGE_PATH = ".imageFilePath";
31 |
32 | public final int thumbnailTop;
33 | public final int thumbnailLeft;
34 | public final int thumbnailWidth;
35 | public final int thumbnailHeight;
36 | public final String imageFilePath;
37 | private String appId;
38 |
39 | public TransitionData(Context context, int thumbnailLeft, int thumbnailTop, int thumbnailWidth, int thumbnailHeight, String imageFilePath) {
40 | setAppId(context);
41 | this.thumbnailLeft = thumbnailLeft;
42 | this.thumbnailTop = thumbnailTop;
43 | this.thumbnailWidth = thumbnailWidth;
44 | this.thumbnailHeight = thumbnailHeight;
45 | this.imageFilePath = imageFilePath;
46 | }
47 |
48 | public TransitionData(Context context, Bundle bundle) {
49 | setAppId(context);
50 | thumbnailTop = bundle.getInt(appId + EXTRA_IMAGE_TOP);
51 | thumbnailLeft = bundle.getInt(appId + EXTRA_IMAGE_LEFT);
52 | thumbnailWidth = bundle.getInt(appId + EXTRA_IMAGE_WIDTH);
53 | thumbnailHeight = bundle.getInt(appId + EXTRA_IMAGE_HEIGHT);
54 | imageFilePath = bundle.getString(appId + EXTRA_IMAGE_PATH);
55 | }
56 |
57 | private void setAppId(Context context) {
58 | appId = (String) BuildConfigUtils.getBuildConfigValue(context, "APPLICATION_ID");
59 | }
60 |
61 |
62 | public Bundle getBundle() {
63 | final Bundle bundle = new Bundle();
64 | if (imageFilePath != null) {
65 | bundle.putString(appId + EXTRA_IMAGE_PATH, imageFilePath);
66 | }
67 | bundle.putInt(appId + EXTRA_IMAGE_LEFT, thumbnailLeft);
68 | bundle.putInt(appId + EXTRA_IMAGE_TOP, thumbnailTop);
69 | bundle.putInt(appId + EXTRA_IMAGE_WIDTH, thumbnailWidth);
70 | bundle.putInt(appId + EXTRA_IMAGE_HEIGHT, thumbnailHeight);
71 | return bundle;
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/fragment/ExitFragmentTransition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition.fragment;
19 |
20 | import android.animation.Animator;
21 | import android.animation.TimeInterpolator;
22 | import android.app.Fragment;
23 | import android.support.v4.app.FragmentManager;
24 | import android.view.KeyEvent;
25 | import android.view.View;
26 | import android.view.animation.DecelerateInterpolator;
27 |
28 | import com.kogitune.activity_transition.core.MoveData;
29 | import com.kogitune.activity_transition.core.TransitionAnimation;
30 |
31 | public class ExitFragmentTransition {
32 | private final MoveData moveData;
33 | private Fragment fragment;
34 | private android.support.v4.app.Fragment supportFragment;
35 | private TimeInterpolator interpolator;
36 | private Animator.AnimatorListener listener;
37 |
38 |
39 | public ExitFragmentTransition(Fragment fragment, MoveData moveData) {
40 | this.fragment = fragment;
41 | this.moveData = moveData;
42 | }
43 |
44 | public ExitFragmentTransition(final android.support.v4.app.Fragment fragment, MoveData moveData) {
45 | this.supportFragment = fragment;
46 | this.moveData = moveData;
47 | }
48 |
49 | public ExitFragmentTransition interpolator(TimeInterpolator interpolator) {
50 | this.interpolator = interpolator;
51 | return this;
52 | }
53 | public ExitFragmentTransition exitListener(Animator.AnimatorListener listener) {
54 | this.listener = listener;
55 | return this;
56 | }
57 |
58 | public void startExitListening() {
59 | startExitListening(null);
60 | }
61 |
62 | public void startExitListening(final Runnable popBackStackRunnable) {
63 | if (interpolator == null) {
64 | interpolator = new DecelerateInterpolator();
65 | }
66 | final View toView = moveData.toView;
67 | toView.setFocusableInTouchMode(true);
68 | toView.requestFocus();
69 | toView.setOnKeyListener(new View.OnKeyListener() {
70 | @Override
71 | public boolean onKey(View v, int keyCode, KeyEvent event) {
72 | if (keyCode == KeyEvent.KEYCODE_BACK) {
73 | if (event.getAction() != KeyEvent.ACTION_UP) {
74 | return true;
75 | }
76 | TransitionAnimation.startExitAnimation(moveData, interpolator, new Runnable() {
77 | @Override
78 | public void run() {
79 | if (popBackStackRunnable != null) {
80 | popBackStackRunnable.run();
81 | return;
82 | }
83 | if (fragment == null) {
84 | if (!supportFragment.isResumed()) {
85 | return;
86 | }
87 | final FragmentManager fragmentManager = supportFragment.getFragmentManager();
88 | if (fragmentManager != null) {
89 | fragmentManager.popBackStack();
90 | }
91 | } else {
92 | if (!fragment.isResumed()) {
93 | return;
94 | }
95 | final android.app.FragmentManager fragmentManager = fragment.getFragmentManager();
96 | if (fragmentManager != null) {
97 | fragmentManager.popBackStack();
98 | }
99 | }
100 | }
101 | }, listener);
102 | return true;
103 | }
104 | return false;
105 | }
106 | });
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/fragment/FragmentTransition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition.fragment;
19 |
20 | import android.animation.Animator;
21 | import android.animation.TimeInterpolator;
22 | import android.app.Fragment;
23 | import android.os.Bundle;
24 | import android.view.View;
25 | import android.view.animation.DecelerateInterpolator;
26 |
27 | import com.kogitune.activity_transition.core.MoveData;
28 | import com.kogitune.activity_transition.core.TransitionAnimation;
29 |
30 | import static com.kogitune.activity_transition.fragment.FragmentTransitionLauncher.TRANSITION_BUNDLE;
31 |
32 | public class FragmentTransition {
33 | private static TimeInterpolator interpolator;
34 | private Animator.AnimatorListener listener;
35 | private int duration = 1000;
36 | private View toView;
37 | private android.support.v4.app.Fragment supportFragment;
38 | private Fragment fragment;
39 |
40 | private FragmentTransition(Fragment fragment) {
41 | this.fragment = fragment;
42 | }
43 |
44 | private FragmentTransition(android.support.v4.app.Fragment fragment) {
45 | this.supportFragment = fragment;
46 | }
47 |
48 | public static FragmentTransition with(Fragment fragment) {
49 | return new FragmentTransition(fragment);
50 | }
51 |
52 | public static FragmentTransition with(android.support.v4.app.Fragment fragment) {
53 | return new FragmentTransition(fragment);
54 | }
55 |
56 | public FragmentTransition to(View toView) {
57 | this.toView = toView;
58 | return this;
59 | }
60 |
61 | public FragmentTransition duration(int duration) {
62 | this.duration = duration;
63 | return this;
64 | }
65 |
66 | public FragmentTransition enterListener(Animator.AnimatorListener listener) {
67 | this.listener = listener;
68 | return this;
69 | }
70 |
71 |
72 | public FragmentTransition interpolator(TimeInterpolator interpolator) {
73 | FragmentTransition.interpolator = interpolator;
74 | return this;
75 | }
76 |
77 | public ExitFragmentTransition start(Bundle savedInstanceState) {
78 | if (interpolator == null) {
79 | interpolator = new DecelerateInterpolator();
80 | }
81 |
82 | final Bundle bundle;
83 | if (fragment == null) {
84 | if (supportFragment.getArguments() == null) {
85 | throw new IllegalStateException("you should call FragmentTransitionLauncher.prepare() at first ");
86 | }
87 | bundle = supportFragment.getArguments().getBundle(TRANSITION_BUNDLE);
88 | } else {
89 | if (fragment.getArguments() == null) {
90 | throw new IllegalStateException("you should call FragmentTransitionLauncher.prepare() at first ");
91 | }
92 | bundle = fragment.getArguments().getBundle(TRANSITION_BUNDLE);
93 | }
94 |
95 | final MoveData moveData = TransitionAnimation.startAnimation(toView, bundle, savedInstanceState, duration, interpolator, listener);
96 | if (fragment == null) {
97 | return new ExitFragmentTransition(supportFragment, moveData);
98 | }
99 | return new ExitFragmentTransition(fragment, moveData);
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/pre-lollipop-activity-transition/src/main/java/com/kogitune/activity_transition/fragment/FragmentTransitionLauncher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.activity_transition.fragment;
19 |
20 | import android.app.Fragment;
21 | import android.content.Context;
22 | import android.graphics.Bitmap;
23 | import android.os.Bundle;
24 | import android.view.View;
25 |
26 | import com.kogitune.activity_transition.core.TransitionBundleFactory;
27 |
28 | public class FragmentTransitionLauncher {
29 | private static final String TAG = "TransitionLauncher";
30 | static final String TRANSITION_BUNDLE = "TransitionBundle";
31 |
32 |
33 | private final Context context;
34 | private View fromView;
35 | private Bitmap bitmap;
36 |
37 |
38 | private FragmentTransitionLauncher(Context context) {
39 | this.context = context;
40 | }
41 |
42 | public static FragmentTransitionLauncher with(Context context) {
43 | return new FragmentTransitionLauncher(context);
44 | }
45 |
46 | public FragmentTransitionLauncher from(View fromView) {
47 | this.fromView = fromView;
48 | return this;
49 | }
50 |
51 | public FragmentTransitionLauncher image(final Bitmap bitmap) {
52 | this.bitmap = bitmap;
53 | return this;
54 | }
55 | /**
56 | * You should call this method after init your argumentsBundle.otherwise the transitionBundle will be not work.
57 | */
58 | public void prepare(Fragment toFragment) {
59 | final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap);
60 | Bundle arguments = toFragment.getArguments();
61 | if (arguments == null) {
62 | arguments = new Bundle();
63 | }
64 | arguments.putBundle(TRANSITION_BUNDLE, transitionBundle);
65 | toFragment.setArguments(arguments);
66 | }
67 | /**
68 | * You should call this method after init your argumentsBundle.otherwise the transitionBundle will be not work.
69 | */
70 | public void prepare(android.support.v4.app.Fragment toFragment) {
71 | final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap);
72 | Bundle arguments = toFragment.getArguments();
73 | if (arguments == null) {
74 | arguments = new Bundle();
75 | }
76 | arguments.putBundle(TRANSITION_BUNDLE, transitionBundle);
77 | toFragment.setArguments(arguments);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/sample-app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample-app/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | apply plugin: 'com.android.application'
19 | apply plugin: 'spoon'
20 |
21 | buildscript {
22 | repositories {
23 | mavenCentral()
24 | }
25 | dependencies {
26 | classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.2.2'
27 | }
28 | }
29 |
30 | android {
31 | compileSdkVersion rootProject.ext.CompileSdk
32 | buildToolsVersion rootProject.ext.BuildTools
33 |
34 | defaultConfig {
35 | applicationId "com.kogitune.prelollipoptransition"
36 | minSdkVersion rootProject.ext.MinSdk
37 | targetSdkVersion rootProject.ext.TargetSdk
38 | versionCode 1
39 | versionName "1.0"
40 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
41 | }
42 | buildTypes {
43 | release {
44 | minifyEnabled false
45 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
46 | }
47 | }
48 | adbOptions {
49 | timeOutInMs 600000 // set timeout to 1 minute
50 | }
51 | }
52 |
53 | dependencies {
54 | compile "com.android.support:appcompat-v7:$rootProject.ext.SupportLibrary"
55 | compile "com.android.support:support-v4:$rootProject.ext.SupportLibrary"
56 |
57 | // testing
58 | androidTestCompile 'com.android.support.test:runner:0.3'
59 | androidTestCompile 'com.android.support.test:rules:0.3'
60 | androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
61 | androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2'
62 | androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2'
63 | androidTestCompile 'com.squareup.spoon:spoon-client:1.6.4'
64 | androidTestCompile 'com.squareup.okhttp:mockwebserver:2.4.0'
65 | androidTestCompile 'com.squareup:fest-android:1.0.7'
66 |
67 | compile project(":pre-lollipop-activity-transition")
68 |
69 | // compile('com.kogitune:pre-lollipop-activity-transition:1.3.2') {
70 | // exclude module: 'support-v4'
71 | // }
72 |
73 | }
74 |
75 | configurations {
76 | androidTestCompile.exclude group: 'com.android.support', module: 'support-v4'
77 | androidTestCompile.exclude group: 'com.android.support', module: 'recyclerview-v7'
78 | androidTestCompile.exclude group: 'com.android.support', module: 'support-annotations'
79 | }
80 |
81 | spoon {
82 | debug = true;
83 | adbTimeout = 60;
84 | }
85 |
--------------------------------------------------------------------------------
/sample-app/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 /Applications/android-sdk-macosx-l/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 |
--------------------------------------------------------------------------------
/sample-app/src/androidTest/java/com/kogitune/prelollipoptransition/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition;
19 |
20 | import android.app.Application;
21 | import android.test.ApplicationTestCase;
22 |
23 | /**
24 | * Testing Fundamentals
25 | */
26 | public class ApplicationTest extends ApplicationTestCase {
27 | public ApplicationTest() {
28 | super(Application.class);
29 | }
30 | }
--------------------------------------------------------------------------------
/sample-app/src/androidTest/java/com/kogitune/prelollipoptransition/ListViewActivityTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition;
19 |
20 | import android.app.Activity;
21 | import android.app.Instrumentation;
22 | import android.test.ActivityInstrumentationTestCase2;
23 | import android.view.KeyEvent;
24 | import android.widget.ListView;
25 |
26 | import com.squareup.spoon.Spoon;
27 |
28 | public class ListViewActivityTest extends ActivityInstrumentationTestCase2 {
29 |
30 | private Instrumentation instrumentation;
31 |
32 | public ListViewActivityTest() {
33 | super(ListViewActivity.class);
34 | }
35 |
36 | @Override
37 | public void setUp() throws Exception {
38 | super.setUp();
39 | instrumentation = getInstrumentation();
40 | }
41 |
42 | public void testListClick() throws InterruptedException {
43 | Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity.class.getName(), null, false);
44 | Spoon.screenshot(getActivity(), "init");
45 |
46 | // listviewactivity -> subactivity
47 | final ListView listView = (ListView) getActivity().findViewById(R.id.list);
48 | instrumentation.waitForIdleSync();
49 | instrumentation.runOnMainSync(new Runnable() {
50 | @Override
51 | public void run() {
52 | assertTrue(listView.performItemClick(listView.getChildAt(0), 0, 0));
53 | }
54 | });
55 | Activity detailActivity = instrumentation.waitForMonitor(monitor);
56 | // Wait for animation
57 | Thread.sleep(2000l);
58 |
59 | instrumentation.waitForIdleSync();
60 | Spoon.screenshot(detailActivity, "listview_transition");
61 |
62 | // subactivity -> listviewactivity
63 | sendKeys(KeyEvent.KEYCODE_BACK);
64 | // Wait for animation
65 | Thread.sleep(2000l);
66 |
67 | instrumentation.waitForIdleSync();
68 | Spoon.screenshot(getActivity(), "listview_transition_backpress");
69 | }
70 |
71 |
72 | }
--------------------------------------------------------------------------------
/sample-app/src/androidTest/java/com/kogitune/prelollipoptransition/MainActivityTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition;
19 |
20 | import android.app.Activity;
21 | import android.app.Instrumentation;
22 | import android.test.ActivityInstrumentationTestCase2;
23 | import android.view.KeyEvent;
24 | import android.widget.ImageView;
25 |
26 | import com.kogitune.activity_transition.core.TransitionAnimation;
27 | import com.kogitune.prelollipoptransition.fragment.SubFragment;
28 | import com.squareup.spoon.Spoon;
29 |
30 | import junit.framework.Assert;
31 |
32 | import org.fest.assertions.api.ANDROID;
33 |
34 | import static com.kogitune.prelollipoptransition.R.id.imageView;
35 | import static com.kogitune.prelollipoptransition.R.id.imageView2;
36 | import static com.kogitune.prelollipoptransition.R.id.imageView3;
37 |
38 | public class MainActivityTest extends ActivityInstrumentationTestCase2 {
39 |
40 | private Instrumentation instrumentation;
41 |
42 | public MainActivityTest() {
43 | super(MainActivity.class);
44 | }
45 |
46 | @Override
47 | public void setUp() throws Exception {
48 | super.setUp();
49 | instrumentation = getInstrumentation();
50 | }
51 |
52 | public void testShouldOpen() {
53 | Spoon.screenshot(getActivity(), "on_main_activity_open_start");
54 | Assert.assertTrue(true);
55 | }
56 |
57 | public void testFragmentTransition() throws InterruptedException {
58 |
59 | Spoon.screenshot(getActivity(), "init");
60 | final ImageView imageView = (ImageView) getActivity().findViewById(R.id.support_fragment_start_imageview);
61 | final ImageView imageView2 = (ImageView) getActivity().findViewById(R.id.fragment_start_imageview);
62 | instrumentation.waitForIdleSync();
63 | instrumentation.runOnMainSync(new Runnable() {
64 | @Override
65 | public void run() {
66 | assertTrue(imageView.performClick());
67 | assertTrue(imageView2.performClick());
68 | }
69 | });
70 | // Wait for animation
71 | Thread.sleep(2000l);
72 |
73 | instrumentation.waitForIdleSync();
74 | Spoon.screenshot(getActivity(), "support_fragment_transition");
75 | sendKeys(KeyEvent.KEYCODE_BACK);
76 | instrumentation.waitForIdleSync();
77 | Thread.sleep(2000l);
78 |
79 |
80 | Spoon.screenshot(getActivity(), "support_fragment_transition_backpress1");
81 |
82 | sendKeys(KeyEvent.KEYCODE_BACK);
83 | instrumentation.waitForIdleSync();
84 | Thread.sleep(3000l);
85 |
86 | Spoon.screenshot(getActivity(), "support_fragment_transition_backpress2");
87 | }
88 |
89 |
90 | public void testSubFragmentTransition() throws InterruptedException {
91 |
92 | Spoon.screenshot(getActivity(), "init");
93 | final ImageView imageView3 = (ImageView) getActivity().findViewById(R.id.imageView3);
94 | instrumentation.waitForIdleSync();
95 | instrumentation.runOnMainSync(new Runnable() {
96 | @Override
97 | public void run() {
98 | assertTrue(imageView3.performClick());
99 | }
100 | });
101 | // Wait for animation
102 | Thread.sleep(3000l);
103 | instrumentation.waitForIdleSync();
104 | Spoon.screenshot(getActivity(), "SubFragment_transition_backpress");
105 | sendKeys(KeyEvent.KEYCODE_BACK);
106 | Thread.sleep(2000l);
107 | }
108 |
109 |
110 | public void testGoSubActivity() throws InterruptedException {
111 | Spoon.screenshot(getActivity(), "init");
112 | Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity.class.getName(), null, false);
113 |
114 | final ImageView imageView = (ImageView) getActivity().findViewById(R.id.imageView);
115 | instrumentation.waitForIdleSync();
116 |
117 | instrumentation.runOnMainSync(new Runnable() {
118 | @Override
119 | public void run() {
120 | assertTrue(imageView.performClick());
121 | }
122 | });
123 |
124 |
125 | Activity activity = instrumentation.waitForMonitor(monitor);
126 |
127 | // Verify new activity was shown.
128 | ANDROID.assertThat(monitor).hasHits(1);
129 | // Wait for animation
130 | Thread.sleep(2000l);
131 | Spoon.screenshot(activity, "sub_activity_shown");
132 |
133 | // subactivity -> mainactivity
134 | sendKeys(KeyEvent.KEYCODE_BACK);
135 | // Wait for animation
136 | Thread.sleep(2000l);
137 |
138 | instrumentation.waitForIdleSync();
139 | Spoon.screenshot(getActivity(), "main_activity_backed");
140 | }
141 |
142 | public void testGoSubActivity2() throws InterruptedException {
143 | Spoon.screenshot(getActivity(), "init");
144 | Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity2.class.getName(), null, false);
145 |
146 | final ImageView imageView = (ImageView) getActivity().findViewById(R.id.imageView2);
147 | instrumentation.waitForIdleSync();
148 |
149 | instrumentation.runOnMainSync(new Runnable() {
150 | @Override
151 | public void run() {
152 | assertTrue(imageView.performClick());
153 | }
154 | });
155 |
156 |
157 | Activity activity = instrumentation.waitForMonitor(monitor);
158 |
159 | // Verify new activity was shown.
160 | ANDROID.assertThat(monitor).hasHits(1);
161 | // Wait for animation
162 | Thread.sleep(2000l);
163 | Spoon.screenshot(activity, "sub_activity_shown");
164 |
165 |
166 | // subactivity -> mainactivity
167 | sendKeys(KeyEvent.KEYCODE_BACK);
168 | // Wait for animation
169 | Thread.sleep(2000l);
170 |
171 | instrumentation.waitForIdleSync();
172 | Spoon.screenshot(getActivity(), "main_activity_backed");
173 | }
174 |
175 | public void testClearCacheGoSubActivity2() throws InterruptedException {
176 | Spoon.screenshot(getActivity(), "init");
177 | Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity2.class.getName(), null, false);
178 |
179 | final ImageView imageView = (ImageView) getActivity().findViewById(R.id.imageView2);
180 | instrumentation.waitForIdleSync();
181 |
182 | instrumentation.runOnMainSync(new Runnable() {
183 | @Override
184 | public void run() {
185 | assertTrue(imageView.performClick());
186 | }
187 | });
188 | instrumentation.runOnMainSync(
189 | new Runnable() {
190 | @Override
191 | public void run() {
192 | // clear bitmapCache
193 | TransitionAnimation.bitmapCache.clear();
194 | }
195 | });
196 |
197 |
198 | Activity activity = instrumentation.waitForMonitor(monitor);
199 |
200 | // Verify new activity was shown.
201 | ANDROID.assertThat(monitor).hasHits(1);
202 | // Wait for animation
203 | Thread.sleep(2000l);
204 | Spoon.screenshot(activity, "sub_activity_shown");
205 |
206 |
207 | // subactivity -> mainactivity
208 | sendKeys(KeyEvent.KEYCODE_BACK);
209 | // Wait for animation
210 | Thread.sleep(2000l);
211 |
212 | instrumentation.waitForIdleSync();
213 | Spoon.screenshot(getActivity(), "main_activity_backed");
214 | }
215 | }
--------------------------------------------------------------------------------
/sample-app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/sample-app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
20 |
21 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
38 |
39 |
42 |
43 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/ListViewActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition;
19 |
20 | import android.animation.Animator;
21 | import android.animation.AnimatorListenerAdapter;
22 | import android.content.Intent;
23 | import android.os.Bundle;
24 | import android.support.v7.app.AppCompatActivity;
25 | import android.util.Log;
26 | import android.view.View;
27 | import android.view.ViewGroup;
28 | import android.widget.AdapterView;
29 | import android.widget.AdapterView.OnItemClickListener;
30 | import android.widget.BaseAdapter;
31 | import android.widget.ListView;
32 |
33 | import com.kogitune.activity_transition.ActivityTransition;
34 | import com.kogitune.activity_transition.ActivityTransitionLauncher;
35 | import com.kogitune.activity_transition.ExitActivityTransition;
36 |
37 | public class ListViewActivity extends AppCompatActivity {
38 |
39 | private ExitActivityTransition exitTransition;
40 |
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.activity_list_view);
45 | Bundle bundle = getIntent().getExtras();
46 | if (bundle != null) {
47 | exitTransition = ActivityTransition
48 | .with(getIntent())
49 | .enterListener(new AnimatorListenerAdapter() {
50 | @Override
51 | public void onAnimationEnd(Animator animation) {
52 | Log.d("TAG", "onEnterAnimationEnd!!");
53 | }
54 |
55 | @Override
56 | public void onAnimationStart(Animator animation) {
57 | Log.d("TAG", "onEnterAnimationStart!!");
58 | }
59 | })
60 | .to(findViewById(R.id.parent_container))
61 | .start(savedInstanceState);
62 | }
63 |
64 | }
65 |
66 | @Override
67 | public void onBackPressed() {
68 | if (exitTransition != null) {
69 | exitTransition.exit(this);
70 | }
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition;
19 |
20 | import android.content.Intent;
21 | import android.graphics.BitmapFactory;
22 | import android.os.Bundle;
23 | import android.support.v4.app.Fragment;
24 | import android.support.v7.app.AppCompatActivity;
25 | import android.view.View;
26 | import android.view.View.OnClickListener;
27 | import android.widget.Toast;
28 |
29 | import com.kogitune.activity_transition.ActivityTransitionLauncher;
30 | import com.kogitune.activity_transition.fragment.FragmentTransitionLauncher;
31 | import com.kogitune.prelollipoptransition.fragment.EndFragment;
32 | import com.kogitune.prelollipoptransition.fragment.SubFragment;
33 | import com.kogitune.prelollipoptransition.support_fragment.SupportStartFragment;
34 |
35 |
36 | public class MainActivity extends AppCompatActivity {
37 |
38 | public static final int REQUEST_CODE = 100;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_main);
44 |
45 | findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | final Intent intent = new Intent(MainActivity.this, SubActivity.class);
49 | ActivityTransitionLauncher
50 | .with(MainActivity.this)
51 | .from(v)
52 | .launch(intent);
53 | }
54 | });
55 |
56 | findViewById(R.id.imageView2).setOnClickListener(new View.OnClickListener() {
57 | @Override
58 | public void onClick(View v) {
59 | final Intent intent = new Intent(MainActivity.this, SubActivity2.class);
60 | // set bitmap for animation
61 | // use startActivityForResult
62 | Bundle transitionBundle = ActivityTransitionLauncher
63 | .with(MainActivity.this)
64 | .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))
65 | .from(v)
66 | .createBundle();
67 | intent.putExtras(transitionBundle);
68 | startActivityForResult(intent, REQUEST_CODE);
69 | // you should prevent default activity tansition animation
70 | overridePendingTransition(0, 0);
71 | }
72 | });
73 | findViewById(R.id.imageView3).setOnClickListener(new View.OnClickListener() {
74 | @Override
75 | public void onClick(View v) {
76 |
77 | final Fragment toFragment = new SubFragment();
78 | //init your bundle first!!
79 | Bundle bundle = new Bundle();
80 | bundle.putString("Test", "Test");
81 | toFragment.setArguments(bundle);
82 |
83 | //You should call this method after init your argumentsBundle.
84 | FragmentTransitionLauncher
85 | .with(v.getContext())
86 | .from(v)
87 | .prepare(toFragment);
88 | getSupportFragmentManager().beginTransaction().replace(R.id.parent_container, toFragment).addToBackStack(null).commit();
89 | }
90 | });
91 |
92 | findViewById(R.id.listViewExampleButton).setOnClickListener(new OnClickListener() {
93 | @Override
94 | public void onClick(View v) {
95 | final Intent intent = new Intent(MainActivity.this, ListViewActivity.class);
96 | Bundle transitionBundle = ActivityTransitionLauncher
97 | .with(MainActivity.this)
98 | // .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))
99 | .from(v)
100 | .createBundle();
101 | intent.putExtras(transitionBundle);
102 | startActivity(intent);
103 | // you should prevent default activity tansition animation
104 | overridePendingTransition(0, 0);
105 | }
106 | });
107 |
108 | if (savedInstanceState == null) {
109 | getSupportFragmentManager()
110 | .beginTransaction()
111 | .add(R.id.support_content, new SupportStartFragment())
112 | .commit();
113 | getFragmentManager()
114 | .beginTransaction()
115 | .add(R.id.content, new com.kogitune.prelollipoptransition.fragment.StartFragment())
116 | .commit();
117 |
118 | }
119 | }
120 |
121 | @Override
122 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
123 | super.onActivityResult(requestCode, resultCode, data);
124 | if (REQUEST_CODE == requestCode) {
125 | String resultExtra = data.getStringExtra(SubActivity2.EXTRA_RESULT);
126 | Toast.makeText(this, "onActivityResult:" + resultExtra, Toast.LENGTH_SHORT).show();
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/SubActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition;
19 |
20 | import android.animation.Animator;
21 | import android.animation.AnimatorListenerAdapter;
22 | import android.os.Bundle;
23 | import android.support.v7.app.AppCompatActivity;
24 | import android.util.Log;
25 |
26 | import com.kogitune.activity_transition.ActivityTransition;
27 | import com.kogitune.activity_transition.ExitActivityTransition;
28 |
29 |
30 | public class SubActivity extends AppCompatActivity {
31 |
32 | private ExitActivityTransition exitTransition;
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_sub);
38 | exitTransition = ActivityTransition
39 | .with(getIntent())
40 | .enterListener(new AnimatorListenerAdapter() {
41 | @Override
42 | public void onAnimationEnd(Animator animation) {
43 | Log.d("TAG", "onEnterAnimationEnd!!");
44 | }
45 |
46 | @Override
47 | public void onAnimationStart(Animator animation) {
48 | Log.d("TAG", "onOEnterAnimationStart!!");
49 | }
50 | })
51 | .to(findViewById(R.id.sub_imageView))
52 | .start(savedInstanceState);
53 | exitTransition.exitListener(new AnimatorListenerAdapter() {
54 | @Override
55 | public void onAnimationStart(Animator animation) {
56 | Log.d("TAG", "onOutAnimationStart!!");
57 | }
58 |
59 | @Override
60 | public void onAnimationEnd(Animator animation) {
61 | Log.d("TAG", "onOutAnimationEnd!!");
62 | }
63 | });
64 | }
65 |
66 | @Override
67 | public void onBackPressed() {
68 | exitTransition.exit(this);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/SubActivity2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition;
19 |
20 | import android.animation.Animator;
21 | import android.animation.AnimatorListenerAdapter;
22 | import android.content.Intent;
23 | import android.os.Bundle;
24 | import android.support.v7.app.AppCompatActivity;
25 | import android.util.Log;
26 | import android.view.animation.BounceInterpolator;
27 | import android.view.animation.OvershootInterpolator;
28 |
29 | import com.kogitune.activity_transition.ActivityTransition;
30 | import com.kogitune.activity_transition.ExitActivityTransition;
31 |
32 | import static android.app.Activity.RESULT_OK;
33 |
34 |
35 | public class SubActivity2 extends AppCompatActivity {
36 |
37 | public static final String EXTRA_RESULT = "result";
38 | private ExitActivityTransition exitTransition;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_sub2);
44 | Intent intent = getIntent();
45 | exitTransition = ActivityTransition
46 | .with(intent)
47 | .to(findViewById(R.id.sub_imageView))
48 | .interpolator(new BounceInterpolator())
49 | .enterListener(new AnimatorListenerAdapter() {
50 | @Override
51 | public void onAnimationStart(Animator animation) {
52 | Log.d("TAG", "onEnterAnimationStart!! ");
53 | }
54 |
55 | @Override
56 | public void onAnimationEnd(Animator animation) {
57 | Log.d("TAG", "onEnterAnimationEnd!!");
58 | }
59 |
60 | })
61 | .start(savedInstanceState);
62 | exitTransition.exitListener(new AnimatorListenerAdapter() {
63 | @Override
64 | public void onAnimationEnd(Animator animation) {
65 | Log.d("TAG", "onExitAnimationEnd!!");
66 | }
67 |
68 | @Override
69 | public void onAnimationStart(Animator animation) {
70 | Log.d("TAG", "onExitAnimationStart!!");
71 | }
72 | });
73 | }
74 |
75 | @Override
76 | public void onBackPressed() {
77 | Intent intent = new Intent();
78 | intent.putExtra(EXTRA_RESULT, "ok");
79 | setResult(RESULT_OK, intent);
80 | exitTransition.interpolator(new OvershootInterpolator()).exit(this);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/fragment/EndFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition.fragment;
19 |
20 | import android.animation.Animator;
21 | import android.animation.AnimatorListenerAdapter;
22 | import android.app.Fragment;
23 | import android.os.Bundle;
24 | import android.support.v4.view.animation.FastOutSlowInInterpolator;
25 | import android.support.v4.view.animation.LinearOutSlowInInterpolator;
26 | import android.util.Log;
27 | import android.view.LayoutInflater;
28 | import android.view.View;
29 | import android.view.ViewGroup;
30 | import android.view.animation.AccelerateDecelerateInterpolator;
31 | import android.view.animation.DecelerateInterpolator;
32 |
33 | import com.kogitune.activity_transition.fragment.ExitFragmentTransition;
34 | import com.kogitune.activity_transition.fragment.FragmentTransition;
35 | import com.kogitune.prelollipoptransition.R;
36 |
37 | public class EndFragment extends Fragment {
38 | @Override
39 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
40 | View v = inflater.inflate(R.layout.fragment_end, container, false);
41 | final ExitFragmentTransition exitFragmentTransition
42 | = FragmentTransition
43 | .with(this)
44 | .interpolator(new LinearOutSlowInInterpolator())
45 | .to(v.findViewById(R.id.fragment_imageView))
46 | .start(savedInstanceState);
47 | exitFragmentTransition.exitListener(new AnimatorListenerAdapter() {
48 | @Override
49 | public void onAnimationStart(Animator animation) {
50 | Log.d("TAG", "onAnimationStart: ");
51 | }
52 |
53 | @Override
54 | public void onAnimationEnd(Animator animation) {
55 | Log.d("TAG", "onAnimationEnd: ");
56 | }
57 | }).interpolator(new FastOutSlowInInterpolator());
58 | exitFragmentTransition.startExitListening();
59 | return v;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/fragment/ListViewFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.kogitune.prelollipoptransition.fragment;
18 |
19 | import android.content.Intent;
20 | import android.os.Bundle;
21 | import android.support.annotation.Nullable;
22 | import android.support.v4.app.Fragment;
23 | import android.view.LayoutInflater;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 | import android.widget.AdapterView;
27 | import android.widget.BaseAdapter;
28 | import android.widget.ListView;
29 |
30 | import com.kogitune.activity_transition.ActivityTransitionLauncher;
31 | import com.kogitune.prelollipoptransition.ListViewActivity;
32 | import com.kogitune.prelollipoptransition.R;
33 | import com.kogitune.prelollipoptransition.SubActivity;
34 |
35 | public class ListViewFragment extends Fragment {
36 | @Nullable
37 | @Override
38 | public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
39 | View inflate = inflater.inflate(R.layout.fragment_list_view, container, false);
40 |
41 |
42 |
43 | final ListView listView = (ListView) inflate.findViewById(R.id.list);
44 | listView.setAdapter(new BaseAdapter() {
45 | @Override
46 | public int getCount() {
47 | return 10;
48 | }
49 |
50 | @Override
51 | public Object getItem(int position) {
52 | return null;
53 | }
54 |
55 | @Override
56 | public long getItemId(int position) {
57 | return 0;
58 | }
59 |
60 | @Override
61 | public View getView(int position, View convertView, ViewGroup parent) {
62 | return inflater.inflate(R.layout.list_row, parent, false);
63 | }
64 | });
65 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
66 | @Override
67 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
68 | final Intent intent = new Intent(getContext(), SubActivity.class);
69 | ActivityTransitionLauncher.with(getActivity()).from(view.findViewById(R.id.image)).launch(intent);
70 | }
71 | });
72 | return inflate;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/fragment/StartFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition.fragment;
19 |
20 | import android.app.Fragment;
21 | import android.graphics.BitmapFactory;
22 | import android.os.Bundle;
23 | import android.view.LayoutInflater;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 |
27 | import com.kogitune.activity_transition.fragment.FragmentTransitionLauncher;
28 | import com.kogitune.prelollipoptransition.R;
29 |
30 | public class StartFragment extends Fragment {
31 | @Override
32 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
33 | View v = inflater.inflate(R.layout.fragment_start, container, false);
34 | v.findViewById(R.id.fragment_start_imageview).setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View view) {
37 | final EndFragment toFragment = new EndFragment();
38 | FragmentTransitionLauncher
39 | .with(view.getContext())
40 | .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))
41 | .from(view.findViewById(R.id.fragment_start_imageview)).prepare(toFragment);
42 | getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit();
43 | }
44 | });
45 | return v;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/fragment/SubFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition.fragment;
19 |
20 | import android.animation.Animator;
21 | import android.animation.AnimatorListenerAdapter;
22 | import android.os.Bundle;
23 | import android.support.annotation.Nullable;
24 | import android.support.v4.app.Fragment;
25 | import android.support.v4.view.animation.FastOutSlowInInterpolator;
26 | import android.support.v4.view.animation.LinearOutSlowInInterpolator;
27 | import android.util.Log;
28 | import android.view.LayoutInflater;
29 | import android.view.View;
30 | import android.view.ViewGroup;
31 |
32 | import com.kogitune.activity_transition.fragment.ExitFragmentTransition;
33 | import com.kogitune.activity_transition.fragment.FragmentTransition;
34 | import com.kogitune.prelollipoptransition.R;
35 |
36 |
37 | public class SubFragment extends Fragment {
38 |
39 | @Nullable
40 | @Override
41 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
42 | View v = inflater.inflate(R.layout.fragment_sub, container, false);
43 | final ExitFragmentTransition exitFragmentTransition
44 | = FragmentTransition
45 | .with(this)
46 | .interpolator(new LinearOutSlowInInterpolator())
47 | .to(v.findViewById(R.id.sub_imageView))
48 | .start(savedInstanceState);
49 | exitFragmentTransition.exitListener(new AnimatorListenerAdapter() {
50 | @Override
51 | public void onAnimationStart(Animator animation) {
52 | Log.d("TAG", "onAnimationStart: ");
53 | }
54 |
55 | @Override
56 | public void onAnimationEnd(Animator animation) {
57 | Log.d("TAG", "onAnimationEnd: ");
58 | }
59 | }).interpolator(new FastOutSlowInInterpolator());
60 | exitFragmentTransition.startExitListening();
61 | return v;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/support_fragment/SupportEndFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition.support_fragment;
19 |
20 | import android.os.Bundle;
21 | import android.support.v4.app.Fragment;
22 | import android.support.v4.view.animation.FastOutSlowInInterpolator;
23 | import android.view.LayoutInflater;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 |
27 | import com.kogitune.activity_transition.fragment.ExitFragmentTransition;
28 | import com.kogitune.activity_transition.fragment.FragmentTransition;
29 | import com.kogitune.prelollipoptransition.R;
30 |
31 | public class SupportEndFragment extends Fragment {
32 | @Override
33 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
34 | View v = inflater.inflate(R.layout.support_fragment_end, container, false);
35 | final ExitFragmentTransition exitFragmentTransition = FragmentTransition
36 | .with(this)
37 | .interpolator(new FastOutSlowInInterpolator())
38 | .to(v.findViewById(R.id.fragment_imageview))
39 | .start(savedInstanceState);
40 |
41 | exitFragmentTransition.startExitListening();
42 | return v;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/kogitune/prelollipoptransition/support_fragment/SupportStartFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.kogitune.prelollipoptransition.support_fragment;
19 |
20 | import android.os.Bundle;
21 | import android.support.v4.app.Fragment;
22 | import android.view.LayoutInflater;
23 | import android.view.View;
24 | import android.view.ViewGroup;
25 |
26 | import com.kogitune.activity_transition.fragment.FragmentTransitionLauncher;
27 | import com.kogitune.prelollipoptransition.R;
28 |
29 | public class SupportStartFragment extends Fragment {
30 | @Override
31 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
32 | View v = inflater.inflate(R.layout.support_fragment_start, container, false);
33 | v.findViewById(R.id.support_fragment_start_imageview).setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View view) {
36 | final SupportEndFragment toFragment = new SupportEndFragment();
37 | FragmentTransitionLauncher
38 | .with(view.getContext())
39 | .from(view.findViewById(R.id.support_fragment_start_imageview))
40 | .prepare(toFragment);
41 | getFragmentManager().beginTransaction().replace(R.id.support_content, toFragment).addToBackStack(null).commit();
42 | }
43 | });
44 | return v;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/drawable/photo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/takahirom/PreLollipopTransition/90c6e12b5dd40a52dd57cb6560cfefe1804ba36d/sample-app/src/main/res/drawable/photo.jpg
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/activity_list_view.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
24 |
25 |
30 |
31 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
24 |
25 |
26 |
32 |
33 |
37 |
38 |
42 |
43 |
48 |
49 |
54 |
55 |
60 |
61 |
68 |
69 |
70 |
78 |
86 |
87 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/activity_sub.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
26 |
27 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/activity_sub2.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
27 |
28 |
34 |
35 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/fragment_end.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
21 |
22 |
30 |
31 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/fragment_list_view.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
27 |
28 |
32 |
33 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/fragment_start.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
22 |
23 |
32 |
33 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/fragment_sub.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/list_row.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
22 |
23 |
29 |
30 |
38 |
39 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/support_fragment_end.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
21 |
22 |
31 |
32 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/support_fragment_start.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
21 |
22 |
31 |
32 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/menu/menu_list_view.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
27 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
27 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/menu/menu_sub.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
28 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/takahirom/PreLollipopTransition/90c6e12b5dd40a52dd57cb6560cfefe1804ba36d/sample-app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/takahirom/PreLollipopTransition/90c6e12b5dd40a52dd57cb6560cfefe1804ba36d/sample-app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/takahirom/PreLollipopTransition/90c6e12b5dd40a52dd57cb6560cfefe1804ba36d/sample-app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/takahirom/PreLollipopTransition/90c6e12b5dd40a52dd57cb6560cfefe1804ba36d/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample-app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
22 | 64dp
23 |
24 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 | 16dp
21 | 16dp
22 |
23 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 | PreLollipopTransition
20 |
21 | Hello world!
22 | Settings
23 | SubActivity
24 | SubActivity2
25 | ListViewActivity
26 |
27 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 takahirom
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | include 'sample-app:','pre-lollipop-activity-transition:'
19 |
--------------------------------------------------------------------------------