/[projects]/android/Side9/src/dk/thoerup/side9/anim/SwapViews.java
ViewVC logotype

Contents of /android/Side9/src/dk/thoerup/side9/anim/SwapViews.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1218 - (show annotations) (download)
Tue Jan 25 09:37:58 2011 UTC (13 years, 3 months ago) by torben
File size: 1239 byte(s)
Annotate functions with @Override where appropriate
1 package dk.thoerup.side9.anim;
2
3 import android.view.View;
4 import android.view.animation.DecelerateInterpolator;
5 import android.widget.ImageView;
6
7 public final class SwapViews implements Runnable {
8 private boolean mIsFirstView;
9 ImageView image1;
10 ImageView image2;
11 boolean forward;
12
13 public SwapViews(boolean isFirstView, boolean forward, ImageView image1, ImageView image2) {
14 mIsFirstView = isFirstView;
15 this.image1 = image1;
16 this.image2 = image2;
17 this.forward = forward;
18 }
19
20 @Override
21 public void run() {
22 final float centerX = image1.getWidth() / 2.0f;
23 final float centerY = image1.getHeight() / 2.0f;
24 Flip3dAnimation rotation;
25
26 if (mIsFirstView) {
27 image1.setVisibility(View.GONE);
28 image2.setVisibility(View.VISIBLE);
29 image2.requestFocus();
30
31
32 } else {
33 image2.setVisibility(View.GONE);
34 image1.setVisibility(View.VISIBLE);
35 image1.requestFocus();
36 }
37
38 int startAngle = forward ? 90 : -90;
39
40 rotation = new Flip3dAnimation(startAngle, 0, centerX, centerY);
41
42 rotation.setDuration(250);
43 rotation.setFillAfter(true);
44 rotation.setInterpolator(new DecelerateInterpolator());
45
46 if (mIsFirstView) {
47 image2.startAnimation(rotation);
48 } else {
49 image1.startAnimation(rotation);
50 }
51 }
52 }

  ViewVC Help
Powered by ViewVC 1.1.20