Adaptation of the receive logic
This commit is contained in:
parent
f1f90952d2
commit
fb873406f9
@ -51,11 +51,6 @@ public class WiFiCommunication {
|
|||||||
if (mDeviceRepository == null) {
|
if (mDeviceRepository == null) {
|
||||||
this.mDeviceRepository = deviceRepository;
|
this.mDeviceRepository = deviceRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
public void setRecievedSting(String rxString) {
|
|
||||||
this.rxString = rxString;
|
|
||||||
//mDeviceRepository.getNewReceivedMessage(this.rxString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNewMessage(String newMessage, boolean isNewMessage){
|
public void setNewMessage(String newMessage, boolean isNewMessage){
|
||||||
@ -124,7 +119,7 @@ public class WiFiCommunication {
|
|||||||
rxString = new String(packet.getData(), 0, packet.getLength());
|
rxString = new String(packet.getData(), 0, packet.getLength());
|
||||||
|
|
||||||
if(!previousRxString.equals(rxString)){
|
if(!previousRxString.equals(rxString)){
|
||||||
setRecievedSting(rxString);
|
mDeviceRepository.getNewReceivedMessage(rxString);
|
||||||
|
|
||||||
}
|
}
|
||||||
previousRxString = rxString;
|
previousRxString = rxString;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.example.greenwatch.repositories;
|
package com.example.greenwatch.repositories;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import com.example.greenwatch.models.Device;
|
import com.example.greenwatch.models.Device;
|
||||||
@ -273,7 +275,12 @@ public class DeviceRepository {
|
|||||||
|
|
||||||
private void setMutableLiveDataDeviceList() {
|
private void setMutableLiveDataDeviceList() {
|
||||||
List<Device> list = new ArrayList<>(connectedDevicesList.values());
|
List<Device> list = new ArrayList<>(connectedDevicesList.values());
|
||||||
deviceList.setValue(list);
|
if (Looper.myLooper() == Looper.getMainLooper()){
|
||||||
|
deviceList.setValue(list);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
deviceList.postValue(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMutableLiveDataAlarmHistoryList() {
|
private void setMutableLiveDataAlarmHistoryList() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user