package doodoo.toyo.magicforest;

import android.os.Bundle;


import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.ViewSwitcher;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;

public class MagicForestActivity extends Activity {
	
	private static final String LOGTAG = "MagicForestActivity";
					
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_magicforest);
        
        Log.d(LOGTAG, "onCreate" );															  //lifecycle
      
		final ImageView tarzan = (ImageView) findViewById(R.id.imageView1);					  //ImageView tarzan
		final ImageView roata = (ImageView) findViewById(R.id.imageView4);					  //ImageView roata
		final ImageView papagal = (ImageView) findViewById(R.id.imageView5);				  //ImageView papagal

//start animatii tarzan, roata, papagal----------------------------------------------------
		final Animation tarzanAnimation = AnimationUtils.loadAnimation(this, R.anim.tarzan);	//Animation tarzan
		tarzan.startAnimation(tarzanAnimation);		
		final Animation roataAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate);		//Animation roata
		roata.startAnimation(roataAnimation);		
		final Animation papagalAnimation = AnimationUtils.loadAnimation(this, R.anim.papagal);	//Animation papagal
		papagal.startAnimation(papagalAnimation);
//end animatii tarzan, roata, papagal
		
//start sunete papagal, tarzan si ursuleti------------------------------------------------
		 final MediaPlayer mp=MediaPlayer.create(getApplicationContext(), R.raw.papagal);
		 final MediaPlayer mp1=MediaPlayer.create(getApplicationContext(), R.raw.tarzan);
		 final MediaPlayer mp4=MediaPlayer.create(getApplicationContext(), R.raw.roata);

		 OnClickListener elem = new OnClickListener() {

				@Override
				public void onClick(View v) {
					
					switch (v.getId()) {
			         case R.id.imageView1:
				         mp1.start();
				         break;
			         case R.id.imageView4:
				         mp4.start();
				         break;
			         case R.id.imageView5:
				         mp.start();
				         break;
			         }				
				}	
		    };		    
		    papagal.setOnClickListener(elem);
		    tarzan.setOnClickListener(elem);
		    roata.setOnClickListener(elem);
//end sunete papagal, tarzan si ursuleti
		    
// ViewSwitcher ursuleti animation---------------------------------------------------------------------
		    ((ViewSwitcher) findViewById(R.id.switcher)).setOnClickListener(new View.OnClickListener() {

		        @Override
		        public void onClick(View v) {
		            ViewSwitcher switcher = (ViewSwitcher) v;

		            if (switcher.getDisplayedChild() == 0) {
		                switcher.showNext();
		            } else {
		                switcher.showPrevious();
		            }
		        }
		    });
// end ViewSwitcher ursuleti animation	    
		    
    }
    
//fereastra bear----------------------------------------
    public void gotoBear(View v){
    	Intent intent = new Intent(this, BearActivity.class);
        startActivity(intent);
    }
    
//fereastra monkey---------------------------------------
    public void gotoMonkey(View v){
    	Intent intent = new Intent(this, MonkeyActivity.class);
        startActivity(intent);
    }
        
//lifecycle---------------------------------------------------
    @Override
    protected void onResume() {
    	super.onResume();
    	Log.d(LOGTAG, "onResume");
    }
    
    @Override
    protected void onStart() {
    	super.onStart();
    	Log.d(LOGTAG, "onStart");
    }
    
    @Override
    protected void onPause() {
    	super.onPause();
    	Log.d(LOGTAG, "onPause");
    }
    
    @Override
    protected void onStop() {
    	super.onStop();
    	Log.d(LOGTAG, "onStop");
    }
    
    @Override
    protected void onDestroy() {
    	super.onDestroy();
    	Log.d(LOGTAG, "onDestroy");
    }
    
    @Override
    protected void onRestart() {
    	super.onRestart();
     	Log.d(LOGTAG, "onRestart");
    }
//end lifecycle


}
