|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void onChanged(Boolean aBoolean) { |
|
|
public void onChanged(Boolean aBoolean) { |
|
|
if (aBoolean) { |
|
|
if (aBoolean) { |
|
|
if (mAudiodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected()) { |
|
|
|
|
|
|
|
|
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "onChangedTrue", Toast.LENGTH_LONG).show(); |
|
|
|
|
|
if (mAudiodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected() && !mAudiodetectionAndAccelerometerViewModel.getMicrofonAlarmDetected()) { |
|
|
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10); |
|
|
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10); |
|
|
} |
|
|
} |
|
|
else if (mAudiodetectionAndAccelerometerViewModel.getMicrofonAlarmDetected()) { |
|
|
|
|
|
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Microfon", (int) mAudiodetectionAndAccelerometerViewModel.getAmplitudeInDB()); |
|
|
|
|
|
|
|
|
else if (mAudiodetectionAndAccelerometerViewModel.getMicrofonAlarmDetected() && !mAudiodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected()) { |
|
|
|
|
|
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Audio", (int) mAudiodetectionAndAccelerometerViewModel.getAmplitudeInDB()); |
|
|
|
|
|
} |
|
|
|
|
|
else if (mAudiodetectionAndAccelerometerViewModel.getMicrofonAlarmDetected() && mAudiodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected()) { |
|
|
|
|
|
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "2AudioAndAccelerometer", 10); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
|
|
|
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "onChangedFalse", Toast.LENGTH_LONG).show(); |
|
|
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), false, "AudioAndAccelerometer", 0); |
|
|
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), false, "AudioAndAccelerometer", 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onPause() { |
|
|
protected void onPause() { |
|
|
super.onPause(); |
|
|
super.onPause(); |
|
|
|
|
|
if (isFinishing()){ |
|
|
|
|
|
mAudiodetectionAndAccelerometerViewModel.recalibrationMicrofonSensor(); |
|
|
|
|
|
} |
|
|
mAudiodetectionAndAccelerometerViewModel.stopMicrofonSensor(); |
|
|
mAudiodetectionAndAccelerometerViewModel.stopMicrofonSensor(); |
|
|
if (accelerometerSensor != null) { |
|
|
if (accelerometerSensor != null) { |
|
|
accelerometerManager.unregisterListener(this, accelerometerSensor); |
|
|
accelerometerManager.unregisterListener(this, accelerometerSensor); |