├── .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 |