├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ └── ic_menu.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── ic_menu.png
│ │ │ ├── drawable-nodpi
│ │ │ │ ├── cheese_1.jpg
│ │ │ │ ├── cheese_2.jpg
│ │ │ │ ├── cheese_3.jpg
│ │ │ │ ├── cheese_4.jpg
│ │ │ │ └── cheese_5.jpg
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── ic_menu.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_menu.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── themes.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── material_design_colors.xml
│ │ │ ├── transition
│ │ │ │ ├── cheeses_exit.xml
│ │ │ │ ├── cheeses_enter.xml
│ │ │ │ ├── cheese_detail_shared_element_enter.xml
│ │ │ │ └── cheese_detail_shared_element_exit.xml
│ │ │ ├── layout
│ │ │ │ ├── cheese_row.xml
│ │ │ │ ├── activity_cheeses.xml
│ │ │ │ ├── activity_cheese_detail.xml
│ │ │ │ ├── cheeses_toolbar.xml
│ │ │ │ ├── cheese_details_toolbar.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── fragment_cheeses.xml
│ │ │ │ ├── nav_header.xml
│ │ │ │ └── fragment_cheese_details.xml
│ │ │ └── menu
│ │ │ │ └── drawer_view.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── etiennelawlor
│ │ │ └── sharedelementtransition
│ │ │ ├── activities
│ │ │ ├── CheesesActivity.java
│ │ │ ├── CheeseDetailsActivity.java
│ │ │ └── MainActivity.java
│ │ │ ├── fragments
│ │ │ ├── CheeseDetailsFragment.java
│ │ │ └── CheesesFragment.java
│ │ │ └── adapters
│ │ │ └── CheesesAdapter.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── etiennelawlor
│ │ │ └── sharedelementtransition
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── etiennelawlor
│ │ └── sharedelementtransition
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── images
├── cheeses.png
└── cheese_details.png
├── gradle
└── wrapper
│ └── gradle-wrapper.properties
├── README.md
├── .gitignore
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/images/cheeses.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/images/cheeses.png
--------------------------------------------------------------------------------
/images/cheese_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/images/cheese_details.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-hdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-mdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/cheese_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-nodpi/cheese_1.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/cheese_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-nodpi/cheese_2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/cheese_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-nodpi/cheese_3.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/cheese_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-nodpi/cheese_4.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/cheese_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-nodpi/cheese_5.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-xhdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/drawable-xxhdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawloretienne/SharedElementTransition/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 256dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/transition/cheeses_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/transition/cheeses_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/cheese_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SharedElementTransition
2 | Demonstrates SharedElementTransitions
3 |
4 |
5 | Cheeses | Cheese Details
6 | :-------------------------:|:-------------------------:
7 |  | 
8 |
--------------------------------------------------------------------------------
/app/src/test/java/com/etiennelawlor/sharedelementtransition/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.etiennelawlor.sharedelementtransition;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_cheeses.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_cheese_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/etiennelawlor/sharedelementtransition/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.etiennelawlor.sharedelementtransition;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/drawer_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/transition/cheese_detail_shared_element_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/transition/cheese_detail_shared_element_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
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/etiennelawlor/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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/cheeses_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/cheese_details_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
15 |
16 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_cheeses.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
16 |
17 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.etiennelawlor.sharedelementtransition"
9 | minSdkVersion 21
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | ext {
23 | supportLibVersion = '23.4.0'
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | testCompile 'junit:junit:4.12'
29 |
30 | compile "com.android.support:design:${supportLibVersion}"
31 | compile "com.android.support:support-v4:${supportLibVersion}"
32 | compile "com.android.support:appcompat-v7:${supportLibVersion}"
33 | compile "com.android.support:cardview-v7:${supportLibVersion}"
34 | compile "com.android.support:recyclerview-v7:${supportLibVersion}"
35 |
36 | compile 'com.squareup.picasso:picasso:2.5.2'
37 | compile 'com.jakewharton:butterknife:7.0.1'
38 |
39 | compile 'de.hdodenhof:circleimageview:2.0.0'
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
25 |
26 |
27 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # [Android] ========================
2 | # Built application files
3 | *.apk
4 | *.ap_
5 |
6 | # Files for the Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 | # Generated files
13 | bin/
14 | gen/
15 |
16 | # Gradle files
17 | .gradle
18 | .gradle/
19 | build/
20 | /build
21 |
22 | # Local configuration file (sdk path, etc)
23 | /local.properties
24 | local.properties
25 |
26 | # Proguard folder generated by Eclipse
27 | proguard/
28 |
29 | # Log Files
30 | *.log
31 |
32 |
33 | ## Directory-based project format:
34 | .idea/
35 |
36 | ## File-based project format:
37 | *.ipr
38 | *.iws
39 |
40 | ## Plugin-specific files:
41 |
42 | # IntelliJ
43 | out/
44 |
45 | # mpeltonen/sbt-idea plugin
46 | .idea_modules/
47 |
48 | # JIRA plugin
49 | atlassian-ide-plugin.xml
50 |
51 | # Crashlytics plugin (for Android Studio and IntelliJ)
52 | com_crashlytics_export_strings.xml
53 |
54 | # Fabric
55 | fabric.properties
56 |
57 | # xml files
58 | defaults.xml
59 |
60 | # [Maven] ========================
61 | target/
62 | pom.xml.tag
63 | pom.xml.releaseBackup
64 | pom.xml.versionsBackup
65 | pom.xml.next
66 | release.properties
67 |
68 |
69 | # [Gradle-Android] ========================
70 | gradle.properties
71 |
72 | # Ignore Gradle GUI config
73 | gradle-app.setting
74 |
75 | # Gradle Signing
76 | signing.properties
77 | loop.keystore
78 |
79 | # Mobile Tools for Java (J2ME)
80 | .mtj.tmp/
81 |
82 | # Package Files #
83 | *.jar
84 | *.war
85 | *.ear
86 |
87 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
88 | hs_err_pid*
89 |
90 | # Misc
91 | /.idea/workspace.xml
92 | /.idea/libraries
93 | .DS_Store
94 | /captures
95 | **/*.iml
96 | *.iml
97 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #993F51B5
8 |
9 | #0Dffffff
10 | #1Affffff
11 | #33ffffff
12 | #4Dffffff
13 | #80ffffff
14 | #99ffffff
15 | #B3ffffff
16 | #CCffffff
17 | #E6ffffff
18 | #F2ffffff
19 |
20 | #0D000000
21 | #1A000000
22 | #33000000
23 | #66000000
24 | #80000000
25 | #99000000
26 | #B3000000
27 | #CC000000
28 | #E6000000
29 | #F2000000
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/etiennelawlor/sharedelementtransition/activities/CheesesActivity.java:
--------------------------------------------------------------------------------
1 | package com.etiennelawlor.sharedelementtransition.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.MenuItem;
7 |
8 | import com.etiennelawlor.sharedelementtransition.R;
9 | import com.etiennelawlor.sharedelementtransition.fragments.CheesesFragment;
10 |
11 | import butterknife.ButterKnife;
12 |
13 | /**
14 | * Created by etiennelawlor on 4/27/16.
15 | */
16 | public class CheesesActivity extends AppCompatActivity {
17 |
18 | // region Lifecycle Methods
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_cheeses);
23 | ButterKnife.bind(this);
24 |
25 | Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
26 | if (fragment == null) {
27 | fragment = CheesesFragment.newInstance(getIntent().getExtras());
28 | getSupportFragmentManager()
29 | .beginTransaction()
30 | .replace(android.R.id.content, fragment, "")
31 | .commit();
32 | } else {
33 | getSupportFragmentManager()
34 | .beginTransaction()
35 | .attach(fragment)
36 | .commit();
37 | }
38 | }
39 | // endregion
40 |
41 | @Override
42 | public boolean onOptionsItemSelected(MenuItem item) {
43 | switch (item.getItemId()) {
44 | // Respond to the action bar's Up/Home button
45 | case android.R.id.home:
46 | supportFinishAfterTransition();
47 | // NavUtils.navigateUpFromSameTask(this);
48 | return true;
49 | }
50 | return super.onOptionsItemSelected(item);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/etiennelawlor/sharedelementtransition/activities/CheeseDetailsActivity.java:
--------------------------------------------------------------------------------
1 | package com.etiennelawlor.sharedelementtransition.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.MenuItem;
7 |
8 | import com.etiennelawlor.sharedelementtransition.R;
9 | import com.etiennelawlor.sharedelementtransition.fragments.CheeseDetailsFragment;
10 |
11 | import butterknife.ButterKnife;
12 |
13 | /**
14 | * Created by etiennelawlor on 4/27/16.
15 | */
16 | public class CheeseDetailsActivity extends AppCompatActivity {
17 |
18 | // region Lifecycle Methods
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_cheese_detail);
23 | ButterKnife.bind(this);
24 |
25 | Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
26 | if (fragment == null) {
27 | fragment = CheeseDetailsFragment.newInstance(getIntent().getExtras());
28 | getSupportFragmentManager()
29 | .beginTransaction()
30 | .replace(android.R.id.content, fragment, "")
31 | .commit();
32 | } else {
33 | getSupportFragmentManager()
34 | .beginTransaction()
35 | .attach(fragment)
36 | .commit();
37 | }
38 | }
39 | // endregion
40 |
41 | @Override
42 | public boolean onOptionsItemSelected(MenuItem item) {
43 | switch (item.getItemId()) {
44 | // Respond to the action bar's Up/Home button
45 | case android.R.id.home:
46 | supportFinishAfterTransition();
47 | // NavUtils.navigateUpFromSameTask(this);
48 | return true;
49 | }
50 | return super.onOptionsItemSelected(item);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
15 |
21 |
22 |
23 |
28 |
29 |
39 |
40 |
--------------------------------------------------------------------------------
/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/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SharedElementTransition
3 | Cheeses
4 |
5 |
6 | transition_cheese_thumbnail
7 | status_bar
8 | nav_bar
9 |
10 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam finibus tortor ut nulla maximus molestie. Phasellus a turpis volutpat, egestas ex nec, laoreet sem. Vivamus aliquet felis ac urna semper accumsan. Curabitur placerat nulla vitae lacus hendrerit viverra. Duis ullamcorper mauris eget sollicitudin consectetur. Interdum et malesuada fames ac ante ipsum primis in faucibus. Cras ut elit et ante dapibus rhoncus. Vivamus libero nisi, consectetur bibendum diam ut, tempus pulvinar lorem. Nam tempus erat est, consequat mattis odio feugiat luctus. Suspendisse eu vulputate dui, laoreet pharetra orci. Suspendisse dolor diam, aliquet et gravida et, maximus non orci. Nullam fermentum sed orci varius hendrerit. Suspendisse eu nulla id turpis rhoncus interdum sed ac dolor. Vestibulum tincidunt interdum neque eu pharetra. Sed imperdiet blandit magna, vel semper orci molestie id. Maecenas non eros non nisi placerat finibus vitae non diam.
11 |
12 | Morbi congue, est id efficitur sodales, felis ex dictum quam, sit amet dignissim ante ipsum id felis. Sed scelerisque ex dolor, sed elementum dui semper nec. Nullam non viverra justo. Donec ac libero quam. Nulla facilisi. Nullam dignissim lacinia eros sed mollis. Nullam et velit a risus blandit molestie id et quam. Nam rutrum purus id mi finibus auctor. Nunc tempus consectetur sapien et porttitor.
13 |
14 | Praesent viverra id neque sit amet aliquam. Nunc interdum dui eu feugiat lacinia. Proin hendrerit lorem augue, et sagittis libero semper nec. Donec et consectetur lacus. Sed lobortis porta sollicitudin. Fusce luctus at ante ac dignissim. Proin vehicula leo vehicula nunc gravida dapibus. Vestibulum volutpat rutrum molestie. Nunc vitae risus sed quam bibendum rhoncus id ac quam. Aenean id diam pulvinar, sodales odio sit amet, iaculis massa.
15 |
16 | Sed consequat tincidunt sapien id commodo. Praesent vestibulum finibus leo quis rhoncus. Cras eget fermentum neque. Donec gravida vulputate quam eu efficitur. Aliquam in iaculis velit. Vivamus a ligula ac elit luctus condimentum. Donec accumsan turpis lectus, quis commodo dui pharetra sit amet. Nam eget blandit velit. Suspendisse dolor velit, luctus sed euismod id, sodales et lacus. Proin lacinia efficitur ultricies. Fusce egestas elit elit, et pellentesque dolor aliquam eget. Maecenas non orci eu nisl sollicitudin bibendum. Duis lectus arcu, aliquam sit amet gravida vitae, cursus vehicula leo.
17 |
18 | Donec a risus quis ex fringilla convallis. Nam elit elit, suscipit vitae tempus vitae, aliquam et ipsum. Vestibulum volutpat tortor tortor. Vestibulum auctor sollicitudin purus, eu laoreet urna ultricies hendrerit. Duis ut mauris in sapien aliquam eleifend eget eu turpis. Integer lacus elit, rutrum quis sapien non, consequat dignissim erat. Fusce sit amet luctus leo, quis feugiat nulla. Sed vulputate tortor ut felis hendrerit, sit amet maximus enim aliquam. Vestibulum fermentum venenatis justo, non gravida arcu venenatis in. Donec ut porta ipsum. Sed bibendum, ex sit amet tempor eleifend, purus tellus dictum nulla, quis ultrices quam mi vel ligula. Maecenas non posuere lorem, a tincidunt ex.
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
28 |
29 |
33 |
34 |
44 |
45 |
57 |
58 |
66 |
67 |
68 |
69 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_cheese_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
27 |
28 |
29 |
30 |
36 |
37 |
38 |
39 |
46 |
47 |
48 |
49 |
55 |
56 |
57 |
58 |
59 |
60 |
68 |
69 |
74 |
75 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/etiennelawlor/sharedelementtransition/fragments/CheeseDetailsFragment.java:
--------------------------------------------------------------------------------
1 | package com.etiennelawlor.sharedelementtransition.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.AppBarLayout;
5 | import android.support.design.widget.CollapsingToolbarLayout;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v7.app.ActionBar;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.text.TextUtils;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.ImageView;
15 |
16 | import com.etiennelawlor.sharedelementtransition.R;
17 | import com.squareup.picasso.Picasso;
18 |
19 | import butterknife.Bind;
20 | import butterknife.ButterKnife;
21 |
22 | /**
23 | * Created by etiennelawlor on 4/27/16.
24 | */
25 | public class CheeseDetailsFragment extends Fragment {
26 |
27 |
28 | // region Views
29 | @Bind(R.id.toolbar)
30 | Toolbar toolbar;
31 | @Bind(R.id.collapsing_toolbar)
32 | CollapsingToolbarLayout collapsingToolbarLayout;
33 | @Bind(R.id.appbar)
34 | AppBarLayout appBarLayout;
35 | @Bind(R.id.iv)
36 | ImageView imageView;
37 | // endregion
38 |
39 | // region Member Variables
40 | private ActionBar actionBar;
41 | private Integer cheese;
42 | // endregion
43 |
44 | // region Constructors
45 | public CheeseDetailsFragment() {
46 | }
47 | // endregion
48 |
49 | // region Factory Methods
50 | public static CheeseDetailsFragment newInstance() {
51 | return new CheeseDetailsFragment();
52 | }
53 |
54 | public static CheeseDetailsFragment newInstance(Bundle extras) {
55 | CheeseDetailsFragment fragment = new CheeseDetailsFragment();
56 | fragment.setArguments(extras);
57 | return fragment;
58 | }
59 | // endregion
60 |
61 | // region Lifecycle Methods
62 |
63 | @Override
64 | public void onCreate(Bundle savedInstanceState) {
65 | super.onCreate(savedInstanceState);
66 |
67 | if (getArguments() != null) {
68 | cheese = getArguments().getInt("cheese");
69 | }
70 |
71 | setHasOptionsMenu(true);
72 | }
73 |
74 | @Override
75 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
76 | Bundle savedInstanceState) {
77 | View rootView = inflater.inflate(R.layout.fragment_cheese_details, container, false);
78 | ButterKnife.bind(this, rootView);
79 |
80 | return rootView;
81 | }
82 |
83 | @Override
84 | public void onViewCreated(View view, Bundle savedInstanceState) {
85 | super.onViewCreated(view, savedInstanceState);
86 |
87 | ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
88 |
89 | actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
90 | if (actionBar != null) {
91 | actionBar.setDisplayHomeAsUpEnabled(true);
92 | setCollapsingToolbarTitle("");
93 | }
94 |
95 | setUpImage(imageView, cheese);
96 | }
97 |
98 | @Override
99 | public void onDestroyView() {
100 | super.onDestroyView();
101 | ButterKnife.unbind(this);
102 | }
103 | // endregion
104 |
105 | // region Helper Methods
106 | private void setUpImage(ImageView iv, int cheese){
107 |
108 | int cheeseDrawable = 0;
109 | switch (cheese){
110 | case 0:
111 | cheeseDrawable = R.drawable.cheese_1;
112 | break;
113 | case 1:
114 | cheeseDrawable = R.drawable.cheese_2;
115 | break;
116 | case 2:
117 | cheeseDrawable = R.drawable.cheese_3;
118 | break;
119 | case 3:
120 | cheeseDrawable = R.drawable.cheese_4;
121 | break;
122 | case 4:
123 | cheeseDrawable = R.drawable.cheese_5;
124 | break;
125 | }
126 |
127 | Picasso.with(iv.getContext())
128 | .load(cheeseDrawable)
129 | .into(iv);
130 | }
131 |
132 | private void setCollapsingToolbarTitle(String title) {
133 | if (!TextUtils.isEmpty(title)) {
134 | collapsingToolbarLayout.setTitle(title);
135 | } else {
136 | collapsingToolbarLayout.setTitle("");
137 | }
138 | }
139 |
140 | // endregion
141 |
142 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/etiennelawlor/sharedelementtransition/activities/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.etiennelawlor.sharedelementtransition.activities;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Typeface;
5 | import android.os.Bundle;
6 | import android.support.design.widget.NavigationView;
7 | import android.support.v4.view.GravityCompat;
8 | import android.support.v4.widget.DrawerLayout;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.util.Log;
11 | import android.view.Gravity;
12 | import android.view.LayoutInflater;
13 | import android.view.MenuItem;
14 | import android.view.View;
15 | import android.view.Window;
16 |
17 | import com.etiennelawlor.sharedelementtransition.R;
18 | import com.etiennelawlor.sharedelementtransition.fragments.CheesesFragment;
19 |
20 | import butterknife.Bind;
21 | import butterknife.ButterKnife;
22 |
23 | /**
24 | * Created by etiennelawlor on 4/28/16.
25 | */
26 | public class MainActivity extends AppCompatActivity {
27 |
28 | // region Constants
29 | private static final String CHEESES_FRAGMENT = "CheesesFragment";
30 | private static final String CHEESES_ACTIVITY = "CheesesActivity";
31 | // endregion
32 |
33 | // region Views
34 | @Bind(R.id.drawer_layout)
35 | DrawerLayout drawerLayout;
36 | @Bind(R.id.nav_view)
37 | NavigationView navigationView;
38 | // endregion
39 |
40 | // region Member Variables
41 | private Typeface font;
42 | // endregion
43 |
44 | // region Listeners
45 | private NavigationView.OnNavigationItemSelectedListener navigationViewOnNavigationItemSelectedListener
46 | = new NavigationView.OnNavigationItemSelectedListener() {
47 | @Override
48 | public boolean onNavigationItemSelected(MenuItem menuItem) {
49 | drawerLayout.closeDrawers();
50 |
51 | String title = menuItem.getTitle().toString();
52 | switch (title) {
53 | case CHEESES_FRAGMENT:
54 | menuItem.setChecked(true);
55 | getSupportFragmentManager()
56 | .beginTransaction()
57 | .replace(R.id.content_fl, CheesesFragment.newInstance(), "")
58 | .commit();
59 | break;
60 | case CHEESES_ACTIVITY:
61 | Intent intent = new Intent(MainActivity.this, CheesesActivity.class);
62 | intent.putExtra("up_nav", true);
63 | startActivity(intent);
64 | break;
65 | default:
66 | break;
67 | }
68 | return true;
69 | }
70 | };
71 |
72 | // endregion
73 |
74 | // region Lifecycle Methods
75 | @Override
76 | protected void onCreate(Bundle savedInstanceState) {
77 | super.onCreate(savedInstanceState);
78 | setContentView(R.layout.activity_main);
79 | ButterKnife.bind(this);
80 |
81 | View header = LayoutInflater.from(this).inflate(R.layout.nav_header, null);
82 | navigationView.addHeaderView(header);
83 |
84 | // Setup NavigationView
85 | navigationView.setNavigationItemSelectedListener(navigationViewOnNavigationItemSelectedListener);
86 |
87 | getSupportFragmentManager()
88 | .beginTransaction()
89 | .replace(R.id.content_fl, CheesesFragment.newInstance(), "")
90 | .commit();
91 |
92 | }
93 |
94 | @Override
95 | protected void onResume() {
96 | super.onResume();
97 |
98 | Window window = getWindow();
99 | window.setStatusBarColor(getResources().getColor(R.color.five_percent_transparency_black));
100 | }
101 |
102 | // endregion
103 |
104 | @Override
105 | public boolean onOptionsItemSelected(MenuItem item) {
106 | switch (item.getItemId()) {
107 | case android.R.id.home:
108 | drawerLayout.openDrawer(GravityCompat.START);
109 | return true;
110 | }
111 | return super.onOptionsItemSelected(item);
112 | }
113 |
114 | @Override
115 | public void onBackPressed() {
116 | if (drawerLayout.isDrawerOpen(Gravity.LEFT)) {
117 | drawerLayout.closeDrawer(Gravity.LEFT);
118 | } else {
119 | super.onBackPressed();
120 | }
121 | }
122 |
123 | @Override
124 | public void setTitle(CharSequence title) {
125 | if (getSupportActionBar() != null) {
126 | getSupportActionBar().setTitle(title);
127 | }
128 | }
129 | }
--------------------------------------------------------------------------------
/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/etiennelawlor/sharedelementtransition/adapters/CheesesAdapter.java:
--------------------------------------------------------------------------------
1 | package com.etiennelawlor.sharedelementtransition.adapters;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.util.Log;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 |
10 | import com.etiennelawlor.sharedelementtransition.R;
11 | import com.squareup.picasso.Picasso;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import butterknife.Bind;
17 | import butterknife.ButterKnife;
18 |
19 | /**
20 | * Created by etiennelawlor on 4/27/16.
21 | */
22 | public class CheesesAdapter extends RecyclerView.Adapter {
23 |
24 | // region Constants
25 | private static final int ITEM = 1;
26 | // endregion
27 |
28 | // region Member Variables
29 | private List cheeses;
30 | private OnItemClickListener onItemClickListener;
31 | // endregion
32 |
33 | // region Interfaces
34 | public interface OnItemClickListener {
35 | void onItemClick(int position, View view);
36 | }
37 | // endregion
38 |
39 | // region Constructors
40 | public CheesesAdapter() {
41 | cheeses = new ArrayList<>();
42 | }
43 | // endregion
44 |
45 | @Override
46 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
47 | RecyclerView.ViewHolder viewHolder = null;
48 |
49 | switch (viewType) {
50 | case ITEM:
51 | viewHolder = createCheeseViewHolder(parent);
52 | break;
53 | default:
54 | Log.e("", String.format("[ERR] type is not supported!!! type is %d", viewType));
55 | break;
56 | }
57 |
58 | return viewHolder;
59 | }
60 |
61 | @Override
62 | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
63 | switch (getItemViewType(position)) {
64 | case ITEM:
65 | bindCheeseViewHolder(viewHolder, position);
66 | break;
67 | default:
68 | break;
69 | }
70 | }
71 |
72 | @Override
73 | public int getItemCount() {
74 | return cheeses.size();
75 | }
76 |
77 | @Override
78 | public int getItemViewType(int position) {
79 | // return (position == venues.size()-1 && isLoadingFooterAdded) ? LOADING : ITEM;
80 | return ITEM;
81 | }
82 |
83 | // region Helper Methods
84 |
85 | private RecyclerView.ViewHolder createCheeseViewHolder(ViewGroup parent) {
86 | // create a new view
87 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.cheese_row, parent, false);
88 |
89 | final CheeseViewHolder holder = new CheeseViewHolder(v);
90 |
91 | holder.itemView.setOnClickListener(new View.OnClickListener() {
92 | @Override
93 | public void onClick(View v) {
94 | int adapterPos = holder.getAdapterPosition();
95 | if (adapterPos != RecyclerView.NO_POSITION) {
96 | if (onItemClickListener != null) {
97 | onItemClickListener.onItemClick(adapterPos, holder.itemView);
98 | }
99 | }
100 | }
101 | });
102 |
103 | return holder;
104 | }
105 |
106 | private void bindCheeseViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
107 | final CheeseViewHolder holder = (CheeseViewHolder) viewHolder;
108 |
109 | final int cheese = cheeses.get(position);
110 | setUpImage(holder.imageView, cheese);
111 | }
112 |
113 | private void add(int item) {
114 | cheeses.add(item);
115 | notifyItemInserted(cheeses.size() - 1);
116 | }
117 |
118 | public void addAll(List cheeses) {
119 | for (Integer cheese : cheeses) {
120 | add(cheese);
121 | }
122 | }
123 |
124 | public void remove(Integer item) {
125 | int position = cheeses.indexOf(item);
126 | if (position > -1) {
127 | cheeses.remove(position);
128 | notifyItemRemoved(position);
129 | }
130 | }
131 |
132 | public Integer getItem(int position) {
133 | return cheeses.get(position);
134 | }
135 |
136 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
137 | this.onItemClickListener = onItemClickListener;
138 | }
139 |
140 | private void setUpImage(ImageView iv, int cheese){
141 |
142 | int cheeseDrawable = 0;
143 | switch (cheese){
144 | case 0:
145 | cheeseDrawable = R.drawable.cheese_1;
146 | break;
147 | case 1:
148 | cheeseDrawable = R.drawable.cheese_2;
149 | break;
150 | case 2:
151 | cheeseDrawable = R.drawable.cheese_3;
152 | break;
153 | case 3:
154 | cheeseDrawable = R.drawable.cheese_4;
155 | break;
156 | case 4:
157 | cheeseDrawable = R.drawable.cheese_5;
158 | break;
159 | }
160 |
161 | Picasso.with(iv.getContext())
162 | .load(cheeseDrawable)
163 | .into(iv);
164 | }
165 |
166 | // endregion
167 |
168 | // region Inner Classes
169 |
170 | public static class CheeseViewHolder extends RecyclerView.ViewHolder {
171 | // region Views
172 | @Bind(R.id.iv)
173 | ImageView imageView;
174 | // endregion
175 |
176 | // region Constructors
177 | public CheeseViewHolder(View view) {
178 | super(view);
179 | ButterKnife.bind(this, view);
180 | }
181 | // endregion
182 | }
183 |
184 | // endregion
185 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/etiennelawlor/sharedelementtransition/fragments/CheesesFragment.java:
--------------------------------------------------------------------------------
1 | package com.etiennelawlor.sharedelementtransition.fragments;
2 |
3 | import android.content.Intent;
4 | import android.content.res.Resources;
5 | import android.os.Bundle;
6 | import android.support.v4.app.ActivityCompat;
7 | import android.support.v4.app.ActivityOptionsCompat;
8 | import android.support.v4.app.Fragment;
9 | import android.support.v4.util.Pair;
10 | import android.support.v7.app.ActionBar;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.support.v7.widget.LinearLayoutManager;
13 | import android.support.v7.widget.RecyclerView;
14 | import android.support.v7.widget.Toolbar;
15 | import android.util.Log;
16 | import android.view.LayoutInflater;
17 | import android.view.View;
18 | import android.view.ViewGroup;
19 | import android.view.Window;
20 |
21 | import com.etiennelawlor.sharedelementtransition.R;
22 | import com.etiennelawlor.sharedelementtransition.activities.CheeseDetailsActivity;
23 | import com.etiennelawlor.sharedelementtransition.adapters.CheesesAdapter;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | import butterknife.Bind;
29 | import butterknife.ButterKnife;
30 |
31 | /**
32 | * Created by etiennelawlor on 4/27/16.
33 | */
34 | public class CheesesFragment extends Fragment implements CheesesAdapter.OnItemClickListener {
35 |
36 | // region Views
37 | @Bind(R.id.rv)
38 | RecyclerView recyclerView;
39 | @Bind(R.id.toolbar)
40 | Toolbar toolbar;
41 | // endregion
42 |
43 | // region Member Variables
44 | private CheesesAdapter cheesesAdapter;
45 | private LinearLayoutManager layoutManager;
46 | private boolean upNav;
47 | // endregion
48 |
49 | // region Constructors
50 | public CheesesFragment() {
51 | }
52 | // endregion
53 |
54 | // region Factory Methods
55 | public static CheesesFragment newInstance() {
56 | return new CheesesFragment();
57 | }
58 |
59 | public static CheesesFragment newInstance(Bundle extras) {
60 | CheesesFragment fragment = new CheesesFragment();
61 | fragment.setArguments(extras);
62 | return fragment;
63 | }
64 | // endregion
65 |
66 | // region Lifecycle Methods
67 |
68 | @Override
69 | public void onCreate(Bundle savedInstanceState) {
70 | super.onCreate(savedInstanceState);
71 |
72 | if(getArguments() != null){
73 | upNav = getArguments().getBoolean("up_nav");
74 | }
75 |
76 | setHasOptionsMenu(true);
77 |
78 |
79 | }
80 |
81 | @Override
82 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
83 | Bundle savedInstanceState) {
84 | View rootView = inflater.inflate(R.layout.fragment_cheeses, container, false);
85 | ButterKnife.bind(this, rootView);
86 |
87 | return rootView;
88 | }
89 |
90 | @Override
91 | public void onViewCreated(View view, Bundle savedInstanceState) {
92 | super.onViewCreated(view, savedInstanceState);
93 |
94 | ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
95 |
96 | final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
97 | if (ab != null) {
98 | ab.setDisplayHomeAsUpEnabled(true);
99 | ab.setTitle(getString(R.string.cheeses));
100 |
101 | if(!upNav){
102 | ab.setHomeAsUpIndicator(R.drawable.ic_menu);
103 | }
104 | }
105 |
106 | layoutManager = new LinearLayoutManager(getActivity());
107 | recyclerView.setLayoutManager(layoutManager);
108 | cheesesAdapter = new CheesesAdapter();
109 | cheesesAdapter.setOnItemClickListener(this);
110 |
111 | // recyclerView.setItemAnimator(new SlideInUpAnimator());
112 | recyclerView.setAdapter(cheesesAdapter);
113 |
114 | List cheeses = new ArrayList<>();
115 | cheeses.add(0);
116 | cheeses.add(1);
117 | cheeses.add(2);
118 | cheeses.add(3);
119 | cheeses.add(4);
120 |
121 | cheesesAdapter.addAll(cheeses);
122 | }
123 |
124 | @Override
125 | public void onDestroyView() {
126 | super.onDestroyView();
127 | ButterKnife.unbind(this);
128 | }
129 | // endregion
130 |
131 | // region CheesesAdapter.OnItemClickListener Methods
132 | @Override
133 | public void onItemClick(int position, View view) {
134 | Integer cheese = cheesesAdapter.getItem(position);
135 |
136 |
137 | Intent intent = new Intent(getActivity(), CheeseDetailsActivity.class);
138 | Bundle bundle = new Bundle();
139 | bundle.putInt("cheese", cheese);
140 | intent.putExtras(bundle);
141 |
142 | View venueThumbnailImageView = view.findViewById(R.id.iv);
143 | Resources resources = view.getResources();
144 |
145 | Pair p1 = Pair.create(venueThumbnailImageView, resources.getString(R.string.transition_cheese_thumbnail));
146 |
147 | Window window = getActivity().getWindow();
148 | window.setStatusBarColor(getResources().getColor(R.color.primary_dark));
149 |
150 | View decor = window.getDecorView();
151 | View statusBar = decor.findViewById(android.R.id.statusBarBackground);
152 | View navBar = decor.findViewById(android.R.id.navigationBarBackground);
153 | // View actionBar = decor.findViewById(getResources().getIdentifier(
154 | // "action_bar_container", "id", "android"));
155 |
156 | Pair p2 = Pair.create(statusBar, resources.getString(R.string.transition_status_bar));
157 | Pair p3 = Pair.create(navBar, resources.getString(R.string.transition_nav_bar));
158 |
159 | ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
160 | p1, p2, p3);
161 |
162 | ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
163 | //// startActivity(intent);
164 |
165 | }
166 | // endregion
167 | }
168 |
--------------------------------------------------------------------------------
/app/src/main/res/values/material_design_colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #fde0dc
6 | #f9bdbb
7 | #f69988
8 | #f36c60
9 | #e84e40
10 | #e51c23
11 | #dd191d
12 | #d01716
13 | #c41411
14 | #b0120a
15 | #ff7997
16 | #ff5177
17 | #ff2d6f
18 | #e00032
19 |
20 | #fce4ec
21 | #f8bbd0
22 | #f48fb1
23 | #f06292
24 | #ec407a
25 | #e91e63
26 | #d81b60
27 | #c2185b
28 | #ad1457
29 | #880e4f
30 | #ff80ab
31 | #ff4081
32 | #f50057
33 | #c51162
34 |
35 | #f3e5f5
36 | #e1bee7
37 | #ce93d8
38 | #ba68c8
39 | #ab47bc
40 | #9c27b0
41 | #8e24aa
42 | #7b1fa2
43 | #6a1b9a
44 | #4a148c
45 | #ea80fc
46 | #e040fb
47 | #d500f9
48 | #aa00ff
49 |
50 | #ede7f6
51 | #d1c4e9
52 | #b39ddb
53 | #9575cd
54 | #7e57c2
55 | #673ab7
56 | #5e35b1
57 | #512da8
58 | #4527a0
59 | #311b92
60 | #b388ff
61 | #7c4dff
62 | #651fff
63 | #6200ea
64 |
65 | #e8eaf6
66 | #c5cae9
67 | #9fa8da
68 | #7986cb
69 | #5c6bc0
70 | #3f51b5
71 | #3949ab
72 | #303f9f
73 | #283593
74 | #1a237e
75 | #8c9eff
76 | #536dfe
77 | #3d5afe
78 | #304ffe
79 |
80 | #e7e9fd
81 | #d0d9ff
82 | #afbfff
83 | #91a7ff
84 | #738ffe
85 | #5677fc
86 | #4e6cef
87 | #455ede
88 | #3b50ce
89 | #2a36b1
90 | #a6baff
91 | #6889ff
92 | #4d73ff
93 | #4d69ff
94 |
95 | #e1f5fe
96 | #b3e5fc
97 | #81d4fa
98 | #4fc3f7
99 | #29b6f6
100 | #03a9f4
101 | #039be5
102 | #0288d1
103 | #0277bd
104 | #01579b
105 | #80d8ff
106 | #40c4ff
107 | #00b0ff
108 | #0091ea
109 |
110 | #e0f7fa
111 | #b2ebf2
112 | #80deea
113 | #4dd0e1
114 | #26c6da
115 | #00bcd4
116 | #00acc1
117 | #0097a7
118 | #00838f
119 | #006064
120 | #84ffff
121 | #18ffff
122 | #00e5ff
123 | #00b8d4
124 |
125 | #e0f2f1
126 | #b2dfdb
127 | #80cbc4
128 | #4db6ac
129 | #26a69a
130 | #009688
131 | #00897b
132 | #00796b
133 | #00695c
134 | #004d40
135 | #a7ffeb
136 | #64ffda
137 | #1de9b6
138 | #00bfa5
139 |
140 | #d0f8ce
141 | #a3e9a4
142 | #72d572
143 | #42bd41
144 | #2baf2b
145 | #259b24
146 | #0a8f08
147 | #0a7e07
148 | #056f00
149 | #0d5302
150 | #a2f78d
151 | #5af158
152 | #14e715
153 | #12c700
154 |
155 | #f1f8e9
156 | #dcedc8
157 | #c5e1a5
158 | #aed581
159 | #9ccc65
160 | #8bc34a
161 | #7cb342
162 | #689f38
163 | #558b2f
164 | #33691e
165 | #ccff90
166 | #b2ff59
167 | #76ff03
168 | #64dd17
169 |
170 | #f9fbe7
171 | #f0f4c3
172 | #e6ee9c
173 | #dce775
174 | #d4e157
175 | #cddc39
176 | #c0ca33
177 | #afb42b
178 | #9e9d24
179 | #827717
180 | #f4ff81
181 | #eeff41
182 | #c6ff00
183 | #aeea00
184 |
185 | #fffde7
186 | #fff9c4
187 | #fff59d
188 | #fff176
189 | #ffee58
190 | #ffeb3b
191 | #fdd835
192 | #fbc02d
193 | #f9a825
194 | #f57f17
195 | #ffff8d
196 | #ffff00
197 | #ffea00
198 | #ffd600
199 |
200 | #fff8e1
201 | #ffecb3
202 | #ffe082
203 | #ffd54f
204 | #ffca28
205 | #ffc107
206 | #ffb300
207 | #ffa000
208 | #ff8f00
209 | #ff6f00
210 | #ffe57f
211 | #ffd740
212 | #ffc400
213 | #ffab00
214 |
215 | #fff3e0
216 | #ffe0b2
217 | #ffcc80
218 | #ffb74d
219 | #ffa726
220 | #ff9800
221 | #fb8c00
222 | #f57c00
223 | #ef6c00
224 | #e65100
225 | #ffd180
226 | #ffab40
227 | #ff9100
228 | #ff6d00
229 |
230 | #fbe9e7
231 | #ffccbc
232 | #ffab91
233 | #ff8a65
234 | #ff7043
235 | #ff5722
236 | #f4511e
237 | #e64a19
238 | #d84315
239 | #bf360c
240 | #ff9e80
241 | #ff6e40
242 | #ff3d00
243 | #dd2c00
244 |
245 | #efebe9
246 | #d7ccc8
247 | #bcaaa4
248 | #a1887f
249 | #8d6e63
250 | #795548
251 | #6d4c41
252 | #5d4037
253 | #4e342e
254 | #3e2723
255 |
256 | #fafafa
257 | #f5f5f5
258 | #eeeeee
259 | #e0e0e0
260 | #bdbdbd
261 | #9e9e9e
262 | #757575
263 | #616161
264 | #424242
265 | #212121
266 | #000000
267 | #ffffff
268 |
269 | #eceff1
270 | #cfd8dc
271 | #b0bec5
272 | #90a4ae
273 | #78909c
274 | #607d8b
275 | #546e7a
276 | #455a64
277 | #37474f
278 | #263238
279 |
280 |
--------------------------------------------------------------------------------