Modificato server status checker.
This commit is contained in:
parent
e3cba49b0f
commit
0a331b30c7
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -95,11 +95,12 @@ dependencies {
|
||||
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha02'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha03'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha02'
|
||||
implementation 'androidx.preference:preference:1.1.0-alpha02'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.0.0'
|
||||
implementation 'com.annimon:stream:1.2.1'
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.REST.consumers.ISingleValueOperationCallback;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityServer;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
@ -14,11 +15,11 @@ public class ServerStatusChecker {
|
||||
|
||||
private static ServerStatusChecker istance = new ServerStatusChecker();
|
||||
|
||||
private List<ISingleValueOperationCallback<Boolean>> mCallback = new ArrayList<>();
|
||||
private List<RunnableArgs<Boolean>> mCallback = new ArrayList<>();
|
||||
|
||||
private ISingleValueOperationCallback<Boolean> mInternalCallback = value -> {
|
||||
for (ISingleValueOperationCallback callback : mCallback) {
|
||||
callback.onResult(value);
|
||||
private RunnableArgs<Boolean> mInternalCallback = value -> {
|
||||
for (RunnableArgs callback : mCallback) {
|
||||
callback.run(value);
|
||||
}
|
||||
};
|
||||
|
||||
@ -31,18 +32,18 @@ public class ServerStatusChecker {
|
||||
@Override
|
||||
public void run() {
|
||||
if(shouldExecute && !UtilityString.isNullOrEmpty(SettingsManager.i().server.host)) {
|
||||
UtilityServer.isHostReachable(SettingsManager.i().server.host, SettingsManager.i().server.port, mInternalCallback);
|
||||
UtilityServer.isEmsApiAvailable(SettingsManager.i().server.host, SettingsManager.i().server.port, mInternalCallback);
|
||||
handler.postDelayed(this, MILLIS_DELAY);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void addCallback(ISingleValueOperationCallback<Boolean> callback){
|
||||
public void addCallback(RunnableArgs<Boolean> callback){
|
||||
this.mCallback.add(callback);
|
||||
|
||||
}
|
||||
|
||||
public void removeCallback(ISingleValueOperationCallback<Boolean> callback){
|
||||
public void removeCallback(RunnableArgs<Boolean> callback){
|
||||
this.mCallback.remove(callback);
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,10 @@ import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import it.integry.integrywmsnative.core.REST.consumers.ISingleValueOperationCallback;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class UtilityServer {
|
||||
|
||||
@ -31,8 +35,26 @@ public class UtilityServer {
|
||||
callback.onResult(connected);
|
||||
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static void isEmsApiAvailable(final String serverAddress, final int serverTCPport, final RunnableArgs<Boolean> callback) {
|
||||
new Thread(() -> {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(String.format("http://%s:%d/ems-api/retail/status", serverAddress, serverTCPport))
|
||||
.build();
|
||||
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
boolean status = response.isSuccessful();
|
||||
response.close();
|
||||
callback.run(status);
|
||||
} catch (IOException e) {
|
||||
callback.run(false);
|
||||
}
|
||||
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ public class LoginViewModel {
|
||||
final String host = u.getHost();
|
||||
final int port = u.getPort();
|
||||
|
||||
UtilityServer.isHostReachable(host, port, value1 -> {
|
||||
UtilityServer.isEmsApiAvailable(host, port, value1 -> {
|
||||
|
||||
if(value1){ //Is online
|
||||
loginHelper.doLogin(host, port, new ISimpleOperationCallback<LoginDTO>() {
|
||||
|
||||
@ -9,6 +9,8 @@ import android.text.SpannableString;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.tfb.fbtoast.FBToast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -807,7 +809,7 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
}
|
||||
|
||||
|
||||
private void cyclicPrint(Iterator<MtbColt> sourceMtbColts, String printerName, Runnable onComplete, RunnableArgs<Exception> onAbort) {
|
||||
private void cyclicPrint(@NotNull Iterator<MtbColt> sourceMtbColts, String printerName, Runnable onComplete, RunnableArgs<Exception> onAbort) {
|
||||
if(sourceMtbColts.hasNext()){
|
||||
singlePrint(sourceMtbColts.next(), printerName, () -> {
|
||||
cyclicPrint(sourceMtbColts, printerName, onComplete, onAbort);
|
||||
@ -899,7 +901,7 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
|
||||
List<MtbColr> filteredMtbColrs = Stream.of(currentMtbColrs).filter(
|
||||
x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()) &&
|
||||
(x.getPartitaMag() != null && x.getPartitaMag().equalsIgnoreCase(item.getPartitaMag())))
|
||||
(!SettingsManager.iDB().isEnableCheckPartitaMagCheckPickingV() || (SettingsManager.iDB().isEnableCheckPartitaMagCheckPickingV() && ((x.getPartitaMag() == null && item.getPartitaMag() == null) || (x.getPartitaMag() != null && x.getPartitaMag().equalsIgnoreCase(item.getPartitaMag()))))))
|
||||
.toList();
|
||||
|
||||
float qtaEvasaTotaleInMtbColr = 0;
|
||||
|
||||
@ -22,6 +22,8 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@ -218,7 +220,7 @@ public class DialogInputQuantity {
|
||||
return new DialogInputQuantity(context, dto, canOverflowQuantity, dialogCallback, onAbort).currentAlert;
|
||||
}
|
||||
|
||||
public DialogInputQuantity(Context context, final DTO dto, boolean canOverflowQuantity, final ISingleValueOperationCallback<QuantityDTO> dialogCallback, final Runnable onAbort) {
|
||||
public DialogInputQuantity(@NotNull Context context, @NotNull final DTO dto, boolean canOverflowQuantity, final ISingleValueOperationCallback<QuantityDTO> dialogCallback, final Runnable onAbort) {
|
||||
currentContext = context;
|
||||
currentMtbAart = dto.getMtbAart();
|
||||
currentDTO = dto;
|
||||
@ -288,7 +290,7 @@ public class DialogInputQuantity {
|
||||
setupBarcode(context);
|
||||
}
|
||||
|
||||
private void setupQuantities(DTO dto, QuantityDTO quantityDTO){
|
||||
private void setupQuantities(@NotNull DTO dto, QuantityDTO quantityDTO){
|
||||
if(dto.getQtaTot() != null) quantityDTO.qtaTot.set(dto.getQtaTot().floatValue());
|
||||
if(dto.getMaxQta() != null) quantityDTO.maxQta.set(dto.getMaxQta().floatValue());
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/gray_detail_background"
|
||||
android:padding="0dp"
|
||||
app:el_duration="400"
|
||||
app:el_expanded="false">
|
||||
|
||||
@ -27,7 +28,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/red_600"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp">
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user