diff --git a/app/Locabean/src/com/locaudio/locabean/NodeActivity.java b/app/Locabean/src/com/locaudio/locabean/NodeActivity.java index b420509..0ca900c 100644 --- a/app/Locabean/src/com/locaudio/locabean/NodeActivity.java +++ b/app/Locabean/src/com/locaudio/locabean/NodeActivity.java @@ -52,9 +52,10 @@ public void onCreate(Bundle savedInstanceState) { } private void setButtonHandlers() { - ((Button) findViewById(R.id.btnStart)).setOnClickListener(btnClick); - ((Button) findViewById(R.id.btnStop)).setOnClickListener(btnClick); - ((Button) findViewById(R.id.btnSend)).setOnClickListener(btnClick); + ((Button) findViewById(R.id.btnStart)) + .setOnClickListener(btnStartClick); + ((Button) findViewById(R.id.btnStop)).setOnClickListener(btnStopClick); + ((Button) findViewById(R.id.btnSend)).setOnClickListener(btnSendClick); } private void enableButton(int id, boolean isEnable) { @@ -101,52 +102,48 @@ private void stopRecording() { WaveWriter.deleteTempFile(); } - private View.OnClickListener btnClick = new View.OnClickListener() { + private View.OnClickListener btnStartClick = new View.OnClickListener() { @Override public void onClick(View v) { - switch (v.getId()) { - case R.id.btnStart: { - System.out.println("Start Recording"); - enableButtons(true); + System.out.println("Start Recording"); + enableButtons(true); - startRecording(); + startRecording(); + } + }; - break; - } - case R.id.btnStop: { - System.out.println("Stop Recording"); - enableButtons(false); - stopRecording(); - Wave wave = new Wave(WaveWriter.getFilename()); - splTextView.setText("" - + WaveProcessing - .determineAverageSoundPressureLevel(wave)); - - break; - } - case R.id.btnSend: { - - Wave wave = new Wave(WaveWriter.getFilename()); - NotifyForm postForm = new NotifyForm(); - postForm.setFingerprint(wave.getFingerprint()); - postForm.setSoundPressureLevel(100); - postForm.setTimestamp(10); - postForm.setX(1); - postForm.setY(0); - - locaudio.notifyEvent(postForm, new UIFunction( - self) { - - @Override - public void runUI(NotifyResponse nr) { - nameTextView.setText(nr.name); - confidenceTextView.setText("" + nr.confidence); - } - }); - - break; - } - } + private View.OnClickListener btnStopClick = new View.OnClickListener() { + @Override + public void onClick(View v) { + System.out.println("Stop Recording"); + enableButtons(false); + stopRecording(); + Wave wave = new Wave(WaveWriter.getFilename()); + splTextView.setText("" + + WaveProcessing.determineAverageSoundPressureLevel(wave)); + } + }; + + private View.OnClickListener btnSendClick = new View.OnClickListener() { + @Override + public void onClick(View v) { + Wave wave = new Wave(WaveWriter.getFilename()); + NotifyForm postForm = new NotifyForm(); + postForm.setFingerprint(wave.getFingerprint()); + postForm.setSoundPressureLevel(100); + postForm.setTimestamp(10); + postForm.setX(1); + postForm.setY(0); + + locaudio.notifyEvent(postForm, + new UIFunction(self) { + + @Override + public void runUI(NotifyResponse nr) { + nameTextView.setText(nr.name); + confidenceTextView.setText("" + nr.confidence); + } + }); } }; }