├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable
│ │ │ ├── lion.jpg
│ │ │ └── gorilla.jpg
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── transition
│ │ │ └── simple_fragment_transition.xml
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── styles.xml
│ │ │ └── strings.xml
│ │ ├── transition-v21
│ │ │ └── default_window_fade.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ ├── layout
│ │ │ ├── item_animal_square.xml
│ │ │ ├── activity_fragment_to_fragment.xml
│ │ │ ├── activity_recycler_view_to_fragment.xml
│ │ │ ├── fragment_animal_view_pager.xml
│ │ │ ├── activity_recycler_view.xml
│ │ │ ├── glide_activity_b.xml
│ │ │ ├── picasso_activity_b.xml
│ │ │ ├── glide_fragment_b.xml
│ │ │ ├── picasso_fragment_b.xml
│ │ │ ├── activity_b.xml
│ │ │ ├── fragment_b.xml
│ │ │ ├── glide_activity_a.xml
│ │ │ ├── picasso_activity_a.xml
│ │ │ ├── glide_fragment_a.xml
│ │ │ ├── picasso_fragment_a.xml
│ │ │ ├── activity_a.xml
│ │ │ ├── fragment_a.xml
│ │ │ ├── activity_animal_detail.xml
│ │ │ ├── fragment_animal_detail.xml
│ │ │ ├── activity_flash_fix_b.xml
│ │ │ ├── activity_flash_fix_a.xml
│ │ │ └── activity_main.xml
│ │ └── values-v21
│ │ │ └── styles.xml
│ │ ├── java
│ │ └── com
│ │ │ └── mikescamell
│ │ │ └── sharedelementtransitions
│ │ │ ├── recycler_view
│ │ │ ├── AnimalItemClickListener.java
│ │ │ ├── recycler_view_to_fragment
│ │ │ │ ├── RecyclerViewToFragmentActivity.java
│ │ │ │ ├── RecyclerViewFragment.java
│ │ │ │ └── AnimalDetailFragment.java
│ │ │ ├── recycler_view_to_viewpager
│ │ │ │ ├── RecyclerViewToViewPagerActivity.java
│ │ │ │ ├── AnimalPagerAdapter.java
│ │ │ │ ├── AnimalViewPagerFragment.java
│ │ │ │ └── RecyclerViewFragment.java
│ │ │ ├── AnimalItem.java
│ │ │ ├── Utils.java
│ │ │ ├── recycler_view_to_activity
│ │ │ │ ├── AnimalDetailActivity.java
│ │ │ │ └── RecyclerViewActivity.java
│ │ │ └── AnimalGalleryAdapter.java
│ │ │ ├── simple_activity_to_activity
│ │ │ ├── SimpleActivityB.java
│ │ │ └── SimpleActivityA.java
│ │ │ ├── simple_fragment_to_fragment
│ │ │ ├── FragmentToFragmentActivity.java
│ │ │ ├── SimpleFragmentB.java
│ │ │ └── SimpleFragmentA.java
│ │ │ ├── glide_fragment_to_fragment
│ │ │ ├── GlideFragmentToFragmentActivity.java
│ │ │ ├── GlideFragmentA.java
│ │ │ └── GlideFragmentB.java
│ │ │ ├── picasso_fragment_to_fragment
│ │ │ ├── PicassoFragmentToFragmentActivity.java
│ │ │ ├── PicassoFragmentB.java
│ │ │ └── PicassoFragmentA.java
│ │ │ ├── picasso_activity_to_activity
│ │ │ ├── PicassoActivityB.java
│ │ │ └── PicassoActivityA.java
│ │ │ ├── glide_activity_to_activity
│ │ │ ├── GlideActivityB.java
│ │ │ └── GlideActivityA.java
│ │ │ ├── flash_fix
│ │ │ ├── xml_activity
│ │ │ │ ├── FlashFixXmlActivityA.java
│ │ │ │ └── FlashFixXmlActivityB.java
│ │ │ └── programmatic_activity
│ │ │ │ ├── FlashFixProgrammaticActivityA.java
│ │ │ │ └── FlashFixProgrammaticActivityB.java
│ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── LICENSE
├── LICENSE.md
├── .gitignore
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/lion.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikescamell/shared-element-transitions/HEAD/app/src/main/res/drawable/lion.jpg
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikescamell/shared-element-transitions/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gorilla.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikescamell/shared-element-transitions/HEAD/app/src/main/res/drawable/gorilla.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikescamell/shared-element-transitions/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikescamell/shared-element-transitions/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/transition/simple_fragment_transition.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikescamell/shared-element-transitions/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikescamell/shared-element-transitions/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikescamell/shared-element-transitions/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jan 17 19:24:25 GMT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/transition-v21/default_window_fade.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/AnimalItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view;
2 |
3 | import android.widget.ImageView;
4 |
5 | /**
6 | * Created by msc10 on 19/02/2017.
7 | */
8 |
9 | public interface AnimalItemClickListener {
10 | void onAnimalItemClick(int pos, AnimalItem animalItem, ImageView shareImageView);
11 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_animal_square.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/simple_activity_to_activity/SimpleActivityB.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.simple_activity_to_activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.mikescamell.sharedelementtransitions.R;
7 |
8 | public class SimpleActivityB extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_b);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_fragment_to_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_view_to_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_animal_view_pager.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/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 /Users/msc10/Library/Android/sdk/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 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/simple_fragment_to_fragment/FragmentToFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.simple_fragment_to_fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.mikescamell.sharedelementtransitions.R;
7 |
8 | public class FragmentToFragmentActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_fragment_to_fragment);
14 |
15 | getSupportFragmentManager()
16 | .beginTransaction()
17 | .add(R.id.content, SimpleFragmentA.newInstance())
18 | .commit();
19 | }
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_fragment/RecyclerViewToFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.mikescamell.sharedelementtransitions.R;
7 |
8 | public class RecyclerViewToFragmentActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_fragment_to_fragment);
14 |
15 | getSupportFragmentManager()
16 | .beginTransaction()
17 | .add(R.id.content, RecyclerViewFragment.newInstance())
18 | .commit();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_viewpager/RecyclerViewToViewPagerActivity.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_viewpager;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.mikescamell.sharedelementtransitions.R;
7 |
8 | public class RecyclerViewToViewPagerActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_fragment_to_fragment);
14 |
15 | getSupportFragmentManager()
16 | .beginTransaction()
17 | .add(R.id.content, RecyclerViewFragment.newInstance())
18 | .commit();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/glide_fragment_to_fragment/GlideFragmentToFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.glide_fragment_to_fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.mikescamell.sharedelementtransitions.R;
7 |
8 | public class GlideFragmentToFragmentActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_fragment_to_fragment);
14 |
15 | if (savedInstanceState == null) {
16 | getSupportFragmentManager()
17 | .beginTransaction()
18 | .add(R.id.content, GlideFragmentA.newInstance())
19 | .commit();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/picasso_fragment_to_fragment/PicassoFragmentToFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.picasso_fragment_to_fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.mikescamell.sharedelementtransitions.R;
7 |
8 | public class PicassoFragmentToFragmentActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_fragment_to_fragment);
14 |
15 | if (savedInstanceState == null) {
16 | getSupportFragmentManager()
17 | .beginTransaction()
18 | .add(R.id.content, PicassoFragmentA.newInstance())
19 | .commit();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/glide_activity_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Michael Scamell
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Michael Scamell
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/picasso_activity_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/glide_fragment_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/picasso_fragment_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_viewpager/AnimalPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_viewpager;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentStatePagerAdapter;
6 |
7 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItem;
8 | import com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_fragment.AnimalDetailFragment;
9 |
10 | import java.util.List;
11 |
12 | public class AnimalPagerAdapter extends FragmentStatePagerAdapter {
13 |
14 | private List animalItems;
15 |
16 | AnimalPagerAdapter(FragmentManager fm, List animalItems) {
17 | super(fm);
18 | this.animalItems = animalItems;
19 | }
20 |
21 | @Override
22 | public Fragment getItem(int position) {
23 | AnimalItem animalItem = animalItems.get(position);
24 | return AnimalDetailFragment.newInstance(animalItem, animalItem.name);
25 | }
26 |
27 | @Override
28 | public int getCount() {
29 | return animalItems.size();
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/simple_fragment_to_fragment/SimpleFragmentB.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.simple_fragment_to_fragment;
2 |
3 |
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.transition.TransitionInflater;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 |
13 | import com.mikescamell.sharedelementtransitions.R;
14 |
15 | public class SimpleFragmentB extends Fragment {
16 |
17 | public SimpleFragmentB() {
18 | // Required empty public constructor
19 | }
20 |
21 | public static SimpleFragmentB newInstance() {
22 | return new SimpleFragmentB();
23 | }
24 |
25 | @Override
26 | public void onCreate(@Nullable Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
29 | setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(android.R.transition.move));
30 | }
31 | }
32 |
33 | @Override
34 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
35 | Bundle savedInstanceState) {
36 | return inflater.inflate(R.layout.fragment_b, container, false);
37 | }
38 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/picasso_activity_to_activity/PicassoActivityB.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.picasso_activity_to_activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.widget.ImageView;
6 |
7 | import com.mikescamell.sharedelementtransitions.R;
8 | import com.squareup.picasso.Callback;
9 | import com.squareup.picasso.Picasso;
10 |
11 | public class PicassoActivityB extends AppCompatActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.picasso_activity_b);
17 | ImageView imageView = (ImageView) findViewById(R.id.picasso_activity_b_image);
18 |
19 | supportPostponeEnterTransition();
20 |
21 | Picasso.with(this)
22 | .load(PicassoActivityA.TIGER_PIC_URL)
23 | .fit()
24 | .noFade()
25 | .centerCrop()
26 | .into(imageView, new Callback() {
27 | @Override
28 | public void onSuccess() {
29 | supportStartPostponedEnterTransition();
30 | }
31 |
32 | @Override
33 | public void onError() {
34 | supportStartPostponedEnterTransition();
35 | }
36 | });
37 | }
38 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/glide_activity_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
22 |
23 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/picasso_activity_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
22 |
23 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/AnimalItem.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * Created by msc10 on 16/02/2017.
8 | */
9 | public class AnimalItem implements Parcelable {
10 |
11 | @SuppressWarnings("unused")
12 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
13 | @Override
14 | public AnimalItem createFromParcel(Parcel in) {
15 | return new AnimalItem(in);
16 | }
17 |
18 | @Override
19 | public AnimalItem[] newArray(int size) {
20 | return new AnimalItem[size];
21 | }
22 | };
23 |
24 | public String name;
25 | public String detail;
26 | public String imageUrl;
27 |
28 | public AnimalItem(String name, String detail, String imageUrl) {
29 | this.name = name;
30 | this.detail = detail;
31 | this.imageUrl = imageUrl;
32 | }
33 |
34 | protected AnimalItem(Parcel in) {
35 | name = in.readString();
36 | detail = in.readString();
37 | imageUrl = in.readString();
38 | }
39 |
40 | @Override
41 | public int describeContents() {
42 | return 0;
43 | }
44 |
45 | @Override
46 | public void writeToParcel(Parcel dest, int flags) {
47 | dest.writeString(name);
48 | dest.writeString(detail);
49 | dest.writeString(imageUrl);
50 | }
51 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.mikescamell.sharedelementtransitions"
8 | minSdkVersion 19
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | ext {
23 | supportLibVersion = '25.2.0'
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
29 | exclude group: 'com.android.support', module: 'support-annotations'
30 | })
31 |
32 | compile "com.android.support:appcompat-v7:${supportLibVersion}"
33 | compile 'com.squareup.picasso:picasso:2.5.2'
34 | compile 'com.github.bumptech.glide:glide:3.7.0'
35 | compile "com.android.support:recyclerview-v7:${supportLibVersion}"
36 | compile "com.android.support:support-v4:${supportLibVersion}"
37 | compile 'com.android.support.constraint:constraint-layout:1.0.1'
38 | compile "com.android.support:percent:${supportLibVersion}"
39 | compile "com.android.support:design:${supportLibVersion}"
40 | testCompile 'junit:junit:4.12'
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/simple_activity_to_activity/SimpleActivityA.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.simple_activity_to_activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.view.ViewCompat;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.ImageView;
11 |
12 | import com.mikescamell.sharedelementtransitions.R;
13 |
14 | public class SimpleActivityA extends AppCompatActivity {
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_a);
20 |
21 | final ImageView imageView = (ImageView) findViewById(R.id.simple_activity_a_imageView);
22 |
23 | Button button = (Button) findViewById(R.id.simple_activity_a_btn);
24 | button.setOnClickListener(new View.OnClickListener() {
25 | @Override
26 | public void onClick(View v) {
27 | Intent intent = new Intent(SimpleActivityA.this, SimpleActivityB.class);
28 | ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
29 | SimpleActivityA.this,
30 | imageView,
31 | ViewCompat.getTransitionName(imageView));
32 | startActivity(intent, options.toBundle());
33 | }
34 | });
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/glide_fragment_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
24 |
25 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/picasso_fragment_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
24 |
25 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
25 |
26 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
25 |
26 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_animal_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
29 |
30 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_animal_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
30 |
31 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Android template
3 | # Built application files
4 | *.apk
5 | *.ap_
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 |
18 | # Gradle files
19 | .gradle/
20 | build/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Log Files
29 | *.log
30 |
31 | # Android Studio Navigation editor temp files
32 | .navigation/
33 |
34 | # Android Studio captures folder
35 | captures/
36 |
37 | # Intellij
38 | *.iml
39 | .idea
40 |
41 | # Keystore files
42 | *.jks
43 |
44 | # External native build folder generated in Android Studio 2.2 and later
45 | .externalNativeBuild
46 | ### JetBrains template
47 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
48 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
49 |
50 | # User-specific stuff:
51 |
52 | # Sensitive or high-churn files:
53 | .idea/dataSources/
54 | .idea/dataSources.ids
55 | .idea/dataSources.xml
56 | .idea/dataSources.local.xml
57 | .idea/sqlDataSources.xml
58 | .idea/dynamic.xml
59 | .idea/uiDesigner.xml
60 |
61 | # Gradle:
62 | .idea/gradle.xml
63 |
64 | # Mongo Explorer plugin:
65 | .idea/mongoSettings.xml
66 |
67 | ## File-based project format:
68 | *.iws
69 |
70 | ## Plugin-specific files:
71 |
72 | # IntelliJ
73 | /out/
74 |
75 | # mpeltonen/sbt-idea plugin
76 | .idea_modules/
77 |
78 | # JIRA plugin
79 | atlassian-ide-plugin.xml
80 |
81 | # Crashlytics plugin (for Android Studio and IntelliJ)
82 | com_crashlytics_export_strings.xml
83 | crashlytics.properties
84 | crashlytics-build.properties
85 | fabric.properties
86 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_flash_fix_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
23 |
24 |
25 |
26 |
34 |
35 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_flash_fix_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
23 |
24 |
33 |
34 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/glide_activity_to_activity/GlideActivityB.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.glide_activity_to_activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.widget.ImageView;
6 |
7 | import com.bumptech.glide.Glide;
8 | import com.bumptech.glide.load.resource.drawable.GlideDrawable;
9 | import com.bumptech.glide.request.RequestListener;
10 | import com.bumptech.glide.request.target.Target;
11 | import com.mikescamell.sharedelementtransitions.R;
12 |
13 | public class GlideActivityB extends AppCompatActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.glide_activity_b);
19 | ImageView imageView = (ImageView) findViewById(R.id.glide_activity_b_image);
20 |
21 | supportPostponeEnterTransition();
22 |
23 | Glide.with(this)
24 | .load(GlideActivityA.FOX_PIC_URL)
25 | .centerCrop()
26 | .dontAnimate()
27 | .listener(new RequestListener() {
28 | @Override
29 | public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
30 | supportStartPostponedEnterTransition();
31 | return false;
32 | }
33 |
34 | @Override
35 | public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
36 | supportStartPostponedEnterTransition();
37 | return false;
38 | }
39 | })
40 | .into(imageView);
41 | }
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/glide_activity_to_activity/GlideActivityA.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.glide_activity_to_activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.view.ViewCompat;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.ImageView;
11 |
12 | import com.bumptech.glide.Glide;
13 | import com.mikescamell.sharedelementtransitions.R;
14 |
15 | public class GlideActivityA extends AppCompatActivity {
16 |
17 | public static final String FOX_PIC_URL = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Red_Fox_(Vulpes_vulpes)_(4).jpg/640px-Red_Fox_(Vulpes_vulpes)_(4).jpg";
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.glide_activity_a);
23 |
24 | final ImageView imageView = (ImageView) findViewById(R.id.glide_activity_a_imageView);
25 | Glide.with(this)
26 | .load(FOX_PIC_URL)
27 | .centerCrop()
28 | .into(imageView);
29 |
30 | Button button = (Button) findViewById(R.id.glide_activity_a_btn);
31 | button.setOnClickListener(new View.OnClickListener() {
32 | @Override
33 | public void onClick(View v) {
34 | Intent intent = new Intent(GlideActivityA.this, GlideActivityB.class);
35 | ActivityOptionsCompat options = ActivityOptionsCompat.
36 | makeSceneTransitionAnimation(GlideActivityA.this,
37 | imageView,
38 | ViewCompat.getTransitionName(imageView));
39 | startActivity(intent, options.toBundle());
40 | }
41 | });
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/picasso_activity_to_activity/PicassoActivityA.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.picasso_activity_to_activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.view.ViewCompat;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.ImageView;
11 |
12 | import com.mikescamell.sharedelementtransitions.R;
13 | import com.squareup.picasso.Picasso;
14 |
15 | public class PicassoActivityA extends AppCompatActivity {
16 |
17 | public static final String TIGER_PIC_URL = "https://cdn.pixabay.com/photo/2016/11/29/10/07/animal-1868911_1280.jpg";
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.picasso_activity_a);
23 |
24 | final ImageView imageView = (ImageView) findViewById(R.id.picasso_activity_a_imageView);
25 | Picasso.with(this)
26 | .load(TIGER_PIC_URL)
27 | .fit()
28 | .centerCrop()
29 | .into(imageView);
30 |
31 | Button button = (Button) findViewById(R.id.picasso_activity_a_btn);
32 | button.setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View v) {
35 | Intent intent = new Intent(PicassoActivityA.this, PicassoActivityB.class);
36 | ActivityOptionsCompat options = ActivityOptionsCompat.
37 | makeSceneTransitionAnimation(PicassoActivityA.this,
38 | imageView,
39 | ViewCompat.getTransitionName(imageView));
40 | startActivity(intent, options.toBundle());
41 | }
42 | });
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/simple_fragment_to_fragment/SimpleFragmentA.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.simple_fragment_to_fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.view.ViewCompat;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Button;
11 | import android.widget.ImageView;
12 |
13 | import com.mikescamell.sharedelementtransitions.R;
14 |
15 | public class SimpleFragmentA extends Fragment {
16 |
17 | public static final String TAG = SimpleFragmentA.class.getSimpleName();
18 |
19 | public SimpleFragmentA() {
20 | // Required empty public constructor
21 | }
22 |
23 | public static SimpleFragmentA newInstance() {
24 | return new SimpleFragmentA();
25 | }
26 |
27 | @Override
28 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
29 | Bundle savedInstanceState) {
30 | return inflater.inflate(R.layout.fragment_a, container, false);
31 | }
32 |
33 | @Override
34 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
35 | super.onViewCreated(view, savedInstanceState);
36 |
37 | final ImageView imageView = (ImageView) view.findViewById(R.id.fragment_a_imageView);
38 |
39 | Button button = (Button) view.findViewById(R.id.fragment_a_btn);
40 | button.setOnClickListener(new View.OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | SimpleFragmentB simpleFragmentB = SimpleFragmentB.newInstance();
44 | getFragmentManager()
45 | .beginTransaction()
46 | .addSharedElement(imageView, ViewCompat.getTransitionName(imageView))
47 | .addToBackStack(TAG)
48 | .replace(R.id.content, simpleFragmentB)
49 | .commit();
50 | }
51 | });
52 | }
53 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/flash_fix/xml_activity/FlashFixXmlActivityA.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.flash_fix.xml_activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.view.ViewCompat;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.ImageView;
12 |
13 | import com.bumptech.glide.Glide;
14 | import com.mikescamell.sharedelementtransitions.R;
15 |
16 | public class FlashFixXmlActivityA extends AppCompatActivity {
17 |
18 | public static final String PIG_PIC_URL = "http://s0.geograph.org.uk/photos/57/76/577604_d3efbef6.jpg";
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_flash_fix_a);
24 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
25 | setSupportActionBar(toolbar);
26 |
27 | final ImageView imageView = (ImageView) findViewById(R.id.flash_fix_xml_activity_a_imageView);
28 | Glide.with(this)
29 | .load(PIG_PIC_URL)
30 | .centerCrop()
31 | .into(imageView);
32 |
33 | Button button = (Button) findViewById(R.id.flash_fix_xml_activity_a_btn);
34 | button.setText(R.string.pig);
35 | button.setOnClickListener(new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | Intent intent = new Intent(FlashFixXmlActivityA.this, FlashFixXmlActivityB.class);
39 | ActivityOptionsCompat options = ActivityOptionsCompat.
40 | makeSceneTransitionAnimation(FlashFixXmlActivityA.this,
41 | imageView,
42 | ViewCompat.getTransitionName(imageView));
43 | startActivity(intent, options.toBundle());
44 | }
45 | });
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/Utils.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view;
2 |
3 | import android.content.Context;
4 |
5 | import com.mikescamell.sharedelementtransitions.R;
6 |
7 | import java.util.ArrayList;
8 |
9 | /**
10 | * Created by msc10 on 19/02/2017.
11 | */
12 |
13 | public class Utils {
14 |
15 | public static ArrayList generateAnimalItems(Context context) {
16 | ArrayList animalItems = new ArrayList<>();
17 | animalItems.add(new AnimalItem("Dog", context.getString(R.string.dog_blurb), "https://c1.staticflickr.com/1/188/417924629_6832e79c98_z.jpg?zz=1"));
18 | animalItems.add(new AnimalItem("Penguin", context.getString(R.string.penguin_blurb), "https://c1.staticflickr.com/9/8616/16237154608_c5489cae31_z.jpg"));
19 | animalItems.add(new AnimalItem("Eagle", context.getString(R.string.eagle_blurb), "https://c1.staticflickr.com/5/4010/4210875342_7cb06a9b62_z.jpg?zz=1"));
20 | animalItems.add(new AnimalItem("Rabbit", context.getString(R.string.rabbit_blurb), "https://c2.staticflickr.com/4/3285/2819978026_175072995a_z.jpg?zz=1"));
21 | animalItems.add(new AnimalItem("Dolphin", context.getString(R.string.dolphin_blurb), "https://c1.staticflickr.com/8/7619/16124006043_60bc4d8ca5_z.jpg"));
22 | animalItems.add(new AnimalItem("Snek", context.getString(R.string.snek_blurb), "https://c1.staticflickr.com/9/8796/17158681740_a6caa5099f_z.jpg"));
23 | animalItems.add(new AnimalItem("Seal", context.getString(R.string.seal_blurb), "https://c1.staticflickr.com/4/3852/14729534910_62b338dd72_z.jpg"));
24 | animalItems.add(new AnimalItem("Rhino", context.getString(R.string.rhino_blurb), "https://c1.staticflickr.com/1/335/18040640224_f56f05f8dc_z.jpg"));
25 | animalItems.add(new AnimalItem("Leopard", context.getString(R.string.leopard_blurb), "https://c1.staticflickr.com/9/8678/16645189230_b0e96e7af9_z.jpg"));
26 | animalItems.add(new AnimalItem("Hippo", context.getString(R.string.hippo_blurb), "https://c2.staticflickr.com/4/3774/9377370000_6a57d1cfec_z.jpg"));
27 | return animalItems;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_activity/AnimalDetailActivity.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_activity;
2 |
3 | import android.os.Build;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.widget.ImageView;
7 | import android.widget.TextView;
8 |
9 | import com.mikescamell.sharedelementtransitions.R;
10 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItem;
11 | import com.squareup.picasso.Callback;
12 | import com.squareup.picasso.Picasso;
13 |
14 | public class AnimalDetailActivity extends AppCompatActivity {
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_animal_detail);
20 | supportPostponeEnterTransition();
21 |
22 | Bundle extras = getIntent().getExtras();
23 | AnimalItem animalItem = extras.getParcelable(RecyclerViewActivity.EXTRA_ANIMAL_ITEM);
24 |
25 | ImageView imageView = (ImageView) findViewById(R.id.animal_detail_image_view);
26 | TextView textView = (TextView) findViewById(R.id.animal_detail_text);
27 | textView.setText(animalItem.detail);
28 |
29 | String imageUrl = animalItem.imageUrl;
30 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
31 | String imageTransitionName = extras.getString(RecyclerViewActivity.EXTRA_ANIMAL_IMAGE_TRANSITION_NAME);
32 | imageView.setTransitionName(imageTransitionName);
33 | }
34 |
35 | Picasso.with(this)
36 | .load(imageUrl)
37 | .noFade()
38 | .into(imageView, new Callback() {
39 | @Override
40 | public void onSuccess() {
41 | supportStartPostponedEnterTransition();
42 | }
43 |
44 | @Override
45 | public void onError() {
46 | supportStartPostponedEnterTransition();
47 | }
48 | });
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/flash_fix/xml_activity/FlashFixXmlActivityB.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.flash_fix.xml_activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.support.v7.widget.Toolbar;
6 | import android.widget.ImageView;
7 | import android.widget.TextView;
8 |
9 | import com.bumptech.glide.Glide;
10 | import com.bumptech.glide.load.resource.drawable.GlideDrawable;
11 | import com.bumptech.glide.request.RequestListener;
12 | import com.bumptech.glide.request.target.Target;
13 | import com.mikescamell.sharedelementtransitions.R;
14 |
15 | public class FlashFixXmlActivityB extends AppCompatActivity {
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_flash_fix_b);
21 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
22 | setSupportActionBar(toolbar);
23 | supportPostponeEnterTransition();
24 |
25 | TextView detailTextView = (TextView) findViewById(R.id.flash_fix_activity_b_text);
26 | detailTextView.setText(getString(R.string.pig_blurb));
27 |
28 | ImageView imageView = (ImageView) findViewById(R.id.flash_fix_activity_b_imageView);
29 |
30 | Glide.with(this)
31 | .load(FlashFixXmlActivityA.PIG_PIC_URL)
32 | .centerCrop()
33 | .dontAnimate()
34 | .listener(new RequestListener() {
35 | @Override
36 | public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
37 | supportStartPostponedEnterTransition();
38 | return false;
39 | }
40 |
41 | @Override
42 | public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
43 | supportStartPostponedEnterTransition();
44 | return false;
45 | }
46 | })
47 | .into(imageView);
48 | }
49 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/picasso_fragment_to_fragment/PicassoFragmentB.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.picasso_fragment_to_fragment;
2 |
3 |
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.transition.TransitionInflater;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ImageView;
13 |
14 | import com.mikescamell.sharedelementtransitions.R;
15 | import com.squareup.picasso.Callback;
16 | import com.squareup.picasso.Picasso;
17 |
18 | public class PicassoFragmentB extends Fragment {
19 |
20 | public PicassoFragmentB() {
21 | // Required empty public constructor
22 | }
23 |
24 | public static PicassoFragmentB newInstance() {
25 | return new PicassoFragmentB();
26 | }
27 |
28 | @Override
29 | public void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | postponeEnterTransition();
32 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
33 | setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(android.R.transition.move));
34 | }
35 | }
36 |
37 | @Override
38 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
39 | Bundle savedInstanceState) {
40 | return inflater.inflate(R.layout.picasso_fragment_b, container, false);
41 | }
42 |
43 | @Override
44 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
45 | super.onViewCreated(view, savedInstanceState);
46 |
47 | ImageView imageView = (ImageView) view.findViewById(R.id.picasso_fragment_b_image);
48 | Picasso.with(getContext())
49 | .load(PicassoFragmentA.GIRAFFE_PIC_URL)
50 | .fit()
51 | .noFade()
52 | .centerCrop()
53 | .into(imageView, new Callback() {
54 | @Override
55 | public void onSuccess() {
56 | startPostponedEnterTransition();
57 | }
58 |
59 | @Override
60 | public void onError() {
61 | startPostponedEnterTransition();
62 | }
63 | });
64 | }
65 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_activity/RecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.view.ViewCompat;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.GridLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.widget.ImageView;
11 |
12 | import com.mikescamell.sharedelementtransitions.R;
13 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalGalleryAdapter;
14 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItem;
15 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItemClickListener;
16 | import com.mikescamell.sharedelementtransitions.recycler_view.Utils;
17 |
18 | public class RecyclerViewActivity extends AppCompatActivity implements AnimalItemClickListener {
19 |
20 | public static final String EXTRA_ANIMAL_ITEM = "animal_image_url";
21 | public static final String EXTRA_ANIMAL_IMAGE_TRANSITION_NAME = "animal_image_transition_name";
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_recycler_view);
27 |
28 | AnimalGalleryAdapter animalGalleryAdapter = new AnimalGalleryAdapter(Utils.generateAnimalItems(this), this);
29 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
30 | GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
31 | recyclerView.setLayoutManager(gridLayoutManager);
32 | recyclerView.setAdapter(animalGalleryAdapter);
33 | }
34 |
35 | @Override
36 | public void onAnimalItemClick(int pos, AnimalItem animalItem, ImageView sharedImageView) {
37 | Intent intent = new Intent(this, AnimalDetailActivity.class);
38 | intent.putExtra(EXTRA_ANIMAL_ITEM, animalItem);
39 | intent.putExtra(EXTRA_ANIMAL_IMAGE_TRANSITION_NAME, ViewCompat.getTransitionName(sharedImageView));
40 |
41 | ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
42 | this,
43 | sharedImageView,
44 | ViewCompat.getTransitionName(sharedImageView));
45 |
46 | startActivity(intent, options.toBundle());
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/AnimalGalleryAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view;
2 |
3 | import android.support.v4.view.ViewCompat;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 |
10 | import com.mikescamell.sharedelementtransitions.R;
11 | import com.squareup.picasso.Picasso;
12 |
13 | import java.util.ArrayList;
14 |
15 | /**
16 | * Created by msc10 on 16/02/2017.
17 | */
18 |
19 | public class AnimalGalleryAdapter extends RecyclerView.Adapter {
20 |
21 | private final AnimalItemClickListener animalItemClickListener;
22 | private ArrayList animalItems;
23 |
24 | public AnimalGalleryAdapter(ArrayList animalItems, AnimalItemClickListener animalItemClickListener) {
25 | this.animalItems = animalItems;
26 | this.animalItemClickListener = animalItemClickListener;
27 | }
28 |
29 | @Override
30 | public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
31 | return new ImageViewHolder(LayoutInflater.from(parent.getContext())
32 | .inflate(R.layout.item_animal_square, parent, false));
33 | }
34 |
35 | @Override
36 | public int getItemCount() {
37 | return animalItems.size();
38 | }
39 |
40 | @Override
41 | public void onBindViewHolder(final ImageViewHolder holder, int position) {
42 | final AnimalItem animalItem = animalItems.get(position);
43 |
44 | Picasso.with(holder.itemView.getContext())
45 | .load(animalItem.imageUrl)
46 | .into(holder.animalImageView);
47 |
48 | ViewCompat.setTransitionName(holder.animalImageView, animalItem.name);
49 |
50 | holder.itemView.setOnClickListener(new View.OnClickListener() {
51 | @Override
52 | public void onClick(View v) {
53 | animalItemClickListener.onAnimalItemClick(holder.getAdapterPosition(), animalItem, holder.animalImageView);
54 | }
55 | });
56 | }
57 |
58 | public static class ImageViewHolder extends RecyclerView.ViewHolder {
59 |
60 | private ImageView animalImageView;
61 |
62 | public ImageViewHolder(View itemView) {
63 | super(itemView);
64 | animalImageView = (ImageView) itemView.findViewById(R.id.item_animal_square_image);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/glide_fragment_to_fragment/GlideFragmentA.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.glide_fragment_to_fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.view.ViewCompat;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Button;
11 | import android.widget.ImageView;
12 |
13 | import com.bumptech.glide.Glide;
14 | import com.mikescamell.sharedelementtransitions.R;
15 |
16 | public class GlideFragmentA extends Fragment {
17 |
18 | public static final String TAG = GlideFragmentA.class.getSimpleName();
19 | public static String ARMADILLO_PIC_URL = "http://a1.img.talkingpointsmemo.com/image/upload/c_fill,fl_keep_iptc,g_faces,h_365,w_652/xiglrkmrizdvmkdqw50j.jpg";
20 |
21 | public GlideFragmentA() {
22 | // Required empty public constructor
23 | }
24 |
25 | public static GlideFragmentA newInstance() {
26 | return new GlideFragmentA();
27 | }
28 |
29 | @Override
30 | public void onCreate(@Nullable Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | }
33 |
34 | @Override
35 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
36 | Bundle savedInstanceState) {
37 | return inflater.inflate(R.layout.glide_fragment_a, container, false);
38 | }
39 |
40 | @Override
41 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
42 | super.onViewCreated(view, savedInstanceState);
43 |
44 | final ImageView imageView = (ImageView) view.findViewById(R.id.glide_fragment_a_imageView);
45 | Glide.with(getContext())
46 | .load(ARMADILLO_PIC_URL)
47 | .centerCrop()
48 | .into(imageView);
49 |
50 | Button button = (Button) view.findViewById(R.id.glide_fragment_a_btn);
51 | button.setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | GlideFragmentB simpleFragmentB = GlideFragmentB.newInstance();
55 | getFragmentManager()
56 | .beginTransaction()
57 | .addSharedElement(imageView, ViewCompat.getTransitionName(imageView))
58 | .addToBackStack(TAG)
59 | .replace(R.id.content, simpleFragmentB)
60 | .commit();
61 | }
62 | });
63 | }
64 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/picasso_fragment_to_fragment/PicassoFragmentA.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.picasso_fragment_to_fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.view.ViewCompat;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Button;
11 | import android.widget.ImageView;
12 |
13 | import com.mikescamell.sharedelementtransitions.R;
14 | import com.squareup.picasso.Picasso;
15 |
16 | public class PicassoFragmentA extends Fragment {
17 |
18 | public static final String TAG = PicassoFragmentA.class.getSimpleName();
19 | public static String GIRAFFE_PIC_URL = "http://ichef.bbci.co.uk/naturelibrary/images/ic/credit/640x395/g/gi/giraffe/giraffe_1.jpg";
20 |
21 | public PicassoFragmentA() {
22 | // Required empty public constructor
23 | }
24 |
25 | public static PicassoFragmentA newInstance() {
26 | return new PicassoFragmentA();
27 | }
28 |
29 | @Override
30 | public void onCreate(@Nullable Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | }
33 |
34 | @Override
35 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
36 | Bundle savedInstanceState) {
37 | return inflater.inflate(R.layout.picasso_fragment_a, container, false);
38 | }
39 |
40 | @Override
41 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
42 | super.onViewCreated(view, savedInstanceState);
43 |
44 | final ImageView imageView = (ImageView) view.findViewById(R.id.picasso_fragment_a_imageView);
45 | Picasso.with(getContext())
46 | .load(GIRAFFE_PIC_URL)
47 | .fit()
48 | .centerCrop()
49 | .into(imageView);
50 |
51 | Button button = (Button) view.findViewById(R.id.picasso_fragment_a_btn);
52 | button.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | PicassoFragmentB simpleFragmentB = PicassoFragmentB.newInstance();
56 | getFragmentManager()
57 | .beginTransaction()
58 | .addSharedElement(imageView, ViewCompat.getTransitionName(imageView))
59 | .addToBackStack(TAG)
60 | .replace(R.id.content, simpleFragmentB)
61 | .commit();
62 | }
63 | });
64 | }
65 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/flash_fix/programmatic_activity/FlashFixProgrammaticActivityA.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.flash_fix.programmatic_activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.support.v4.app.ActivityOptionsCompat;
7 | import android.support.v4.view.ViewCompat;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.transition.Fade;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.ImageView;
14 |
15 | import com.bumptech.glide.Glide;
16 | import com.mikescamell.sharedelementtransitions.R;
17 |
18 | public class FlashFixProgrammaticActivityA extends AppCompatActivity {
19 |
20 | public static final String STARFISH_IMAGE_URL = "https://upload.wikimedia.org/wikipedia/commons/f/f2/Starfish_09_(paulshaffner).jpg";
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_flash_fix_a);
26 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
27 | setSupportActionBar(toolbar);
28 |
29 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
30 | Fade fade = new Fade();
31 | fade.excludeTarget(R.id.appBar, true);
32 | fade.excludeTarget(android.R.id.statusBarBackground, true);
33 | fade.excludeTarget(android.R.id.navigationBarBackground, true);
34 |
35 | getWindow().setEnterTransition(fade);
36 | getWindow().setExitTransition(fade);
37 | }
38 |
39 | final ImageView imageView = (ImageView) findViewById(R.id.flash_fix_xml_activity_a_imageView);
40 | Glide.with(this)
41 | .load(STARFISH_IMAGE_URL)
42 | .centerCrop()
43 | .into(imageView);
44 |
45 | Button button = (Button) findViewById(R.id.flash_fix_xml_activity_a_btn);
46 | button.setText(R.string.starfish);
47 | button.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | Intent intent = new Intent(FlashFixProgrammaticActivityA.this, FlashFixProgrammaticActivityB.class);
51 | ActivityOptionsCompat options = ActivityOptionsCompat.
52 | makeSceneTransitionAnimation(FlashFixProgrammaticActivityA.this,
53 | imageView,
54 | ViewCompat.getTransitionName(imageView));
55 | startActivity(intent, options.toBundle());
56 | }
57 | });
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
39 |
42 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/flash_fix/programmatic_activity/FlashFixProgrammaticActivityB.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.flash_fix.programmatic_activity;
2 |
3 | import android.os.Build;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.transition.Fade;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.bumptech.glide.load.resource.drawable.GlideDrawable;
13 | import com.bumptech.glide.request.RequestListener;
14 | import com.bumptech.glide.request.target.Target;
15 | import com.mikescamell.sharedelementtransitions.R;
16 |
17 | public class FlashFixProgrammaticActivityB extends AppCompatActivity {
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_flash_fix_b);
23 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
24 | setSupportActionBar(toolbar);
25 | supportPostponeEnterTransition();
26 |
27 | TextView detailTextView = (TextView) findViewById(R.id.flash_fix_activity_b_text);
28 | detailTextView.setText(getString(R.string.starfish_blurb));
29 |
30 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
31 | Fade fade = new Fade();
32 | fade.excludeTarget(R.id.appBar, true);
33 | fade.excludeTarget(android.R.id.statusBarBackground, true);
34 | fade.excludeTarget(android.R.id.navigationBarBackground, true);
35 | getWindow().setEnterTransition(fade);
36 | getWindow().setExitTransition(fade);
37 | }
38 |
39 | ImageView imageView = (ImageView) findViewById(R.id.flash_fix_activity_b_imageView);
40 |
41 | Glide.with(this)
42 | .load(FlashFixProgrammaticActivityA.STARFISH_IMAGE_URL)
43 | .centerCrop()
44 | .dontAnimate()
45 | .listener(new RequestListener() {
46 | @Override
47 | public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
48 | supportStartPostponedEnterTransition();
49 | return false;
50 | }
51 |
52 | @Override
53 | public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
54 | supportStartPostponedEnterTransition();
55 | return false;
56 | }
57 | })
58 | .into(imageView);
59 | }
60 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/glide_fragment_to_fragment/GlideFragmentB.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.glide_fragment_to_fragment;
2 |
3 |
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.transition.TransitionInflater;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ImageView;
13 |
14 | import com.bumptech.glide.Glide;
15 | import com.bumptech.glide.load.resource.drawable.GlideDrawable;
16 | import com.bumptech.glide.request.RequestListener;
17 | import com.bumptech.glide.request.target.Target;
18 | import com.mikescamell.sharedelementtransitions.R;
19 |
20 | public class GlideFragmentB extends Fragment {
21 |
22 | public GlideFragmentB() {
23 | // Required empty public constructor
24 | }
25 |
26 | public static GlideFragmentB newInstance() {
27 | return new GlideFragmentB();
28 | }
29 |
30 | @Override
31 | public void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | postponeEnterTransition();
34 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
35 | setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(android.R.transition.move));
36 | }
37 | }
38 |
39 | @Override
40 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
41 | Bundle savedInstanceState) {
42 | return inflater.inflate(R.layout.glide_fragment_b, container, false);
43 | }
44 |
45 | @Override
46 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
47 | super.onViewCreated(view, savedInstanceState);
48 |
49 | ImageView imageView = (ImageView) view.findViewById(R.id.glide_fragment_b_image);
50 |
51 | Glide.with(this)
52 | .load(GlideFragmentA.ARMADILLO_PIC_URL)
53 | .centerCrop()
54 | .dontAnimate()
55 | .listener(new RequestListener() {
56 | @Override
57 | public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
58 | startPostponedEnterTransition();
59 | return false;
60 | }
61 |
62 | @Override
63 | public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
64 | startPostponedEnterTransition();
65 | return false;
66 | }
67 | })
68 | .into(imageView);
69 | }
70 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_viewpager/AnimalViewPagerFragment.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_viewpager;
2 |
3 |
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.view.ViewPager;
9 | import android.transition.TransitionInflater;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import com.mikescamell.sharedelementtransitions.R;
15 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItem;
16 |
17 | import java.util.ArrayList;
18 |
19 | public class AnimalViewPagerFragment extends Fragment {
20 |
21 | private static final String EXTRA_INITIAL_ITEM_POS = "initial_item_pos";
22 | private static final String EXTRA_ANIMAL_ITEMS = "animal_items";
23 |
24 | public AnimalViewPagerFragment() {
25 | // Required empty public constructor
26 | }
27 |
28 | public static AnimalViewPagerFragment newInstance(int currentItem, ArrayList animalItems) {
29 | AnimalViewPagerFragment animalViewPagerFragment = new AnimalViewPagerFragment();
30 | Bundle bundle = new Bundle();
31 | bundle.putInt(EXTRA_INITIAL_ITEM_POS, currentItem);
32 | bundle.putParcelableArrayList(EXTRA_ANIMAL_ITEMS, animalItems);
33 | animalViewPagerFragment.setArguments(bundle);
34 | return animalViewPagerFragment;
35 | }
36 |
37 | @Override
38 | public void onCreate(@Nullable Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | postponeEnterTransition();
41 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
42 | setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(android.R.transition.move));
43 | }
44 | setSharedElementReturnTransition(null);
45 | }
46 |
47 | @Override
48 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
49 | Bundle savedInstanceState) {
50 | return inflater.inflate(R.layout.fragment_animal_view_pager, container, false);
51 | }
52 |
53 | @Override
54 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
55 | super.onViewCreated(view, savedInstanceState);
56 |
57 | int currentItem = getArguments().getInt(EXTRA_INITIAL_ITEM_POS);
58 | ArrayList animalItems = getArguments().getParcelableArrayList(EXTRA_ANIMAL_ITEMS);
59 |
60 | AnimalPagerAdapter animalPagerAdapter = new AnimalPagerAdapter(getChildFragmentManager(), animalItems);
61 |
62 | ViewPager viewPager = (ViewPager) view.findViewById(R.id.animal_view_pager);
63 | viewPager.setAdapter(animalPagerAdapter);
64 | viewPager.setCurrentItem(currentItem);
65 | }
66 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_viewpager/RecyclerViewFragment.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_viewpager;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.view.ViewCompat;
7 | import android.support.v7.widget.GridLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ImageView;
13 |
14 | import com.mikescamell.sharedelementtransitions.R;
15 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalGalleryAdapter;
16 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItem;
17 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItemClickListener;
18 | import com.mikescamell.sharedelementtransitions.recycler_view.Utils;
19 |
20 | public class RecyclerViewFragment extends Fragment implements AnimalItemClickListener {
21 |
22 | public static final String TAG = RecyclerViewFragment.class.getSimpleName();
23 |
24 | public RecyclerViewFragment() {
25 | // Required empty public constructor
26 | }
27 |
28 | public static RecyclerViewFragment newInstance() {
29 | return new RecyclerViewFragment();
30 | }
31 |
32 | @Override
33 | public void onCreate(@Nullable Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | }
36 |
37 | @Override
38 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
39 | Bundle savedInstanceState) {
40 | return inflater.inflate(R.layout.activity_recycler_view, container, false);
41 | }
42 |
43 | @Override
44 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
45 | super.onViewCreated(view, savedInstanceState);
46 |
47 | AnimalGalleryAdapter animalGalleryAdapter = new AnimalGalleryAdapter(Utils.generateAnimalItems(getContext()), this);
48 | RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
49 | GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
50 | recyclerView.setLayoutManager(gridLayoutManager);
51 | recyclerView.setAdapter(animalGalleryAdapter);
52 | }
53 |
54 | @Override
55 | public void onAnimalItemClick(int pos, AnimalItem animalItem, ImageView sharedImageView) {
56 | Fragment animalViewPagerFragment = AnimalViewPagerFragment.newInstance(pos, Utils.generateAnimalItems(getContext()));
57 | getFragmentManager()
58 | .beginTransaction()
59 | .addSharedElement(sharedImageView, ViewCompat.getTransitionName(sharedImageView))
60 | .addToBackStack(TAG)
61 | .replace(R.id.content, animalViewPagerFragment)
62 | .commit();
63 | }
64 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_fragment/RecyclerViewFragment.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.view.ViewCompat;
7 | import android.support.v7.widget.GridLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ImageView;
13 |
14 | import com.mikescamell.sharedelementtransitions.R;
15 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalGalleryAdapter;
16 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItem;
17 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItemClickListener;
18 | import com.mikescamell.sharedelementtransitions.recycler_view.Utils;
19 |
20 | public class RecyclerViewFragment extends Fragment implements AnimalItemClickListener {
21 |
22 | public static final String TAG = RecyclerViewFragment.class.getSimpleName();
23 |
24 | public RecyclerViewFragment() {
25 | // Required empty public constructor
26 | }
27 |
28 | public static RecyclerViewFragment newInstance() {
29 | return new RecyclerViewFragment();
30 | }
31 |
32 | @Override
33 | public void onCreate(@Nullable Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | }
36 |
37 | @Override
38 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
39 | Bundle savedInstanceState) {
40 | return inflater.inflate(R.layout.activity_recycler_view, container, false);
41 | }
42 |
43 | @Override
44 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
45 | super.onViewCreated(view, savedInstanceState);
46 |
47 | AnimalGalleryAdapter animalGalleryAdapter = new AnimalGalleryAdapter(Utils.generateAnimalItems(getContext()), this);
48 | RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
49 | GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
50 | recyclerView.setLayoutManager(gridLayoutManager);
51 | recyclerView.setAdapter(animalGalleryAdapter);
52 | }
53 |
54 | @Override
55 | public void onAnimalItemClick(int pos, AnimalItem animalItem, ImageView sharedImageView) {
56 | Fragment animalDetailFragment = AnimalDetailFragment.newInstance(animalItem, ViewCompat.getTransitionName(sharedImageView));
57 | getFragmentManager()
58 | .beginTransaction()
59 | .addSharedElement(sharedImageView, ViewCompat.getTransitionName(sharedImageView))
60 | .addToBackStack(TAG)
61 | .replace(R.id.content, animalDetailFragment)
62 | .commit();
63 | }
64 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/recycler_view/recycler_view_to_fragment/AnimalDetailFragment.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_fragment;
2 |
3 |
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.transition.TransitionInflater;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 |
15 | import com.mikescamell.sharedelementtransitions.R;
16 | import com.mikescamell.sharedelementtransitions.recycler_view.AnimalItem;
17 | import com.squareup.picasso.Callback;
18 | import com.squareup.picasso.Picasso;
19 |
20 | public class AnimalDetailFragment extends Fragment {
21 |
22 | private static final String EXTRA_ANIMAL_ITEM = "animal_item";
23 | private static final String EXTRA_TRANSITION_NAME = "transition_name";
24 |
25 | public AnimalDetailFragment() {
26 | // Required empty public constructor
27 | }
28 |
29 | public static AnimalDetailFragment newInstance(AnimalItem animalItem, String transitionName) {
30 | AnimalDetailFragment animalDetailFragment = new AnimalDetailFragment();
31 | Bundle bundle = new Bundle();
32 | bundle.putParcelable(EXTRA_ANIMAL_ITEM, animalItem);
33 | bundle.putString(EXTRA_TRANSITION_NAME, transitionName);
34 | animalDetailFragment.setArguments(bundle);
35 | return animalDetailFragment;
36 | }
37 |
38 | @Override
39 | public void onCreate(@Nullable Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | postponeEnterTransition();
42 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
43 | setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(android.R.transition.move));
44 | }
45 | }
46 |
47 | @Override
48 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
49 | Bundle savedInstanceState) {
50 | return inflater.inflate(R.layout.fragment_animal_detail, container, false);
51 | }
52 |
53 | @Override
54 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
55 | super.onViewCreated(view, savedInstanceState);
56 |
57 | AnimalItem animalItem = getArguments().getParcelable(EXTRA_ANIMAL_ITEM);
58 | String transitionName = getArguments().getString(EXTRA_TRANSITION_NAME);
59 |
60 | TextView detailTextView = (TextView) view.findViewById(R.id.animal_detail_text);
61 | detailTextView.setText(animalItem.detail);
62 |
63 | ImageView imageView = (ImageView) view.findViewById(R.id.animal_detail_image_view);
64 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
65 | imageView.setTransitionName(transitionName);
66 | }
67 |
68 | Picasso.with(getContext())
69 | .load(animalItem.imageUrl)
70 | .noFade()
71 | .into(imageView, new Callback() {
72 | @Override
73 | public void onSuccess() {
74 | startPostponedEnterTransition();
75 | }
76 |
77 | @Override
78 | public void onError() {
79 | startPostponedEnterTransition();
80 | }
81 | });
82 | }
83 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
24 |
25 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
49 |
54 |
55 |
60 |
61 |
66 |
67 |
72 |
73 |
78 |
79 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikescamell/sharedelementtransitions/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.mikescamell.sharedelementtransitions;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | import com.mikescamell.sharedelementtransitions.flash_fix.programmatic_activity.FlashFixProgrammaticActivityA;
10 | import com.mikescamell.sharedelementtransitions.flash_fix.xml_activity.FlashFixXmlActivityA;
11 | import com.mikescamell.sharedelementtransitions.glide_activity_to_activity.GlideActivityA;
12 | import com.mikescamell.sharedelementtransitions.glide_fragment_to_fragment.GlideFragmentToFragmentActivity;
13 | import com.mikescamell.sharedelementtransitions.picasso_activity_to_activity.PicassoActivityA;
14 | import com.mikescamell.sharedelementtransitions.picasso_fragment_to_fragment.PicassoFragmentToFragmentActivity;
15 | import com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_fragment.RecyclerViewToFragmentActivity;
16 | import com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_viewpager.RecyclerViewToViewPagerActivity;
17 | import com.mikescamell.sharedelementtransitions.simple_activity_to_activity.SimpleActivityA;
18 | import com.mikescamell.sharedelementtransitions.simple_fragment_to_fragment.FragmentToFragmentActivity;
19 |
20 | public class MainActivity extends AppCompatActivity {
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_main);
26 |
27 | Button activityToActivityBtn = (Button) findViewById(R.id.activity_to_activity_btn);
28 | activityToActivityBtn.setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View v) {
31 | startActivity(new Intent(MainActivity.this, SimpleActivityA.class));
32 | }
33 | });
34 |
35 | Button fragmentToFragmentBtn = (Button) findViewById(R.id.fragment_to_fragment_btn);
36 | fragmentToFragmentBtn.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View v) {
39 | startActivity(new Intent(MainActivity.this, FragmentToFragmentActivity.class));
40 | }
41 | });
42 |
43 | Button picassoActivityBtn = (Button) findViewById(R.id.picasso_activity_to_activity_btn);
44 | picassoActivityBtn.setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View v) {
47 | startActivity(new Intent(MainActivity.this, PicassoActivityA.class));
48 | }
49 | });
50 |
51 | Button picassoFragmentBtn = (Button) findViewById(R.id.picasso_fragment_to_fragment_btn);
52 | picassoFragmentBtn.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | startActivity(new Intent(MainActivity.this, PicassoFragmentToFragmentActivity.class));
56 | }
57 | });
58 |
59 | Button glideActivityBtn = (Button) findViewById(R.id.glide_activity_to_activity_btn);
60 | glideActivityBtn.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View v) {
63 | startActivity(new Intent(MainActivity.this, GlideActivityA.class));
64 | }
65 | });
66 |
67 | Button glideFragmentBtn = (Button) findViewById(R.id.glide_fragment_to_fragment_btn);
68 | glideFragmentBtn.setOnClickListener(new View.OnClickListener() {
69 | @Override
70 | public void onClick(View v) {
71 | startActivity(new Intent(MainActivity.this, GlideFragmentToFragmentActivity.class));
72 | }
73 | });
74 |
75 | Button recyclerViewToAcitivtyBtn = (Button) findViewById(R.id.recycler_view_to_activity_btn);
76 | recyclerViewToAcitivtyBtn.setOnClickListener(new View.OnClickListener() {
77 | @Override
78 | public void onClick(View v) {
79 | startActivity(new Intent(MainActivity.this, com.mikescamell.sharedelementtransitions.recycler_view.recycler_view_to_activity.RecyclerViewActivity.class));
80 | }
81 | });
82 |
83 | Button recyclerViewToFragmentBtn = (Button) findViewById(R.id.recycler_view_to_fragment_btn);
84 | recyclerViewToFragmentBtn.setOnClickListener(new View.OnClickListener() {
85 | @Override
86 | public void onClick(View v) {
87 | startActivity(new Intent(MainActivity.this, RecyclerViewToFragmentActivity.class));
88 | }
89 | });
90 |
91 | Button recyclerViewToViewPagerBtn = (Button) findViewById(R.id.recycler_view_to_view_pager_btn);
92 | recyclerViewToViewPagerBtn.setOnClickListener(new View.OnClickListener() {
93 | @Override
94 | public void onClick(View v) {
95 | startActivity(new Intent(MainActivity.this, RecyclerViewToViewPagerActivity.class));
96 | }
97 | });
98 |
99 | Button programmaticFlashFixActivity = (Button) findViewById(R.id.flash_fix_programmatic_activity_btn);
100 | programmaticFlashFixActivity.setOnClickListener(new View.OnClickListener() {
101 | @Override
102 | public void onClick(View v) {
103 | startActivity(new Intent(MainActivity.this, FlashFixProgrammaticActivityA.class));
104 | }
105 | });
106 |
107 | Button xmlFlashFixActivity = (Button) findViewById(R.id.flash_fix_xml_activity_btn);
108 | xmlFlashFixActivity.setOnClickListener(new View.OnClickListener() {
109 | @Override
110 | public void onClick(View v) {
111 | startActivity(new Intent(MainActivity.this, FlashFixXmlActivityA.class));
112 | }
113 | });
114 | }
115 |
116 | @Override
117 | public void onBackPressed() {
118 | getSupportFragmentManager().popBackStack();
119 | if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
120 | super.onBackPressed();
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Shared Element Transitions
3 |
4 | simple_activity_transition
5 | simple_fragment_transition
6 |
7 | Lion
8 | Pig
9 | Gorilla
10 | Fox
11 | Armadillo
12 | Tiger
13 | Starfish
14 | Giraffe
15 |
16 | The lion (Panthera leo) is one of the big cats in the genus Panthera and a member of the family Felidae. The commonly used term African lion collectively denotes the several subspecies in Africa. With some males exceeding 250 kg (550 lb) in weight, it is the second-largest living cat after the tiger.
17 | Gorillas are ground-dwelling, predominantly herbivorous apes that inhabit the forests of central Africa. The eponymous genus Gorilla is divided into two species: the eastern gorillas and the western gorillas (both critically endangered), and either four or five subspecies. They are the largest living primates. The DNA of gorillas is highly similar to that of humans, from 95–99% depending on what is counted, and they are the next closest living relatives to humans after the chimpanzees and bonobos.
18 | The tiger (Panthera tigris) is the largest cat species, most recognisable for their pattern of dark vertical stripes on reddish-orange fur with a lighter underside. The species is classified in the genus Panthera with the lion, leopard, jaguar and snow leopard. Tigers are apex predators, primarily preying on ungulates such as deer and bovids. They are territorial and generally solitary but social animals, often requiring large contiguous areas of habitat that support their prey requirements.
19 | The giraffe (Giraffa) is a genus of African even-toed ungulate mammals, the tallest living terrestrial animals and the largest ruminants. The genus consists of eleven species including Giraffa camelopardalis, the type species. Seven of these species are extinct, prehistoric species known from fossils, while four are still extant.
20 | Foxes are small-to-medium-sized, omnivorous mammals belonging to several genera of the family Canidae. Foxes are slightly smaller than a medium-size domestic dog, with a flattened skull, upright triangular ears, a pointed, slightly upturned snout, and a long bushy tail (or brush). Twelve species belong to the monophyletic group of Vulpes genus of "true foxes".
21 | Armadillos are New World placental mammals with a leathery armour shell. The Chlamyphoridae and Dasypodidae are the only surviving families in the order Cingulata, part of the superorder Xenarthra, along with the anteaters and sloths. The word armadillo means "little armoured one" in Spanish.
22 | The domestic dog (Canis lupus familiaris or Canis familiaris) is a member of genus Canis (canines) that forms part of the wolf-like canids, and is the most widely abundant carnivore. The dog and the extant gray wolf are sister taxa, with modern wolves not closely related to the wolves that were first domesticated. The dog was the first domesticated species and has been selectively bred over millennia for various behaviors, sensory capabilities, and physical attributes
23 | Penguins (order Sphenisciformes, family Spheniscidae) are a group of aquatic, flightless birds. They live almost exclusively in the Southern Hemisphere, with only one species, the Galapagos penguin, found north of the equator. Highly adapted for life in the water, penguins have countershaded dark and white plumage, and their wings have evolved into flippers. Most penguins feed on krill, fish, squid and other forms of sealife caught while swimming underwater. They spend about half of their lives on land and half in the oceans.Although almost all penguin species are native to the Southern Hemisphere, they are not found only in cold climates, such as Antarctica. In fact, only a few species of penguin live so far south. Several species are found in the temperate zone, and one species, the Galápagos penguin, lives near the equator.
24 | Eagles are large, powerfully built birds of prey, with heavy heads and beaks. Even the smallest eagles, such as the booted eagle (Aquila pennata), which is comparable in size to a common buzzard (Buteo buteo) or red-tailed hawk (B. jamaicensis), have relatively longer and more evenly broad wings, and more direct, faster flight – despite the reduced size of aerodynamic feathers. Most eagles are larger than any other raptors apart from some vultures. The smallest species of eagle is the South Nicobar serpent eagle (Spilornis klossi), at 450 g (0.99 lb) and 40 cm (16 in). The largest species are discussed below. Like all birds of prey, eagles have very large, hooked beaks for ripping flesh from their prey, strong, muscular legs, and powerful talons. The beak is typically heavier than that of most other birds of prey. Eagles\' eyes are extremely powerful, having up to 3.6 times human acuity for the martial eagle, which enables them to spot potential prey from a very long distance.[2] This keen eyesight is primarily attributed to their extremely large pupils which ensure minimal diffraction (scattering) of the incoming light. The female of all known species of eagles is larger than the male.
25 | Rabbits are small mammals in the family Leporidae of the order Lagomorpha, found in several parts of the world. There are eight different genera in the family classified as rabbits, including the European rabbit (Oryctolagus cuniculus), cottontail rabbits (genus Sylvilagus; 13 species), and the Amami rabbit (Pentalagus furnessi, an endangered species on Amami Ōshima, Japan). There are many other species of rabbit, and these, along with pikas and hares, make up the order Lagomorpha. The male is called a buck and the female is a doe; a young rabbit is a kitten or kit.
26 | Dolphins are a widely distributed and diverse group of aquatic mammals. They are an informal grouping within the order Cetacea, excluding whales and porpoises, so to zoologists the grouping is paraphyletic. The dolphins comprise the extant families Delphinidae (the oceanic dolphins), Platanistidae (the Indian river dolphins), Iniidae (the new world river dolphins), and Pontoporiidae (the brackish dolphins), and the extinct Lipotidae (baiji or Chinese river dolphin). There are 40 extant species of dolphins. Dolphins, alongside other cetaceans, belong to the clade Cetartiodactyla with even-toed ungulates. Their closest living relatives are the hippopotamuses, having diverged about 40 million years ago.
27 | Snakes are elongated, legless, carnivorous reptiles of the suborder Serpentes[2] that can be distinguished from legless lizards by their lack of eyelids and external ears. Like all squamates, snakes are ectothermic, amniote vertebrates covered in overlapping scales. Many species of snakes have skulls with several more joints than their lizard ancestors, enabling them to swallow prey much larger than their heads with their highly mobile jaws. To accommodate their narrow bodies, snakes\' paired organs (such as kidneys) appear one in front of the other instead of side by side, and most have only one functional lung. Some species retain a pelvic girdle with a pair of vestigial claws on either side of the cloaca.
28 | Pinnipeds (/ˈpɪnᵻˌpɛdz/) (from Latin pinna "fin" and pes, pedis "foot"[2]), commonly known as seals,[a] are a widely distributed and diverse clade of carnivorous, fin-footed, semiaquatic marine mammals. They comprise the extant families Odobenidae (whose only living member is the walrus), Otariidae (the eared seals: sea lions and fur seals), and Phocidae (the earless seals, or true seals). There are 33 extant species of pinnipeds, and more than 50 extinct species have been described from fossils. While seals were historically thought to have descended from two ancestral lines, molecular evidence supports them as a monophyletic lineage (descended from one ancestral line). Pinnipeds belong to the order Carnivora and their closest living relatives are bears and musteloids (weasels, raccoons, skunks and red pandas), having diverged about 50 million years ago.
29 | A rhinoceros (/raɪˈnɒsərəs/, meaning "nose horn"), often abbreviated to rhino, is one of any five extant species of odd-toed ungulates in the family Rhinocerotidae, as well as any of the numerous extinct species. Two of these extant species are native to Africa and three to Southern Asia./nMembers of the rhinoceros family are characterized by their large size (they are some of the largest remaining megafauna, with all of the species able to reach one tonne or more in weight); as well as by an herbivorous diet; a thick protective skin, 1.5–5 cm thick, formed from layers of collagen positioned in a lattice structure; relatively small brains for mammals this size (400–600 g); and a large horn. They generally eat leafy material, although their ability to ferment food in their hindgut allows them to subsist on more fibrous plant matter, if necessary. Unlike other perissodactyls, the two African species of rhinoceros lack teeth at the front of their mouths, relying instead on their lips to pluck food.
30 | The leopard (Panthera pardus) /ˈlɛpərd/ is one of the five "big cats" in the genus Panthera. It is a member of the family Felidae with a wide range in sub-Saharan Africa and parts of Asia. Fossil records found in Italy suggest that in the Pleistocene it occurred in Europe and Japan. \nCompared to other members of Felidae, the leopard has relatively short legs and a long body with a large skull. It is similar in appearance to the jaguar, but has a smaller, lighter physique. Its fur is marked with rosettes similar to those of the jaguar, but the leopard\'s rosettes are smaller and more densely packed, and do not usually have central spots as the jaguar\'s do. Both leopards and jaguars that are melanistic are known as black panthers.
31 | The common hippopotamus (Hippopotamus amphibius), or hippo, is a large, mostly herbivorous mammal in sub-Saharan Africa, and one of only two extant species in the family Hippopotamidae, the other being the pygmy hippopotamus (Choeropsis liberiensis or Hexaprotodon liberiensis). The name comes from the ancient Greek for "river horse" (ἱπποπόταμος). After the elephant and rhinoceros, the common hippopotamus is the third-largest type of land mammal and the heaviest extant artiodactyl. Despite their physical resemblance to pigs and other terrestrial even-toed ungulates, the closest living relatives of the Hippopotamidae are cetaceans (whales, porpoises, etc.) from which they diverged about 55 million years ago. The common ancestor of whales and hippos split from other even-toed ungulates around 60 million years ago. The earliest known hippopotamus fossils, belonging to the genus Kenyapotamus in Africa, date to around 16 million years ago.
32 | A pig is any of the animals in the genus Sus, within the Suidae family of even-toed ungulates. Pigs include the domestic pig and its ancestor, the common Eurasian wild boar (Sus scrofa), along with other species; related creatures outside the genus include the peccary, the babirusa, and the warthog. Pigs, like all suids, are native to the Eurasian and African continents. Juvenile pigs are known as piglets. Pigs are highly social and intelligent animals.
33 | Starfish or sea stars are star-shaped echinoderms belonging to the class Asteroidea. Common usage frequently finds these names being also applied to ophiuroids, which are correctly referred to as brittle stars or "basket stars". About 1,500 species of starfish occur on the seabed in all the world\'s oceans, from the tropics to frigid polar waters. They are found from the intertidal zone down to abyssal depths, 6,000 m (20,000 ft) below the surface.
34 | Owls are birds from the order Strigiformes, which includes about 200 species of mostly solitary and nocturnal birds of prey typified by an upright stance, a large, broad head, binocular vision, binaural hearing, sharp talons, and feathers adapted for silent flight. Exceptions include the diurnal northern hawk-owl and the gregarious burrowing owl.
35 |
36 | Activity to Activity
37 | Fragment to Fragment
38 | Picasso Activity to Activity
39 | Picasso Fragment to Fragment
40 | Glide Activity to Activity
41 | Glide Fragment to Fragment
42 | RecyclerView to Activity
43 | RecyclerView to Fragment
44 | RecyclerView to ViewPager
45 | Programmatic Flash Fix Activity
46 | XML Flash Fix Activity
47 |
--------------------------------------------------------------------------------