|
|
@@ -171,6 +171,7 @@ public class DataRepository { |
|
|
|
Disposable getNodeBaseURIDisposable = clientApi.getNodeBaseURI(header) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(networks -> { |
|
|
|
for (Network network : networks) { |
|
|
|
if (network.getState().equals(RUNNING)) { |
|
|
@@ -191,6 +192,7 @@ public class DataRepository { |
|
|
|
Disposable getNetworkStateDisposable = clientApi.getNetworkState(UserStore.getInstance(context).getUsername(), network.getUuid(), header) |
|
|
|
.subscribeOn(Schedulers.newThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(networkStatus -> { |
|
|
|
int indexNetworkState = 0; |
|
|
|
for (int i = 0; i < networkStatus.size(); i++) { |
|
|
@@ -210,6 +212,7 @@ public class DataRepository { |
|
|
|
Disposable getNodeBaseURIDisposable = clientApi.getNodeBaseURI(header) |
|
|
|
.subscribeOn(Schedulers.newThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(networks -> { |
|
|
|
for (Network network : networks) { |
|
|
|
if (network.getState().equals(RUNNING)) { |
|
|
@@ -278,6 +281,7 @@ public class DataRepository { |
|
|
|
Disposable disposableLogin = clientApi.login(data) |
|
|
|
.subscribeOn(Schedulers.newThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(user -> { |
|
|
|
UserStore.getInstance(context).setToken(user.getToken()); |
|
|
|
if (!isDeviceLoggedIn(context)) { |
|
|
@@ -297,6 +301,7 @@ public class DataRepository { |
|
|
|
Disposable disposableAllDevices = clientApi.getAllDevices(header) |
|
|
|
.subscribeOn(Schedulers.newThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(listDevices -> { |
|
|
|
boolean hasDevice = false; |
|
|
|
for (Device item : listDevices) { |
|
|
@@ -329,6 +334,7 @@ public class DataRepository { |
|
|
|
final Disposable disposableAllDevices = clientApi.getAllDevices(header) |
|
|
|
.subscribeOn(Schedulers.newThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(listDevices -> { |
|
|
|
String brandModel = brand + SPACE + model + SPACE; |
|
|
|
final List<Device> list = listDevices; |
|
|
@@ -377,6 +383,7 @@ public class DataRepository { |
|
|
|
final Disposable disposableAddDevice = clientApi.addDevice(header, body) |
|
|
|
.subscribeOn(Schedulers.newThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(device -> { |
|
|
|
deviceID = device.getUuid(); |
|
|
|
getCertificate(context).observe((LifecycleOwner) context, new Observer<StatusResource<byte[]>>() { |
|
|
@@ -430,6 +437,7 @@ public class DataRepository { |
|
|
|
Disposable disposableAddDevice = clientApi.addDevice(header, body) |
|
|
|
.subscribeOn(Schedulers.newThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(device -> { |
|
|
|
DataRepository.deviceName = device.getName(); |
|
|
|
DataRepository.deviceID = device.getUuid(); |
|
|
@@ -627,6 +635,7 @@ public class DataRepository { |
|
|
|
final Disposable certificateDisposable = clientApi.getCertificate() |
|
|
|
.subscribeOn(Schedulers.newThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.retry((attempts, error) -> attempts < 5 && error instanceof IOException) |
|
|
|
.subscribe(certificate -> { |
|
|
|
final InputStream inputStream = certificate.byteStream(); |
|
|
|
final Scanner scanner = new Scanner(inputStream).useDelimiter(DELIMITER); |
|
|
|