The data is interrupted.
hubeen opened this issue · 0 comments
hubeen commented
onPressureValueChangedEvent, onMicrophoneValueChangedEvent
Running two events at once causes a delay.
@Override
public void onMicrophoneValueChangedEvent(BluetoothDevice bluetoothDevice, final short[] data) {
if (data != null) {
if (data.length != 0) {
Thread pm = new Thread(new Runnable() {
@Override
public void run() {
mHandler.post(new Runnable() {
@Override
public void run() {
mHeartTimeStamp = ThingyUtils.TIME_FORMAT.format(System.currentTimeMillis());
int pcm_raw = Math.abs(data[data.length - 1]);
handleGraphLineUpdates(lc_Heart);
addHeartEntry(mHeartTimeStamp, pcm_raw );
}
});
}
});
pm.start();
}
}
}
@Override
public void onPressureValueChangedEvent(BluetoothDevice bluetoothDevice, final String pressure) {
if(pressure != null){
if (pressure.length() != 0) {
Thread pt = new Thread(new Runnable() {
@Override
public void run() {
pHandler.post(new Runnable() {
@Override
public void run() {
mPressureTimeStamp = ThingyUtils.TIME_FORMAT.format(System.currentTimeMillis());
handleGraphLineUpdates(lc_Respiratory);
addRespiratoryEntry(mPressureTimeStamp, pressure);
}
});
}
});
pt.start();
}
}
It's the same if you use threads.
How do I approach it?