add animation

git-svn-id: https://osmand.googlecode.com/svn/trunk@756 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-12-04 13:40:51 +00:00
parent e636efaf03
commit a8d4500d0b

View file

@ -23,7 +23,9 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;
public class MainMenuActivity extends Activity {
@ -86,77 +88,30 @@ public class MainMenuActivity extends Activity {
}
}
public Animation getAnimation(boolean left){
Animation anim = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, left ? -1 : 1,
TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0);
anim.setDuration(700);
anim.setInterpolator(new AccelerateInterpolator());
return anim;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.menu);
/* if(Version.VELCOM_EDITION){
final ImageView imgView = (ImageView) findViewById(R.id.VelcomMini);
final Camera camera = new Camera();
final float firstRotate = 0.25f;
final float invisibleText = 0.7f;
final int animationTime = 3600;
Animation ra = new Animation(){
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final Matrix matrix = t.getMatrix();
int centerY = imgView.getHeight() / 2;
int centerX = imgView.getWidth() / 2;
camera.save();
if (interpolatedTime < firstRotate) {
camera.rotateY(360 * interpolatedTime / firstRotate);
} else if (interpolatedTime < 2 * firstRotate) {
camera.rotateY(360 * (interpolatedTime - firstRotate) / firstRotate);
} else {
camera.rotateY(360 * (interpolatedTime - 2 * firstRotate) / (1 - 2 * firstRotate));
}
camera.getMatrix(matrix);
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
camera.restore();
}
};
// let accelerate animation
// ra.setInterpolator(new LinearInterpolator());
ra.setDuration(animationTime);
imgView.startAnimation(ra);
View leftview = (View) findViewById(R.id.MapButton);
leftview.startAnimation(getAnimation(true));
leftview = (View) findViewById(R.id.FavoritesButton);
leftview.startAnimation(getAnimation(true));
final TextView textView = (TextView) findViewById(R.id.TextVelcom);
Animation alphaAnimation = new Animation(){
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if(interpolatedTime < invisibleText){
t.setAlpha(0);
} else {
t.setAlpha((interpolatedTime - invisibleText) / (1 - invisibleText));
}
}
};
alphaAnimation.setAnimationListener(new Animation.AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
textView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
textView.setVisibility(View.VISIBLE);
}
});
alphaAnimation.setDuration(animationTime);
textView.startAnimation(alphaAnimation);
textView.setVisibility(View.INVISIBLE);
} else { */
View rightview = (View) findViewById(R.id.SettingsButton);
rightview.startAnimation(getAnimation(false));
rightview = (View) findViewById(R.id.SearchButton);
rightview.startAnimation(getAnimation(false));
final TextView textView = (TextView) findViewById(R.id.TextVersion);
textView.setText(Version.APP_VERSION+ " "+ Version.APP_DESCRIPTION); //$NON-NLS-1$