Browse Source

Adapted setDevice method

DoNotMerge_Runnable_Test_Branch
Christian Tinz 1 year ago
parent
commit
db74988f3d

+ 2
- 2
app/src/main/java/com/example/greenwatch/AccelerometerActivity.java View File

@Override @Override
public void onChanged(Boolean aBoolean) { public void onChanged(Boolean aBoolean) {
if (aBoolean) { if (aBoolean) {
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), mAccelerometerViewModel.getLocalDeviceUUID(), true, "Accelerometer", 10);
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10);
} }
else { else {
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), mAccelerometerViewModel.getLocalDeviceUUID(), false, "Accelerometer", 0);
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), false, "Accelerometer", 0);
} }


} }

+ 2
- 2
app/src/main/java/com/example/greenwatch/MainActivity.java View File

@Override @Override
public void onClick(View v) { public void onClick(View v) {
//openAudiodetectionActivity(); //openAudiodetectionActivity();
mMainActivityViewModel.setDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", "12345", false, "Audio", 10);
mMainActivityViewModel.setDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", false, "Audio", 10);
} }
}); });
videodetectionButton.setOnClickListener(new View.OnClickListener() { videodetectionButton.setOnClickListener(new View.OnClickListener() {
//openVideodetectionActivity(); //openVideodetectionActivity();
mMainActivityViewModel.setSensorType(mMainActivityViewModel.getLocalDeviceUUID(), "Video"); mMainActivityViewModel.setSensorType(mMainActivityViewModel.getLocalDeviceUUID(), "Video");
mMainActivityViewModel.setTimeStamp(mMainActivityViewModel.getLocalDeviceUUID(), "12:50"); mMainActivityViewModel.setTimeStamp(mMainActivityViewModel.getLocalDeviceUUID(), "12:50");
mMainActivityViewModel.setDeviceID(mMainActivityViewModel.getLocalDeviceUUID(), mMainActivityViewModel.getLocalDeviceUUID());
mMainActivityViewModel.setDeviceID(mMainActivityViewModel.getLocalDeviceUUID(), "12345");
} }
}); });
accelerometerButton.setOnClickListener(new View.OnClickListener() { accelerometerButton.setOnClickListener(new View.OnClickListener() {

+ 2
- 5
app/src/main/java/com/example/greenwatch/repositories/DeviceRepository.java View File

return deviceUUID; return deviceUUID;
} }


public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
public void setDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
String checkedDeviceID = checkDeviceID(deviceID); String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID); Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) { if(device != null) {
device.setTimeStamp(timeStamp); device.setTimeStamp(timeStamp);
device.setDeviceID(newDeviceID);
device.setSensorStatus(sensorStatus); device.setSensorStatus(sensorStatus);
device.setSensorType(sensorType); device.setSensorType(sensorType);
device.setSensorMassage(sensorMassage); device.setSensorMassage(sensorMassage);
setDeviceIDMapper(newDeviceID);
connectedDevicesList.remove(checkedDeviceID);
addToConnectedDeviceList(newDeviceID, device);
addToConnectedDeviceList(checkedDeviceID, device);
setMutableLiveDataValue(); setMutableLiveDataValue();
} }
} }

+ 2
- 2
app/src/main/java/com/example/greenwatch/viewmodels/AccelerometerViewModel.java View File

return mDeviceList; return mDeviceList;
} }


public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
mDeviceRepository.setDevice(deviceID, timeStamp,newDeviceID, sensorStatus, sensorType, sensorMassage);
public void setDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
mDeviceRepository.setDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
} }


public void setTimeStamp(String deviceID, String timeStamp) { public void setTimeStamp(String deviceID, String timeStamp) {

+ 2
- 2
app/src/main/java/com/example/greenwatch/viewmodels/MainActivityViewModel.java View File

return mDeviceList; return mDeviceList;
} }


public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
mDeviceRepository.setDevice(deviceID, timeStamp,newDeviceID, sensorStatus, sensorType, sensorMassage);
public void setDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
mDeviceRepository.setDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
} }


public void setTimeStamp(String deviceID, String timeStamp) { public void setTimeStamp(String deviceID, String timeStamp) {

Loading…
Cancel
Save