package com.danielholst.soundmixer;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
public class DanceKit extends Activity {
/** Called when the activity is first created. */
SoundPool sp;
int kick;
int snare;
int ride;
int hat_cl;
int clap;
int crash;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
setContentView(R.layout.drumpad_dance);
final SoundPool sp = new SoundPool(6, AudioManager.STREAM_MUSIC, 0);
Button bMenu = (Button) findViewById(R.id.menu);
Button bAbout = (Button) findViewById(R.id.about);
Button next = (Button) findViewById(R.id.rightarrow);
Button prev = (Button) findViewById(R.id.leftarrow);
bMenu.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.danielholst.soundmixer.MENU"));
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog loadingdialog = new Dialog(DanceKit.this, R.style.NoFrameDialog);
loadingdialog.setContentView(R.layout.loadingdialog);
loadingdialog.show();
startActivity(new Intent("com.danielholst.soundmixer.VINTAGEKIT"));
finish();
}
});
// sound buttons
Button bKick = (Button) findViewById(R.id.bKick);
Button bSnare = (Button) findViewById(R.id.bSnare);
Button bRide = (Button) findViewById(R.id.bRide);
Button bHat_cl = (Button) findViewById(R.id.bHat_cl);
Button bClap = (Button) findViewById(R.id.bClap);
Button bCrash = (Button) findViewById(R.id.bCrash);
// set sounds
kick = sp.load(this, R.raw.dance_kick, 1);
snare = sp.load(this, R.raw.dance_snare, 1);
ride = sp.load(this, R.raw.dance_ride, 1);
hat_cl = sp.load(this, R.raw.dance_hat_cl, 1);
clap = sp.load(this, R.raw.dance_clap, 1);
crash = sp.load(this, R.raw.dance_crash, 1);
bKick.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
sp.play(kick, 1, 1, 1, 0, 1);
return true;
}
return false;
}
});
bSnare.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
sp.play(snare, 1, 1, 1, 0, 1);
return true;
}
return false;
}
});
bRide.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
sp.play(ride, 1, 1, 1, 0, 1);
return true;
}
return false;
}
});
bHat_cl.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
sp.play(hat_cl, 1, 1, 1, 0, 1);
return true;
}
return false;
}
});
bClap.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
sp.play(clap, 1, 1, 1, 0, 1);
return true;
}
return false;
}
});
bCrash.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
sp.play(crash, 1, 1, 1, 0, 1);
return true;
}
return false;
}
});
}
}