package de.kardroids.testprojekt;
import android.app.Activity;
import android.app.ListActivity;
import android.os.CountDownTimer;
import android.os.Handler;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Random;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
float oldRotation = 0.0f;
public void setRandomValue(View view) {
Random ran = new Random();
int randomNumber = ran.nextInt(100);
final ImageView myImageView = (ImageView)findViewById(R.id.nadel);
AnimationSet animSet = new AnimationSet(true);
animSet.setInterpolator(new DecelerateInterpolator());
animSet.setFillAfter(true);
animSet.setFillEnabled(true);
TextView textView = (TextView) findViewById(R.id.textview);
float rotationOldValue = myImageView.getRotation()/2.4f;
float newRotationValue = randomNumber - rotationOldValue;
final float rotationNumber = newRotationValue*2.4f;
textView.setText("value: " + newRotationValue + " degree: " + rotationNumber);
final RotateAnimation animRotate = new RotateAnimation(oldRotation, rotationNumber,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
animRotate.setDuration(1500);
animRotate.setFillAfter(true);
animRotate.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
oldRotation = rotationNumber;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animSet.addAnimation(animRotate);
myImageView.startAnimation(animSet);
}
public void setProgressValues(View view) {
CountDownTimer myCountdownTimer = new CountDownTimer(12000, 1000) {
public void onTick(long millisUntilFinished) {
final ImageView myImageView = (ImageView)findViewById(R.id.nadel);
AnimationSet animSet = new AnimationSet(true);
animSet.setInterpolator(new DecelerateInterpolator());
animSet.setFillAfter(true);
animSet.setFillEnabled(true);
TextView textView = (TextView) findViewById(R.id.textview);
final float rotationNumber = (millisUntilFinished-2000)/100*2.4f;
textView.setText("value: " + (millisUntilFinished-2000)*10 + " degree: " + rotationNumber);
final RotateAnimation animRotate = new RotateAnimation(oldRotation, rotationNumber,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
animRotate.setDuration(900);
animRotate.setFillAfter(true);
animRotate.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
oldRotation = rotationNumber;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animSet.addAnimation(animRotate);
myImageView.startAnimation(animSet);
//mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
// Kick off your AsyncTask here.
}
public void onFinish() {
//mTextField.setText("done!");
// the 30 seconds is up now so do make any checks you need here.
}
}.start();
}
public void setTenTimesValues(View view) {
CountDownTimer myCountdownTimer = new CountDownTimer(12000, 1000) {
public void onTick(long millisUntilFinished) {
final ImageView myImageView = (ImageView)findViewById(R.id.nadel);
AnimationSet animSet = new AnimationSet(true);
animSet.setInterpolator(new DecelerateInterpolator());
animSet.setFillAfter(true);
animSet.setFillEnabled(true);
TextView textView = (TextView) findViewById(R.id.textview);
Random ran = new Random();
int randomNumber = ran.nextInt(100);
final float rotationNumber = randomNumber*2.4f;
textView.setText("value: " + randomNumber*10 + " degree: " + rotationNumber);
final RotateAnimation animRotate = new RotateAnimation(oldRotation, rotationNumber,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
animRotate.setDuration(900);
animRotate.setFillAfter(true);
animRotate.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
oldRotation = rotationNumber;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animSet.addAnimation(animRotate);
myImageView.startAnimation(animSet);
//mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
// Kick off your AsyncTask here.
}
public void onFinish() {
//mTextField.setText("done!");
// the 30 seconds is up now so do make any checks you need here.
}
}.start();
}
}