├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── rubensousa
│ │ └── transitions
│ │ ├── Adapter.java
│ │ ├── MainActivity.java
│ │ ├── ToolbarActivity.java
│ │ ├── TransitionActivity.java
│ │ └── utils
│ │ ├── ExpandAnimation.java
│ │ └── TransitionUtils.java
│ └── res
│ ├── drawable
│ ├── appbar_statelist.xml
│ ├── circle.xml
│ └── empty_rectangle.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_toolbar.xml
│ ├── activity_transition.xml
│ └── card_adapter.xml
│ ├── 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
│ ├── transition
│ ├── curve_transition.xml
│ └── fade_out.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── drawables.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshots
├── fab.gif
├── layout.gif
└── shared.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Transitions
2 |
3 | A sample that showcases some transitions
4 |
5 |
6 |
7 |
8 |
9 |
10 | ## References
11 |
12 | http://guides.codepath.com/android/shared-element-activity-transition
13 |
14 | https://github.com/lgvalle/Material-Animations
15 |
16 | https://material.io/guidelines/motion/choreography.html#
17 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/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.github.rubensousa.transitions"
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 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.1.1'
28 | compile 'com.android.support:design:25.1.1'
29 | compile 'com.android.support:cardview-v7:25.1.1'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/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 /home/ruben/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/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/rubensousa/transitions/Adapter.java:
--------------------------------------------------------------------------------
1 | package com.github.rubensousa.transitions;
2 |
3 |
4 | import android.os.Build;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.view.animation.AccelerateDecelerateInterpolator;
10 |
11 | import com.github.rubensousa.transitions.utils.ExpandAnimation;
12 |
13 |
14 | public class Adapter extends RecyclerView.Adapter {
15 |
16 | private OnClickListener listener;
17 |
18 | public Adapter(OnClickListener listener) {
19 | this.listener = listener;
20 | }
21 |
22 | @Override
23 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
24 | return new ViewHolder(LayoutInflater.from(parent.getContext())
25 | .inflate(R.layout.card_adapter, parent, false));
26 | }
27 |
28 | @Override
29 | public void onBindViewHolder(ViewHolder holder, int position) {
30 | holder.bind(position);
31 | }
32 |
33 | @Override
34 | public int getItemCount() {
35 | return 50;
36 | }
37 |
38 | public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
39 |
40 | View circleView;
41 | View expandView;
42 | View expandableView;
43 | boolean expanded;
44 |
45 | public ViewHolder(View itemView) {
46 | super(itemView);
47 | itemView.setOnClickListener(this);
48 | expandView = itemView.findViewById(R.id.expandView);
49 | expandableView = itemView.findViewById(R.id.expandableView);
50 | circleView = itemView.findViewById(R.id.circleView);
51 | circleView.setOnClickListener(this);
52 | }
53 |
54 | public void bind(int position) {
55 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
56 | circleView.setTransitionName("transition" + position);
57 | circleView.invalidate();
58 | }
59 | ViewGroup.LayoutParams params = expandView.getLayoutParams();
60 | params.height = expanded ?
61 | itemView.getResources().getDimensionPixelOffset(R.dimen.card_expanded_height)
62 | : itemView.getResources().getDimensionPixelOffset(R.dimen.card_default_height);
63 | expandView.setLayoutParams(params);
64 | expandableView.setAlpha(expanded ? 1.0f : 0.0f);
65 | }
66 |
67 | @Override
68 | public void onClick(View v) {
69 | if (v.getId() == R.id.circleView) {
70 | if (listener != null) {
71 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
72 | listener.onItemClick(v, v.getTransitionName(), getAdapterPosition());
73 | } else {
74 | listener.onItemClick(v, "", getAdapterPosition());
75 | }
76 | }
77 | } else {
78 | expandOrCollapse();
79 | }
80 | }
81 |
82 | private void expandOrCollapse() {
83 | int expandedHeight = itemView.getResources()
84 | .getDimensionPixelOffset(R.dimen.card_expanded_height);
85 | int defaultHeight = itemView.getResources()
86 | .getDimensionPixelOffset(R.dimen.card_default_height);
87 |
88 | if (expanded) {
89 | int tmp = defaultHeight;
90 | defaultHeight = expandedHeight;
91 | expandedHeight = tmp;
92 | }
93 |
94 | ExpandAnimation expandAnimation = new ExpandAnimation(expandView, defaultHeight,
95 | expandedHeight);
96 | expandAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
97 | expandAnimation.setDuration(375);
98 | expandAnimation.start();
99 |
100 | expandableView.animate().alpha(expanded ? 0.0f : 1.0f).setStartDelay(75);
101 | expanded = !expanded;
102 | }
103 | }
104 |
105 | public interface OnClickListener {
106 | void onItemClick(View sharedView, String transitionName, int position);
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/rubensousa/transitions/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.rubensousa.transitions;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.content.Intent;
6 | import android.os.Build;
7 | import android.os.Bundle;
8 | import android.support.annotation.RequiresApi;
9 | import android.support.design.widget.FloatingActionButton;
10 | import android.support.v4.app.ActivityCompat;
11 | import android.support.v4.app.ActivityOptionsCompat;
12 | import android.support.v4.app.SharedElementCallback;
13 | import android.support.v4.util.Pair;
14 | import android.support.v7.app.AppCompatActivity;
15 | import android.support.v7.widget.LinearLayoutManager;
16 | import android.support.v7.widget.RecyclerView;
17 | import android.transition.Fade;
18 | import android.view.View;
19 | import android.view.ViewAnimationUtils;
20 | import android.view.animation.AccelerateInterpolator;
21 | import android.view.animation.DecelerateInterpolator;
22 |
23 | import com.github.rubensousa.transitions.utils.TransitionUtils;
24 |
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | public class MainActivity extends AppCompatActivity implements Adapter.OnClickListener {
29 |
30 | private RecyclerView recyclerView;
31 | private View rippleView;
32 | private FloatingActionButton fab;
33 | private boolean launchedActivity;
34 | private int viewPosition;
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_main);
40 | setupTransitions();
41 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
42 | setupRecyclerView();
43 | rippleView = findViewById(R.id.rippleView);
44 | fab = (FloatingActionButton) findViewById(R.id.fab);
45 | fab.setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | if (TransitionUtils.isAtLeastLollipop()) {
49 | startRippleTransitionReveal();
50 | } else {
51 | startActivity();
52 | }
53 | }
54 | });
55 |
56 | // Workaround for orientation change issue
57 | if (savedInstanceState != null) {
58 | viewPosition = savedInstanceState.getInt("position");
59 | }
60 |
61 | setExitSharedElementCallback(new SharedElementCallback() {
62 | @Override
63 | public void onMapSharedElements(List names, Map sharedElements) {
64 | super.onMapSharedElements(names, sharedElements);
65 | if (sharedElements.isEmpty()) {
66 | View view = recyclerView.getLayoutManager().findViewByPosition(viewPosition);
67 | if (view != null) {
68 | sharedElements.put(names.get(0), view.findViewById(R.id.circleView));
69 | }
70 | }
71 | }
72 | });
73 | }
74 |
75 | @Override
76 | protected void onSaveInstanceState(Bundle outState) {
77 | super.onSaveInstanceState(outState);
78 | outState.putInt("position", viewPosition);
79 | }
80 |
81 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
82 | private void startRippleTransitionReveal() {
83 | fab.setVisibility(View.INVISIBLE);
84 | Animator animator = ViewAnimationUtils.createCircularReveal(rippleView,
85 | (int) fab.getX() + fab.getWidth() / 2,
86 | (int) fab.getY(), fab.getWidth() / 2, TransitionUtils.getViewRadius(rippleView) * 2);
87 | rippleView.setVisibility(View.VISIBLE);
88 | animator.setInterpolator(new AccelerateInterpolator());
89 | animator.setDuration(400);
90 | animator.addListener(new AnimatorListenerAdapter() {
91 | @Override
92 | public void onAnimationStart(Animator animation) {
93 | super.onAnimationStart(animation);
94 | recyclerView.animate().alpha(0f);
95 | }
96 |
97 | @Override
98 | public void onAnimationEnd(Animator animation) {
99 | super.onAnimationEnd(animation);
100 | startActivity();
101 | }
102 | });
103 | animator.start();
104 | }
105 |
106 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
107 | private void startRippleTransitionUnreveal() {
108 | Animator animator = ViewAnimationUtils.createCircularReveal(rippleView,
109 | (int) fab.getX() + fab.getWidth() / 2,
110 | (int) fab.getY(), TransitionUtils.getViewRadius(rippleView) * 2, fab.getWidth() / 2);
111 | rippleView.setVisibility(View.VISIBLE);
112 | animator.setInterpolator(new DecelerateInterpolator());
113 | animator.setDuration(400);
114 | animator.addListener(new AnimatorListenerAdapter() {
115 | @Override
116 | public void onAnimationStart(Animator animation) {
117 | super.onAnimationStart(animation);
118 | recyclerView.animate().alpha(1f);
119 | }
120 |
121 | @Override
122 | public void onAnimationEnd(Animator animation) {
123 | super.onAnimationEnd(animation);
124 | fab.setVisibility(View.VISIBLE);
125 | rippleView.setVisibility(View.INVISIBLE);
126 | }
127 | });
128 | animator.start();
129 | }
130 |
131 | @Override
132 | protected void onResume() {
133 | super.onResume();
134 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && launchedActivity) {
135 | startRippleTransitionUnreveal();
136 | launchedActivity = false;
137 | }
138 | }
139 |
140 | @Override
141 | public void onItemClick(View sharedView, String transitionName, int position) {
142 | viewPosition = position;
143 | Intent intent = new Intent(this, TransitionActivity.class);
144 | intent.putExtra("transition", transitionName);
145 | ActivityOptionsCompat options = ActivityOptionsCompat.
146 | makeSceneTransitionAnimation(this, sharedView, transitionName);
147 | ActivityCompat.startActivity(this, intent, options.toBundle());
148 | }
149 |
150 | @Override
151 | public void onActivityReenter(int resultCode, Intent data) {
152 | super.onActivityReenter(resultCode, data);
153 | }
154 |
155 | private void startActivity() {
156 | ActivityCompat.startActivity(this, new Intent(this, ToolbarActivity.class),
157 | ActivityOptionsCompat.makeSceneTransitionAnimation(this).toBundle());
158 | launchedActivity = true;
159 | }
160 |
161 | private void setupTransitions() {
162 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
163 | getWindow().setExitTransition(new Fade());
164 | }
165 | }
166 |
167 | private void setupRecyclerView() {
168 | recyclerView.setAdapter(new Adapter(this));
169 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/rubensousa/transitions/ToolbarActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.rubensousa.transitions;
2 |
3 | import android.os.Build;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.design.widget.AppBarLayout;
7 | import android.support.design.widget.CollapsingToolbarLayout;
8 | import android.support.v4.widget.NestedScrollView;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.transition.Fade;
11 | import android.view.ViewTreeObserver;
12 | import android.view.animation.AccelerateDecelerateInterpolator;
13 |
14 |
15 | public class ToolbarActivity extends AppCompatActivity implements AppBarLayout.OnOffsetChangedListener {
16 |
17 | NestedScrollView nestedScrollView;
18 | AppBarLayout appbar;
19 | CollapsingToolbarLayout collapsingToolbarLayout;
20 |
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setupTransitions();
25 | setContentView(R.layout.activity_toolbar);
26 | appbar = (AppBarLayout) findViewById(R.id.appbar);
27 | nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);
28 | collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsingLayout);
29 | if (savedInstanceState == null) {
30 | nestedScrollView.setAlpha(0f);
31 | nestedScrollView.getViewTreeObserver()
32 | .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
33 | @Override
34 | public void onGlobalLayout() {
35 | if (nestedScrollView.getHeight() != 0) {
36 | appbar.setExpanded(true);
37 | appbar.addOnOffsetChangedListener(ToolbarActivity.this);
38 | nestedScrollView.getViewTreeObserver()
39 | .removeOnGlobalLayoutListener(this);
40 | nestedScrollView.animate().setStartDelay(400).alpha(1f);
41 | nestedScrollView.setTranslationY(nestedScrollView.getHeight() / 3);
42 | nestedScrollView.animate().setStartDelay(400).translationY(0)
43 | .setInterpolator(new AccelerateDecelerateInterpolator());
44 | }
45 | }
46 | });
47 | }
48 | }
49 |
50 | private void setupTransitions() {
51 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
52 | getWindow().setEnterTransition(new Fade());
53 | }
54 | }
55 |
56 | @Override
57 | public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
58 | if (verticalOffset == 0) {
59 | AppBarLayout.LayoutParams layoutParams
60 | = (AppBarLayout.LayoutParams)
61 | collapsingToolbarLayout.getLayoutParams();
62 | layoutParams.setScrollFlags(0);
63 | collapsingToolbarLayout.setLayoutParams(layoutParams);
64 | appBarLayout.removeOnOffsetChangedListener(this);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/rubensousa/transitions/TransitionActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.rubensousa.transitions;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.design.widget.FloatingActionButton;
9 | import android.support.v4.app.SharedElementCallback;
10 | import android.support.v4.content.res.TypedArrayUtils;
11 | import android.support.v4.widget.NestedScrollView;
12 | import android.support.v7.app.AppCompatActivity;
13 | import android.transition.Transition;
14 | import android.util.TypedValue;
15 | import android.view.View;
16 | import android.view.animation.AccelerateInterpolator;
17 | import android.view.animation.DecelerateInterpolator;
18 |
19 | import com.github.rubensousa.transitions.utils.TransitionUtils;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | public class TransitionActivity extends AppCompatActivity {
25 |
26 | FloatingActionButton fab;
27 | NestedScrollView nestedScrollView;
28 |
29 | @Override
30 | protected void onCreate(@Nullable Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_transition);
33 | fab = (FloatingActionButton) findViewById(R.id.fab);
34 | nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);
35 |
36 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
37 | View circleView = findViewById(R.id.circleView);
38 | Intent intent = getIntent();
39 | circleView.setTransitionName(intent.getStringExtra("transition"));
40 | Transition transition = getWindow().getSharedElementEnterTransition();
41 | transition.addListener(new Transition.TransitionListener() {
42 | @Override
43 | public void onTransitionStart(Transition transition) {
44 | fab.setScaleX(0);
45 | fab.setScaleY(0);
46 | fab.setVisibility(View.INVISIBLE);
47 | nestedScrollView.setAlpha(0f);
48 | }
49 |
50 | @Override
51 | public void onTransitionEnd(Transition transition) {
52 | fab.show();
53 | nestedScrollView.setTranslationY(
54 | TransitionUtils.dpToPixels(TransitionActivity.this, 72));
55 | nestedScrollView.animate().alpha(1f).translationY(0)
56 | .setInterpolator(new DecelerateInterpolator());
57 | transition.removeListener(this);
58 | }
59 |
60 | @Override
61 | public void onTransitionCancel(Transition transition) {
62 |
63 | }
64 |
65 | @Override
66 | public void onTransitionPause(Transition transition) {
67 |
68 | }
69 |
70 | @Override
71 | public void onTransitionResume(Transition transition) {
72 |
73 | }
74 | });
75 | } else {
76 | if (savedInstanceState == null) {
77 | fab.setScaleX(0);
78 | fab.setScaleY(0);
79 | fab.setVisibility(View.INVISIBLE);
80 | fab.postDelayed(new Runnable() {
81 | @Override
82 | public void run() {
83 | fab.show();
84 | }
85 | }, 300);
86 | }
87 | }
88 | }
89 |
90 | @Override
91 | public void onActivityReenter(int resultCode, Intent data) {
92 | super.onActivityReenter(resultCode, data);
93 | supportPostponeEnterTransition();
94 | }
95 |
96 | @Override
97 | public void onBackPressed() {
98 | fab.setVisibility(View.INVISIBLE);
99 | nestedScrollView.animate().alpha(0)
100 | .setInterpolator(new AccelerateInterpolator())
101 | .translationY(TransitionUtils.dpToPixels(TransitionActivity.this, 72))
102 | .start();
103 | supportFinishAfterTransition();
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/rubensousa/transitions/utils/ExpandAnimation.java:
--------------------------------------------------------------------------------
1 | package com.github.rubensousa.transitions.utils;
2 |
3 |
4 | import android.view.View;
5 | import android.view.animation.Animation;
6 | import android.view.animation.Transformation;
7 |
8 | /**
9 | * Adapted from: https://coderwall.com/p/35xi3w/layout-change-animations-sliding-height
10 | */
11 | public class ExpandAnimation extends Animation {
12 |
13 | int fromHeight;
14 | int toHeight;
15 | View view;
16 |
17 | public ExpandAnimation(View view, int fromHeight, int toHeight) {
18 | this.view = view;
19 | this.fromHeight = fromHeight;
20 | this.toHeight = toHeight;
21 | }
22 |
23 | @Override
24 | protected void applyTransformation(float interpolatedTime, Transformation transformation) {
25 | int newHeight;
26 | if (view.getHeight() != toHeight) {
27 | newHeight = (int) (fromHeight + ((toHeight - fromHeight) * interpolatedTime));
28 | view.getLayoutParams().height = newHeight;
29 | view.requestLayout();
30 | }
31 | }
32 |
33 | @Override
34 | public boolean willChangeBounds() {
35 | return true;
36 | }
37 |
38 | @Override
39 | public void start() {
40 | super.start();
41 | view.startAnimation(this);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/rubensousa/transitions/utils/TransitionUtils.java:
--------------------------------------------------------------------------------
1 | package com.github.rubensousa.transitions.utils;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.util.TypedValue;
6 | import android.view.View;
7 |
8 | public class TransitionUtils {
9 |
10 | public static boolean isAtLeastLollipop() {
11 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
12 | }
13 |
14 | public static float getViewRadius(View view) {
15 | return (float) Math.hypot(view.getHeight() / 2, view.getWidth() / 2);
16 | }
17 |
18 | public static int dpToPixels(Context context, int value) {
19 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value,
20 | context.getResources().getDisplayMetrics());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/appbar_statelist.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/empty_rectangle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
25 |
26 |
27 |
28 |
29 |
35 |
36 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
21 |
22 |
23 |
24 |
29 |
30 |
41 |
42 |
46 |
47 |
52 |
53 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_transition.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
49 |
54 |
55 |
60 |
61 |
66 |
67 |
72 |
73 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_adapter.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
27 |
28 |
39 |
40 |
49 |
50 |
56 |
57 |
64 |
65 |
71 |
72 |
76 |
77 |
81 |
82 |
88 |
89 |
95 |
96 |
102 |
103 |
104 |
105 |
106 |
107 |
114 |
115 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/transition/curve_transition.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/transition/fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #2196F3
4 | #1976D2
5 | #FF9800
6 | #EDEDED
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 160dp
5 |
6 | 16dp
7 | 16dp
8 | 16dp
9 |
10 | 72dp
11 | 282dp
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | - @android:drawable/ic_menu_camera
3 | - @android:drawable/ic_menu_gallery
4 | - @android:drawable/ic_menu_slideshow
5 | - @android:drawable/ic_menu_manage
6 | - @android:drawable/ic_menu_share
7 | - @android:drawable/ic_menu_send
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Transitions
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Mar 07 19:12:58 WET 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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/screenshots/fab.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/screenshots/fab.gif
--------------------------------------------------------------------------------
/screenshots/layout.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/screenshots/layout.gif
--------------------------------------------------------------------------------
/screenshots/shared.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubensousa/Transitions/d18d8200e8b7c7f2bd8b9c510ed0f59867f5f1b1/screenshots/shared.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------