package net.cs76.lectures.intents06;

import net.cs76.lectures.intents06.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/*
 * Intents06
 * Dan Armendariz
 * Computer Science E-76
 * 
 * Demonstrating intents and starting a second Activity. 
 */

public class Code6 extends Activity implements OnClickListener{

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        // find our buttons and set onClickListeners for both
        Button yes = (Button)findViewById(R.id.yes);
        Button no  = (Button)findViewById(R.id.no);
        yes.setOnClickListener(this);
        no.setOnClickListener(this);
    }

	public void onClick(View v) {

		// do something based on the button that was clicked
		switch(v.getId()) {
			/* if the "yes" button is clicked, let's start a new
			 * activity by creating an Intent and passing it
			 * into the startActivity() method.
			 */
			
			case R.id.yes:
					// create an intent indicating we want
					// to start the ThumbsUp activity.
					// Important! Make sure your activity is
					// in the AndroidManifest.xml file!
			    	Intent i = new Intent(this, ThumbsUp.class);
			    	
			    	// start the activity based on the Intent
					startActivity(i);
					finish();
				break;
				
			// if "no" was selected, we'll quit the application. 
			case R.id.no: 
			default:
				finish();
		}
		
	}
}