Skip to content

Commit a74b19e

Browse files
committed
Refactored explode transition & removed unused code
1 parent 94da13d commit a74b19e

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

app/src/main/java/com/saulmm/material/MyActivity.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
3131
super.onCreate(savedInstanceState);
3232
setContentView(R.layout.activity_my);
3333

34-
Explode ex = new Explode();
35-
ex.setPropagation(new CircularPropagation());
36-
37-
getWindow().setExitTransition(ex);
38-
getWindow().setEnterTransition(ex);
34+
Utils.configureWindowEnterExitTransition(getWindow());;
3935

4036
// Fab Button
4137
int fabSize = getResources().getDimensionPixelSize(R.dimen.fab_size);
@@ -57,13 +53,9 @@ protected void onCreate(Bundle savedInstanceState) {
5753
View.OnClickListener fabClickListener = new View.OnClickListener() {
5854
@Override
5955
public void onClick(View view) {
60-
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MyActivity.this,
61-
Pair.create(holderView, "holder2"),
62-
Pair.create(fabButton, "fab"));
63-
6456

65-
Intent i = new Intent (MyActivity.this, MyActivity2.class);
66-
startActivity(i);
57+
Intent i = new Intent (MyActivity.this, MyActivity2.class);
58+
startActivity(i);
6759
}
6860
};
6961
}

app/src/main/java/com/saulmm/material/MyActivity2.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@ protected void onCreate(Bundle savedInstanceState) {
2929
int fabSize = getResources().getDimensionPixelSize(R.dimen.fab_size);
3030
Outline fabOutLine = new Outline();
3131

32-
Explode ex = new Explode();
33-
ex.setPropagation(new CircularPropagation());
32+
Utils.configureWindowEnterExitTransition(getWindow());
3433

35-
getWindow().setExitTransition(ex);
36-
getWindow().setEnterTransition(ex);
3734
fabOutLine.setOval(0, 0, fabSize, fabSize);
3835
}
3936

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.saulmm.material;
2+
3+
import android.transition.CircularPropagation;
4+
import android.transition.Explode;
5+
import android.view.Window;
6+
7+
/**
8+
* Created by saulmm on 16/10/14.
9+
*/
10+
public class Utils {
11+
12+
public static void configureWindowEnterExitTransition (Window w) {
13+
14+
Explode ex = new Explode();
15+
16+
CircularPropagation c = new CircularPropagation();
17+
c.setPropagationSpeed(2f);
18+
19+
ex.setPropagation(c);
20+
21+
w.setExitTransition(ex);
22+
w.setEnterTransition(ex);
23+
}
24+
}

0 commit comments

Comments
 (0)