package com.android.testbtspp2_1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ViewFlipper;

import com.android.Algorithm.*;
//import com.android.testbtspp2_1.*;
import com.android.MathClass.*;
import com.android.application.*;
import com.android.main.*;


	public class SlideSample extends Activity {
		ViewFlipper flipper;
		//DemoView demoview = new DemoView(this,128);
		private Animation inFromRightAnimation() {
			Animation inFromRight = new TranslateAnimation(
			Animation.RELATIVE_TO_PARENT,  +1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f);
			inFromRight.setDuration(500);
			inFromRight.setInterpolator(new AccelerateInterpolator());
			return inFromRight;
		}
		private Animation outToLeftAnimation() {
			Animation outtoLeft = new TranslateAnimation(  
			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  -1.0f, 
			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
			);
			outtoLeft.setDuration(500);
			outtoLeft.setInterpolator(new AccelerateInterpolator());
			return outtoLeft;
		}
		private Animation inFromLeftAnimation() {
			Animation inFromLeft = new TranslateAnimation(
			Animation.RELATIVE_TO_PARENT,  -1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
			);
			inFromLeft.setDuration(500);
			inFromLeft.setInterpolator(new AccelerateInterpolator());
			return inFromLeft;
		}
		private Animation outToRightAnimation() {
			Animation outtoRight = new TranslateAnimation(			  
			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  +1.0f,			  
			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
			);
			outtoRight.setDuration(500);
			outtoRight.setInterpolator(new AccelerateInterpolator());
			return outtoRight;
		}
		/** Called when the activity is first created. */
		@Override
		public void onCreate(Bundle savedInstanceState) {	 
			super.onCreate(savedInstanceState); 
			setContentView(R.layout.slideclockmain);	 
			flipper = (ViewFlipper) findViewById(R.id.flipper);	
			Button button1 = (Button) findViewById(R.id.Button01);	 
			Button button2 = (Button) findViewById(R.id.Button02);	
			//flipper.addView(demoview);
			button1.setOnClickListener(new View.OnClickListener() {	     
				public void onClick(View view) {	        
					flipper.setInAnimation(inFromRightAnimation());	       
					flipper.setOutAnimation(outToLeftAnimation());	        
					flipper.showNext();      	    
					}	
				});
			button2.setOnClickListener(new View.OnClickListener() {   
				public void onClick(View view) {      
					flipper.setInAnimation(inFromLeftAnimation());     
					flipper.setOutAnimation(outToRightAnimation());      
					flipper.showPrevious();        
					}
				});
		}
}