Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 062a336

Browse files
committed
Create magic button actions animations
1 parent 6129d9a commit 062a336

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package br.com.bloder.magic.internal;
2+
3+
import android.view.View;
4+
import android.view.animation.Animation;
5+
import android.view.animation.Transformation;
6+
7+
/**
8+
* Created by bloder on 28/07/16.
9+
*/
10+
public class Back extends Animation {
11+
12+
private int toWidth;
13+
private int startWidth;
14+
private View view;
15+
16+
public Back(View view) {
17+
this.view = view;
18+
this.startWidth = this.view.getWidth();
19+
this.toWidth = view.getHeight();
20+
}
21+
22+
@Override
23+
protected void applyTransformation(float interpolatedTime, Transformation t) {
24+
final int newWidth = startWidth + (int) ((toWidth - startWidth) * interpolatedTime);
25+
view.getLayoutParams().width = newWidth;
26+
view.requestLayout();
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package br.com.bloder.magic.internal;
2+
3+
import android.view.View;
4+
import android.view.animation.Animation;
5+
import android.view.animation.Transformation;
6+
7+
/**
8+
* Created by bloder on 28/07/16.
9+
*/
10+
public class Go extends Animation {
11+
12+
private int toWidth;
13+
private int startWidth;
14+
private View view;
15+
16+
public Go(View view) {
17+
this.view = view;
18+
this.startWidth = this.view.getWidth();
19+
this.toWidth = startWidth == view.getHeight() ? startWidth * 4 : view.getHeight();
20+
}
21+
22+
@Override
23+
protected void applyTransformation(float interpolatedTime, Transformation t) {
24+
final int newWidth = startWidth + (int) ((toWidth - startWidth) * interpolatedTime);
25+
view.getLayoutParams().width = newWidth;
26+
view.requestLayout();
27+
}
28+
}

0 commit comments

Comments
 (0)