Migliorie rendering UI

This commit is contained in:
2025-06-05 19:40:02 +02:00
parent 143b8a5bda
commit 3a8debdbc4
24 changed files with 532 additions and 208 deletions

View File

@@ -0,0 +1,119 @@
package it.integry.integrywmsnative.core.di;
import androidx.lifecycle.MutableLiveData;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
public class MutableListLiveData<T> extends MutableLiveData<List<T>> {
public MutableListLiveData() {
super(new ArrayList<>());
}
public MutableListLiveData(List<T> initialValue) {
super(initialValue);
}
public void add(T item, boolean immediateSet) {
List<T> current = getValue();
List<T> newList = new ArrayList<>(current);
newList.add(item);
if(immediateSet)
setValue(newList);
else postValue(newList);
}
public void add(T item) {
add(item, false);
}
public void add(int index, T item, boolean immediateSet) {
List<T> current = getValue();
List<T> newList = new ArrayList<>(current);
newList.add(index, item);
if(immediateSet)
setValue(newList);
else postValue(newList);
}
public void add(int index, T item) {
add(index, item, false);
}
public void remove(T item, boolean immediateSet) {
List<T> current = getValue();
List<T> newList = new ArrayList<>(current);
newList.remove(item);
if(immediateSet)
setValue(newList);
else postValue(newList);
}
public void remove(T item) {
remove(item, false);
}
public void update(Consumer<List<T>> updater) {
List<T> current = getValue();
List<T> newList = new ArrayList<>(current);
updater.accept(newList);
postValue(newList);
}
public void clear() {
List<T> newList = new ArrayList<>();
postValue(newList);
}
public void addAll(List<T> items) {
List<T> current = getValue();
List<T> newList = new ArrayList<>(current);
newList.addAll(items);
postValue(newList);
}
public MutableListLiveData<T> clone() {
MutableListLiveData<T> clone = new MutableListLiveData<>();
List<T> current = getValue();
if (current != null) {
clone.postValue(new ArrayList<>(current));
}
return clone;
}
public boolean isEmpty() {
List<T> current = getValue();
return current == null || current.isEmpty();
}
public T get(int index) {
List<T> current = getValue();
if (current != null && index >= 0 && index < current.size()) {
return current.get(index);
}
return null;
}
public int size() {
List<T> current = getValue();
return current != null ? current.size() : 0;
}
public java.util.stream.Stream<T> stream() {
List<T> current = getValue();
return current != null ? current.stream() : java.util.stream.Stream.empty();
}
public void removeAll(Collection<T> items) {
List<T> current = getValue();
List<T> newList = new ArrayList<>(current);
newList.removeAll(items);
postValue(newList);
}
}

View File

@@ -0,0 +1,84 @@
package it.integry.integrywmsnative.core.di;
import android.os.Handler;
import android.os.Looper;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
/**
* Classe che gestisce la serializzazione e deserializzazione di MutableListLiveData con Gson
*
* @param <T> tipo degli elementi nella lista
*/
public class MutableListLiveDataTypeAdapter<T> implements JsonSerializer<MutableListLiveData<T>>, JsonDeserializer<MutableListLiveData<T>> {
private final Handler handler = new Handler(Looper.getMainLooper());
/**
* Serializza un oggetto MutableListLiveData in un JsonElement
*/
@Override
public JsonElement serialize(MutableListLiveData<T> src, Type typeOfSrc, JsonSerializationContext context) {
// Ottiene la lista interna da MutableListLiveData e la serializza
List<T> list = src.getValue();
return context.serialize(list);
}
/**
* Deserializza un JsonElement in un oggetto MutableListLiveData
*/
@Override
public MutableListLiveData<T> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
// Determina il tipo degli elementi nella lista
Type listType = getListType(typeOfT);
// Deserializza il JsonElement in una lista
List<T> list = context.deserialize(json, listType);
if (list == null) {
list = new ArrayList<>();
}
// Crea una nuova istanza di MutableListLiveData e aggiunge tutti gli elementi
MutableListLiveData<T> result = new MutableListLiveData<>(list);
return result;
}
/**
* Estrae il tipo della lista da un tipo parametrizzato di MutableListLiveData<T>
*/
private Type getListType(Type mutableListLiveDataType) {
if (mutableListLiveDataType instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) mutableListLiveDataType;
Type[] typeArguments = parameterizedType.getActualTypeArguments();
if (typeArguments.length > 0) {
// Crea un tipo di List<T> usando il parametro di tipo T
return TypeToken.getParameterized(List.class, typeArguments[0]).getType();
}
}
// Fallback per List<Object> se non riusciamo a determinare il tipo
return TypeToken.getParameterized(List.class, Object.class).getType();
}
/**
* Crea un'istanza del TypeAdapter per MutableListLiveData<T>
*
* @param elementType il tipo T degli elementi nella lista
* @return un'istanza del TypeAdapter
*/
public static <T> MutableListLiveDataTypeAdapter<T> create(Type elementType) {
return new MutableListLiveDataTypeAdapter<>();
}
}

View File

@@ -0,0 +1,41 @@
package it.integry.integrywmsnative.core.diff;
import androidx.recyclerview.widget.DiffUtil;
import java.util.List;
import it.integry.integrywmsnative.core.model.MtbColr;
public class MtbColrDiffCallback extends DiffUtil.Callback {
private final List<MtbColr> oldList;
private final List<MtbColr> newList;
public MtbColrDiffCallback(List<MtbColr> oldList, List<MtbColr> newList) {
this.oldList = oldList;
this.newList = newList;
}
@Override
public int getOldListSize() {
return oldList.size();
}
@Override
public int getNewListSize() {
return newList.size();
}
@Override
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
MtbColr oldItem = oldList.get(oldItemPosition);
MtbColr newItem = newList.get(newItemPosition);
return oldItem.getKey().equals(newItem.getKey()); // Placeholder, idealmente confrontare ID univoci
}
@Override
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
// Assicurarsi che MtbColr.equals() confronti i contenuti rilevanti per la UI
return oldList.get(oldItemPosition).equals(newList.get(newItemPosition));
}
}

View File

@@ -4,7 +4,11 @@ import com.google.gson.annotations.SerializedName;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date; import java.util.Date;
import java.util.Objects;
import it.integry.integrywmsnative.core.exception.DateNotRecognizedException;
import it.integry.integrywmsnative.core.exception.TimeNotRecognizedException;
import it.integry.integrywmsnative.core.model.key.MtbColrKey;
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityDate;
@@ -180,6 +184,9 @@ public class MtbColr extends EntityBase {
// this.refMtbColr = other.refMtbColr; // this.refMtbColr = other.refMtbColr;
} }
public MtbColrKey getKey() {
return new MtbColrKey(gestione, serCollo, getDataColloLD(), numCollo, riga);
}
public static class Causale { public static class Causale {
public static final int DEFAULT = 0; public static final int DEFAULT = 0;
@@ -233,6 +240,14 @@ public class MtbColr extends EntityBase {
return UtilityDate.recognizeDateWithExceptionHandler(getDataColloS()); return UtilityDate.recognizeDateWithExceptionHandler(getDataColloS());
} }
public LocalDate getDataColloLD() {
try {
return UtilityDate.recognizeLocalDate(getDataColloS());
} catch (DateNotRecognizedException | TimeNotRecognizedException e) {
throw new RuntimeException(e);
}
}
public MtbColr setDataCollo(String dataCollo) { public MtbColr setDataCollo(String dataCollo) {
this.dataCollo = dataCollo; this.dataCollo = dataCollo;
return this; return this;
@@ -693,4 +708,107 @@ public class MtbColr extends EntityBase {
this.posizioneOut = posizioneOut; this.posizioneOut = posizioneOut;
return this; return this;
} }
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
MtbColr mtbColr = (MtbColr) o;
return Objects.equals(getGestione(), mtbColr.getGestione()) &&
Objects.equals(getSerCollo(), mtbColr.getSerCollo()) &&
Objects.equals(getNumCollo(), mtbColr.getNumCollo()) &&
Objects.equals(getDataCollo(), mtbColr.getDataCollo()) &&
Objects.equals(getRiga(), mtbColr.getRiga()) &&
Objects.equals(getRigaOrd(), mtbColr.getRigaOrd()) &&
Objects.equals(getCodMart(), mtbColr.getCodMart()) &&
Objects.equals(getCodBarre(), mtbColr.getCodBarre()) &&
Objects.equals(getCodCol(), mtbColr.getCodCol()) &&
Objects.equals(getCodTagl(), mtbColr.getCodTagl()) &&
Objects.equals(getPartitaMag(), mtbColr.getPartitaMag()) &&
Objects.equals(getGestioneRif(), mtbColr.getGestioneRif()) &&
Objects.equals(getSerColloRif(), mtbColr.getSerColloRif()) &&
Objects.equals(getNote(), mtbColr.getNote()) &&
Objects.equals(getDataOrd(), mtbColr.getDataOrd()) &&
Objects.equals(getDataColloRif(), mtbColr.getDataColloRif()) &&
Objects.equals(getQtaCnf(), mtbColr.getQtaCnf()) &&
Objects.equals(getQtaCol(), mtbColr.getQtaCol()) &&
Objects.equals(getNumOrd(), mtbColr.getNumOrd()) &&
Objects.equals(getNumEtich(), mtbColr.getNumEtich()) &&
Objects.equals(getNumColloRif(), mtbColr.getNumColloRif()) &&
Objects.equals(getDatetimeRow(), mtbColr.getDatetimeRow()) &&
Objects.equals(getCodJcom(), mtbColr.getCodJcom()) &&
Objects.equals(getNumCnf(), mtbColr.getNumCnf()) &&
Objects.equals(getInsPartitaMag(), mtbColr.getInsPartitaMag()) &&
Objects.equals(getMtbPartitaMag_descrizione(), mtbColr.getMtbPartitaMag_descrizione()) &&
Objects.equals(getDataScadPartita(), mtbColr.getDataScadPartita()) &&
Objects.equals(getDescrizione(), mtbColr.getDescrizione()) &&
Objects.equals(getUntMis(), mtbColr.getUntMis()) &&
Objects.equals(getCausale(), mtbColr.getCausale()) &&
Objects.equals(getUtente(), mtbColr.getUtente()) &&
Objects.equals(getCodAnagDoc(), mtbColr.getCodAnagDoc()) &&
Objects.equals(getCodDtipDoc(), mtbColr.getCodDtipDoc()) &&
Objects.equals(getDataDoc(), mtbColr.getDataDoc()) &&
Objects.equals(getSerDoc(), mtbColr.getSerDoc()) &&
Objects.equals(getNumDoc(), mtbColr.getNumDoc()) &&
Objects.equals(getIdRigaDoc(), mtbColr.getIdRigaDoc()) &&
Objects.equals(getPesoNettoKg(), mtbColr.getPesoNettoKg()) &&
Objects.equals(getPesoLordoKg(), mtbColr.getPesoLordoKg()) &&
Objects.equals(getBarcodeUlIn(), mtbColr.getBarcodeUlIn()) &&
Objects.equals(getBarcodeUlOut(), mtbColr.getBarcodeUlOut()) &&
Objects.equals(getCodMdepIn(), mtbColr.getCodMdepIn()) &&
Objects.equals(getCodMdepOut(), mtbColr.getCodMdepOut()) &&
Objects.equals(getPosizioneIn(), mtbColr.getPosizioneIn()) &&
Objects.equals(getPosizioneOut(), mtbColr.getPosizioneOut());
}
@Override
public int hashCode() {
int result = Objects.hashCode(getGestione());
result = 31 * result + Objects.hashCode(getSerCollo());
result = 31 * result + Objects.hashCode(getNumCollo());
result = 31 * result + Objects.hashCode(getDataCollo());
result = 31 * result + Objects.hashCode(getRiga());
result = 31 * result + Objects.hashCode(getRigaOrd());
result = 31 * result + Objects.hashCode(getCodMart());
result = 31 * result + Objects.hashCode(getCodBarre());
result = 31 * result + Objects.hashCode(getCodCol());
result = 31 * result + Objects.hashCode(getCodTagl());
result = 31 * result + Objects.hashCode(getPartitaMag());
result = 31 * result + Objects.hashCode(getGestioneRif());
result = 31 * result + Objects.hashCode(getSerColloRif());
result = 31 * result + Objects.hashCode(getNote());
result = 31 * result + Objects.hashCode(getDataOrd());
result = 31 * result + Objects.hashCode(getDataColloRif());
result = 31 * result + Objects.hashCode(getQtaCnf());
result = 31 * result + Objects.hashCode(getQtaCol());
result = 31 * result + Objects.hashCode(getNumOrd());
result = 31 * result + Objects.hashCode(getNumEtich());
result = 31 * result + Objects.hashCode(getNumColloRif());
result = 31 * result + Objects.hashCode(getDatetimeRow());
result = 31 * result + Objects.hashCode(getCodJcom());
result = 31 * result + Objects.hashCode(getNumCnf());
result = 31 * result + Objects.hashCode(getInsPartitaMag());
result = 31 * result + Objects.hashCode(getMtbPartitaMag_descrizione());
result = 31 * result + Objects.hashCode(getDataScadPartita());
result = 31 * result + Objects.hashCode(getDescrizione());
result = 31 * result + Objects.hashCode(getUntMis());
result = 31 * result + Objects.hashCode(getCausale());
result = 31 * result + Objects.hashCode(getUtente());
result = 31 * result + Objects.hashCode(getCodAnagDoc());
result = 31 * result + Objects.hashCode(getCodDtipDoc());
result = 31 * result + Objects.hashCode(getDataDoc());
result = 31 * result + Objects.hashCode(getSerDoc());
result = 31 * result + Objects.hashCode(getNumDoc());
result = 31 * result + Objects.hashCode(getIdRigaDoc());
result = 31 * result + Objects.hashCode(getPesoNettoKg());
result = 31 * result + Objects.hashCode(getPesoLordoKg());
result = 31 * result + Objects.hashCode(getBarcodeUlIn());
result = 31 * result + Objects.hashCode(getBarcodeUlOut());
result = 31 * result + Objects.hashCode(getCodMdepIn());
result = 31 * result + Objects.hashCode(getCodMdepOut());
result = 31 * result + Objects.hashCode(getPosizioneIn());
result = 31 * result + Objects.hashCode(getPosizioneOut());
return result;
}
} }

View File

@@ -2,6 +2,7 @@ package it.integry.integrywmsnative.core.model;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList; import androidx.databinding.ObservableArrayList;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
@@ -684,6 +685,7 @@ public class MtbColt extends EntityBase {
} }
@NonNull
@Override @Override
public EntityBase clone() { public EntityBase clone() {
return clone(true); return clone(true);

View File

@@ -5,6 +5,7 @@ import com.google.gson.annotations.SerializedName;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Objects;
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
@@ -63,23 +64,34 @@ public class OrdineInevasoDTO {
return this; return this;
} }
public boolean equalsKey(OrdineInevasoDTO that) {
if (that == null) return false;
return this.dataOrd.equals(that.dataOrd) &&
this.numOrd.equals(that.numOrd) &&
StringUtils.equalsIgnoreCase(this.codMdep, that.codMdep);
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
OrdineInevasoDTO that = (OrdineInevasoDTO) o; OrdineInevasoDTO that = (OrdineInevasoDTO) o;
return getDataOrd().equals(that.getDataOrd()) &&
getNumOrd().equals(that.getNumOrd()) && if(!equalsKey(that)) return false;
getGestione().equals(that.getGestione()) && return StringUtils.equalsIgnoreCase(getCodMdep(), that.getCodMdep());
StringUtils.equalsIgnoreCase(getCodMdep(), that.getCodMdep()); }
public int hashCodeKey() {
int result = getDataOrd().hashCode();
result = 31 * result + getNumOrd().hashCode();
result = 31 * result + getGestione().hashCode();
return result;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = getDataOrd().hashCode(); int result = hashCodeKey();
result = 31 * result + getNumOrd().hashCode(); result = 31 * result + Objects.hashCode(getCodMdep());
result = 31 * result + getGestione().hashCode();
result = 31 * result + getCodMdep().hashCode();
return result; return result;
} }
} }

View File

@@ -0,0 +1,33 @@
package it.integry.integrywmsnative.core.model.key;
import java.time.LocalDate;
public class MtbColrKey extends MtbColtKey{
private final int riga;
public MtbColrKey(String gestione, String serCollo, LocalDate dataCollo, int numCollo, int riga) {
super(gestione, serCollo, dataCollo, numCollo);
this.riga = riga;
}
public Integer getRiga() {
return riga;
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
MtbColrKey that = (MtbColrKey) o;
return getRiga().equals(that.getRiga());
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + getRiga().hashCode();
return result;
}
}

View File

@@ -8,9 +8,9 @@ public class MtbColtKey {
private final String gestione; private final String gestione;
private final String serCollo; private final String serCollo;
private final LocalDate dataCollo; private final LocalDate dataCollo;
private final Integer numCollo; private final int numCollo;
public MtbColtKey(String gestione, String serCollo, LocalDate dataCollo, Integer numCollo) { public MtbColtKey(String gestione, String serCollo, LocalDate dataCollo, int numCollo) {
this.gestione = gestione; this.gestione = gestione;
this.serCollo = serCollo; this.serCollo = serCollo;
this.dataCollo = dataCollo; this.dataCollo = dataCollo;
@@ -29,7 +29,7 @@ public class MtbColtKey {
return dataCollo; return dataCollo;
} }
public Integer getNumCollo() { public int getNumCollo() {
return numCollo; return numCollo;
} }

View File

@@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.rest; package it.integry.integrywmsnative.core.rest;
import android.annotation.SuppressLint;
import com.google.gson.Gson; import com.google.gson.Gson;
import java.security.KeyManagementException; import java.security.KeyManagementException;
@@ -27,32 +29,14 @@ public class RESTBuilder {
private final boolean ADD_LOGGER_INTERCEPTOR = false; private final boolean ADD_LOGGER_INTERCEPTOR = false;
private final AuthInterceptor authInterceptor; private final AuthInterceptor authInterceptor;
private final OkHttpClient client;
private final Gson gson;
public RESTBuilder(AuthInterceptor authInterceptor) { public RESTBuilder(AuthInterceptor authInterceptor) {
this.authInterceptor = authInterceptor; this.authInterceptor = authInterceptor;
}
public <T> T getService(final Class<T> service) {
return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true);
}
public <T> T getService(final Class<T> service, int timeout) {
return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true, true, timeout);
}
public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors) {
return getService(service, protocol, host, port, addInterceptors, true, 60);
}
public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi) {
return getService(service, protocol, host, port, addInterceptors, addEmsApi, 60);
}
public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi, int timeout) {
OkHttpClient.Builder clientBuilder = getDefaultHttpClient(); OkHttpClient.Builder clientBuilder = getDefaultHttpClient();
int timeout = 0;
timeout = 0;
clientBuilder.connectTimeout(timeout, TimeUnit.SECONDS); clientBuilder.connectTimeout(timeout, TimeUnit.SECONDS);
clientBuilder.readTimeout(timeout, TimeUnit.SECONDS); clientBuilder.readTimeout(timeout, TimeUnit.SECONDS);
@@ -62,16 +46,26 @@ public class RESTBuilder {
clientBuilder.retryOnConnectionFailure(true); clientBuilder.retryOnConnectionFailure(true);
clientBuilder.addInterceptor(authInterceptor); clientBuilder.addInterceptor(authInterceptor);
if (addInterceptors) clientBuilder.addInterceptor(new HttpInterceptor()); clientBuilder.addInterceptor(new HttpInterceptor());
if (ADD_LOGGER_INTERCEPTOR) clientBuilder.addInterceptor(new HttpLoggerInterceptor()); if (ADD_LOGGER_INTERCEPTOR) clientBuilder.addInterceptor(new HttpLoggerInterceptor());
client = clientBuilder.build();
OkHttpClient client = clientBuilder.build(); gson = UtilityGson.createObject();
}
public <T> T getService(final Class<T> service) {
return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true);
}
public <T> T getService(final Class<T> service, String protocol, String host, int port) {
return getService(service, protocol, host, port, true);
}
public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addEmsApi) {
String endpoint = protocol + "://" + host + (port > 0 ? ":" + port : "") + "/" + (addEmsApi ? "ems-api/" : ""); String endpoint = protocol + "://" + host + (port > 0 ? ":" + port : "") + "/" + (addEmsApi ? "ems-api/" : "");
Gson gson = UtilityGson.createObject();
Retrofit retrofit = new Retrofit.Builder() Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create(gson)) .addConverterFactory(GsonConverterFactory.create(gson))
.baseUrl(endpoint) .baseUrl(endpoint)
@@ -83,12 +77,15 @@ public class RESTBuilder {
public static OkHttpClient.Builder getDefaultHttpClient() { public static OkHttpClient.Builder getDefaultHttpClient() {
@SuppressLint("CustomX509TrustManager")
TrustManager[] trustAllCerts = new TrustManager[]{ TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() { new X509TrustManager() {
@SuppressLint("TrustAllX509TrustManager")
@Override @Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) { public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) {
} }
@SuppressLint("TrustAllX509TrustManager")
@Override @Override
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) { public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) {
} }
@@ -109,10 +106,8 @@ public class RESTBuilder {
} }
OkHttpClient.Builder client = new OkHttpClient.Builder() return new OkHttpClient.Builder()
.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0]) .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
.hostnameVerifier((hostname, session) -> true); .hostnameVerifier((hostname, session) -> true);
return client;
} }
} }

View File

@@ -21,7 +21,7 @@ public class GiacenzaPvRESTConsumer extends _BaseRESTConsumer {
public List<GiacenzaPvDTO> retrieveGiacenzeSynchronized(String codMdep) throws Exception { public List<GiacenzaPvDTO> retrieveGiacenzeSynchronized(String codMdep) throws Exception {
GiacenzaPvRESTConsumerService giacenzaPvRESTConsumerService = restBuilder.getService(GiacenzaPvRESTConsumerService.class, 120); GiacenzaPvRESTConsumerService giacenzaPvRESTConsumerService = restBuilder.getService(GiacenzaPvRESTConsumerService.class);
var response = giacenzaPvRESTConsumerService.retrieve(codMdep) var response = giacenzaPvRESTConsumerService.retrieve(codMdep)
.execute(); .execute();
@@ -31,7 +31,7 @@ public class GiacenzaPvRESTConsumer extends _BaseRESTConsumer {
} }
public void saveNewVerificaSynchronized(SaveNewVerificaRequestDTO saveNewVerificaRequest) throws Exception { public void saveNewVerificaSynchronized(SaveNewVerificaRequestDTO saveNewVerificaRequest) throws Exception {
GiacenzaPvRESTConsumerService giacenzaPvRESTConsumerService = restBuilder.getService(GiacenzaPvRESTConsumerService.class, 0); GiacenzaPvRESTConsumerService giacenzaPvRESTConsumerService = restBuilder.getService(GiacenzaPvRESTConsumerService.class);
var response = giacenzaPvRESTConsumerService.saveNewVerifica(saveNewVerificaRequest) var response = giacenzaPvRESTConsumerService.saveNewVerifica(saveNewVerificaRequest)
.execute(); .execute();

View File

@@ -62,7 +62,7 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer {
} }
public List<MtbInvent> makeSynchronousRetrieveRequest() throws Exception { public List<MtbInvent> makeSynchronousRetrieveRequest() throws Exception {
var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class, 120); var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class);
var response = inventarioRESTConsumerService.retrieve() var response = inventarioRESTConsumerService.retrieve()
.execute(); .execute();
@@ -77,7 +77,7 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer {
var request = new InsertInventarioRequestDTO() var request = new InsertInventarioRequestDTO()
.setMtbInvent(inventarioToInsert); .setMtbInvent(inventarioToInsert);
var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class, 300); var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class);
inventarioRESTConsumerService inventarioRESTConsumerService
.insert(inventarioToInsert.getIdInventario(), request) .insert(inventarioToInsert.getIdInventario(), request)
.enqueue(new ManagedErrorCallback<>() { .enqueue(new ManagedErrorCallback<>() {

View File

@@ -49,7 +49,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
} }
public void getSuggestedPickingList(String codMdep, List<SitArtOrdDTO> sitArtOrdList, RunnableArgs<List<PickingObjectDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getSuggestedPickingList(String codMdep, List<SitArtOrdDTO> sitArtOrdList, RunnableArgs<List<PickingObjectDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class, 90); OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class);
service service
.getSuggestedPickingList(codMdep, sitArtOrdList) .getSuggestedPickingList(codMdep, sitArtOrdList)
.enqueue(new ManagedErrorCallback<>() { .enqueue(new ManagedErrorCallback<>() {
@@ -154,7 +154,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
.setIdViaggio(x.getIdViaggio())) .setIdViaggio(x.getIdViaggio()))
.toList(); .toList();
OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class, 90); OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class);
service.getArticoliFromOrdini(codMdep, getPickingListDTOs).enqueue(new ManagedErrorCallback<>() { service.getArticoliFromOrdini(codMdep, getPickingListDTOs).enqueue(new ManagedErrorCallback<>() {
@Override @Override

View File

@@ -37,7 +37,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
} }
public void retrieveArticoli(String codAlis, String codMdep, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) { public void retrieveArticoli(String codAlis, String codMdep, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class);
ordiniARestService.retrieveArticoli(codAlis, codMdep, null) ordiniARestService.retrieveArticoli(codAlis, codMdep, null)
.enqueue(new ManagedErrorCallback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
@@ -57,7 +57,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
} }
public void retrieveArticolo(String codAlis, String codMdep, String barcode, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) { public void retrieveArticolo(String codAlis, String codMdep, String barcode, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class);
ordiniARestService.retrieveArticoli(codAlis, codMdep, barcode) ordiniARestService.retrieveArticoli(codAlis, codMdep, barcode)
.enqueue(new ManagedErrorCallback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
@@ -92,7 +92,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
saveDTO.setGestione("O"); saveDTO.setGestione("O");
saveDTO.setOrdineDTO(ordineDTO); saveDTO.setOrdineDTO(ordineDTO);
PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class);
ordiniARestService.save(codMdep, saveDTO) ordiniARestService.save(codMdep, saveDTO)
.enqueue(new ManagedErrorCallback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override

View File

@@ -125,10 +125,10 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
public void printClosedOrdersSynchronized(PrintOrderCloseDTO dto, String codMdep) throws Exception { public void printClosedOrdersSynchronized(PrintOrderCloseDTO dto, String codMdep) throws Exception {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
// return; return;
} }
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class, 240); PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
var response = printerService.printClosedOrders(codMdep, dto).execute(); var response = printerService.printClosedOrders(codMdep, dto).execute();
analyzeAnswer(response, "printCollo"); analyzeAnswer(response, "printCollo");

View File

@@ -63,7 +63,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
} }
public void avviaProduzioneArticoloSuLinea(String codJfas, String codMart, String partitaMag, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void avviaProduzioneArticoloSuLinea(String codJfas, String codMart, String partitaMag, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class, 300); ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> callable = restService.avviaProduzioneArticoloSuLinea(codJfas, codMart, partitaMag); Call<ServiceRESTResponse<JsonObject>> callable = restService.avviaProduzioneArticoloSuLinea(codJfas, codMart, partitaMag);
callable.enqueue(new ManagedErrorCallback<>() { callable.enqueue(new ManagedErrorCallback<>() {
@Override @Override

View File

@@ -9,6 +9,8 @@ import java.lang.reflect.Modifier;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import it.integry.integrywmsnative.core.di.MutableListLiveData;
import it.integry.integrywmsnative.core.di.MutableListLiveDataTypeAdapter;
import it.integry.integrywmsnative.core.model.MtbTCol; import it.integry.integrywmsnative.core.model.MtbTCol;
import it.integry.integrywmsnative.core.model.secondary.StatoPartitaMag; import it.integry.integrywmsnative.core.model.secondary.StatoPartitaMag;
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateDeserializer; import it.integry.integrywmsnative.core.rest.deserializer.LocalDateDeserializer;
@@ -28,6 +30,7 @@ public class UtilityGson {
return new GsonBuilder() return new GsonBuilder()
.setDateFormat("dd/MM/yyyy HH:mm:ss") .setDateFormat("dd/MM/yyyy HH:mm:ss")
.excludeFieldsWithModifiers(Modifier.TRANSIENT) .excludeFieldsWithModifiers(Modifier.TRANSIENT)
.registerTypeAdapter(MutableListLiveData.class, new MutableListLiveDataTypeAdapter<>())
.registerTypeAdapter(MutableLiveData.class, new MutableLiveDataDeserializer()) .registerTypeAdapter(MutableLiveData.class, new MutableLiveDataDeserializer())
.registerTypeAdapter(MutableLiveData.class, new MutableLiveDataSerializer()) .registerTypeAdapter(MutableLiveData.class, new MutableLiveDataSerializer())
.registerTypeAdapter(LocalDate.class, new LocalDateDeserializer()) .registerTypeAdapter(LocalDate.class, new LocalDateDeserializer())

View File

@@ -34,7 +34,7 @@ public class AuthenticationRESTConsumer extends _BaseRESTConsumer {
String host = CommonConst.Login.Azienda.host; String host = CommonConst.Login.Azienda.host;
int port = CommonConst.Login.Azienda.port; int port = CommonConst.Login.Azienda.port;
AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class, protocol, host, port, false, true); AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class, protocol, host, port);
service.loginAzienda(codAzienda).enqueue(new ManagedErrorCallback<>() { service.loginAzienda(codAzienda).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Response<ServiceRESTResponse<LoginAziendaDTO>> response) { public void onResponse(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Response<ServiceRESTResponse<LoginAziendaDTO>> response) {

View File

@@ -190,6 +190,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
this.initJtbComtCache(); this.initJtbComtCache();
mAppliedFilterViewModel.init(data); mAppliedFilterViewModel.init(data);
// this.refreshList(data, null); // this.refreshList(data, null);
this.onLoadingEnded(); this.onLoadingEnded();
@@ -209,7 +210,9 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep(); String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
mViewModel.init(codMdep, mCurrentGestioneOrd, mCurrentGestioneCol, mCurrentSegnoCol, this::onLoadingEnded); mViewModel.init(codMdep, mCurrentGestioneOrd, mCurrentGestioneCol, mCurrentSegnoCol, () -> {
this.onLoadingEnded();
});
Log.d("onStart", "Ended"); Log.d("onStart", "Ended");
} }
@@ -233,7 +236,10 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
var orderElementItemType = new Type<OrdiniUscitaElencoDTO, FragmentMainOrdiniUscitaListGroupModelBinding>( var orderElementItemType = new Type<OrdiniUscitaElencoDTO, FragmentMainOrdiniUscitaListGroupModelBinding>(
R.layout.fragment_main_ordini_uscita__list_group_model, R.layout.fragment_main_ordini_uscita__list_group_model,
it.integry.integrywmsnative.BR.item); it.integry.integrywmsnative.BR.item)
.areItemSame((item1, item2) -> item1.hashCodeKey() == item2.hashCodeKey() && item1.equalsKey(item2))
.areContentsTheSame((item1, item2) -> item1.hashCode() == item2.hashCode() && item1.equals(item2));
orderElementItemType.onClick(holder -> { orderElementItemType.onClick(holder -> {
holder.getBinding().getItem().getSelectedProperty().toggle(); holder.getBinding().getItem().getSelectedProperty().toggle();
@@ -275,7 +281,8 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
var mutableFilteredOrderListWithSeparators = new MutableLiveData<List<Object>>(); var mutableFilteredOrderListWithSeparators = new MutableLiveData<List<Object>>();
this.mAppliedFilterViewModel.getMutableFilteredOrderList().observe(this, orderList -> { this.mAppliedFilterViewModel.getMutableFilteredOrderList().observe(getViewLifecycleOwner(), orderList -> {
List<Object> listWithSeparators = new ArrayList<>(); List<Object> listWithSeparators = new ArrayList<>();
String lastRagSoc = null; String lastRagSoc = null;
@@ -292,6 +299,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
} }
mutableFilteredOrderListWithSeparators.setValue(listWithSeparators); mutableFilteredOrderListWithSeparators.setValue(listWithSeparators);
refreshFabStatus();
}); });
new LiveAdapter(mutableFilteredOrderListWithSeparators, this) // Observe filteredList new LiveAdapter(mutableFilteredOrderListWithSeparators, this) // Observe filteredList

View File

@@ -219,8 +219,8 @@ public class ProdRientroMerceOrderDetailFragment extends BaseFragment implements
AtomicBigDecimal sumGross = new AtomicBigDecimal(BigDecimal.ZERO); AtomicBigDecimal sumGross = new AtomicBigDecimal(BigDecimal.ZERO);
AtomicBigDecimal sumQtaCol = new AtomicBigDecimal(BigDecimal.ZERO); AtomicBigDecimal sumQtaCol = new AtomicBigDecimal(BigDecimal.ZERO);
Stream.of(mtbColts) mtbColts.stream()
.forEach(x -> Stream.of(x.getMtbColr()).forEach(y -> { .forEach(x -> x.getMtbColr().stream().forEach(y -> {
sumColli.getAndAdd(y.getNumCnf()); sumColli.getAndAdd(y.getNumCnf());
sumNet.getAndAdd(y.getPesoNettoKg()); sumNet.getAndAdd(y.getPesoNettoKg());
sumGross.getAndAdd(y.getPesoLordoKg()); sumGross.getAndAdd(y.getPesoLordoKg());

View File

@@ -1569,8 +1569,11 @@ public class SpedizioneViewModel {
this.sendError(ex); this.sendError(ex);
} }
pickingObjectDTO.getWithdrawMtbColrs().add(createdMtbColr); MtbColr finalCreatedMtbColr = createdMtbColr;
this.mCurrentMtbColt.getMtbColr().add(createdMtbColr); handler.post(() -> {
pickingObjectDTO.getWithdrawMtbColrs().add(finalCreatedMtbColr);
this.mCurrentMtbColt.getMtbColr().add(finalCreatedMtbColr);
});
createdMtbColr createdMtbColr
.setUntMis(pickingObjectDTO.getMtbAart().getUntMis()) .setUntMis(pickingObjectDTO.getMtbAart().getUntMis())
@@ -1692,8 +1695,10 @@ public class SpedizioneViewModel {
pickingObjectDTO.get().getWithdrawMtbColrs().add(mtbColrToUpdate); pickingObjectDTO.get().getWithdrawMtbColrs().add(mtbColrToUpdate);
} }
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate); handler.post(() -> {
this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate); this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate);
this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate);
});
this.resetMatchedRows(); this.resetMatchedRows();
this.sendOnRowSaved(); this.sendOnRowSaved();
@@ -1721,7 +1726,9 @@ public class SpedizioneViewModel {
pickingObjectDTO.get().getWithdrawMtbColrs().remove(mtbColrToDelete); pickingObjectDTO.get().getWithdrawMtbColrs().remove(mtbColrToDelete);
} }
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete); handler.post(() -> {
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete);
});
this.resetMatchedRows(); this.resetMatchedRows();
this.sendOnRowSaved(); this.sendOnRowSaved();

View File

@@ -1,119 +0,0 @@
package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableList;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
import it.integry.integrywmsnative.core.expansion.OnSingleClickListener;
import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityNumber;
import it.integry.integrywmsnative.core.utility.UtilityResources;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.BottomSheetFragmentLuContentListItemBinding;
public class BottomSheetFragmentLUContentListAdapter extends RecyclerView.Adapter<BottomSheetFragmentLUContentListAdapter.ViewHolder> {
private final Context mContext;
private final ArrayList<MtbColr> mDataset;
private OnItemClickListener mOnItemClickListener;
public static class ViewHolder extends RecyclerView.ViewHolder {
protected BottomSheetFragmentLuContentListItemBinding mViewDataBinding;
public ViewHolder(BottomSheetFragmentLuContentListItemBinding v) {
super(v.getRoot());
mViewDataBinding = v;
}
public void bind(MtbColr mtbColr) {
mViewDataBinding.setMtbColr(mtbColr);
mViewDataBinding.executePendingBindings();
}
}
public BottomSheetFragmentLUContentListAdapter(Context context, ObservableArrayList<MtbColr> mtbColrs) {
super();
this.mContext = context;
this.mDataset = mtbColrs != null ? mtbColrs : new ArrayList<>();
Handler handler = new Handler(Looper.getMainLooper());
mtbColrs.addOnListChangedCallback(new OnListGeneralChangedCallback() {
@Override
public void onChanged(ObservableList sender) {
handler.post(() -> notifyDataSetChanged());
}
});
}
@Override
public BottomSheetFragmentLUContentListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// create a new view
BottomSheetFragmentLuContentListItemBinding viewDataBinding = BottomSheetFragmentLuContentListItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new BottomSheetFragmentLUContentListAdapter.ViewHolder(viewDataBinding);
}
@Override
public void onBindViewHolder(BottomSheetFragmentLUContentListAdapter.ViewHolder holder, int position) {
MtbColr mtbColr = mDataset.get(position);
holder.bind(mtbColr);
//Setting qty with unt_mis
if (!SettingsManager.iDB().isFlagForceAllToColli() && (mtbColr.getMtbAart() == null || mtbColr.getMtbAart().isFlagQtaCnfFissaBoolean())) {
String text = UtilityNumber.decimalToString(mtbColr.getQtaCol());
if (mtbColr.getMtbAart() != null) {
text += !UtilityString.isNullOrEmpty(mtbColr.getMtbAart().getUntMis()) ? "\n" + mtbColr.getMtbAart().getUntMis() : "";
}
holder.mViewDataBinding.qtaTextview.setText(text);
} else {
holder.mViewDataBinding.qtaTextview.setText(UtilityNumber.decimalToString(mtbColr.getNumCnf()) + "\n" + UtilityResources.getString(R.string.unt_mis_col));
}
holder.mViewDataBinding.executePendingBindings();
if (position % 2 == 1)
holder.mViewDataBinding.getRoot().setBackgroundColor(mContext.getResources().getColor(R.color.letturaFacilitataBG));
holder.mViewDataBinding.getRoot().setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
if(mOnItemClickListener != null) mOnItemClickListener.onItemClick(holder.mViewDataBinding.getMtbColr());
}
});
}
@Override
public int getItemCount() {
return mDataset.size();
}
public BottomSheetFragmentLUContentListAdapter setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.mOnItemClickListener = onItemClickListener;
return this;
}
interface OnItemClickListener {
void onItemClick(MtbColr item);
}
}

View File

@@ -14,22 +14,29 @@ import androidx.databinding.Observable;
import androidx.databinding.ObservableList; import androidx.databinding.ObservableList;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import java.util.List; import com.ravikoradiya.liveadapter.LiveAdapter;
import com.ravikoradiya.liveadapter.Type;
import java.util.List;
import java.util.Objects;
import it.integry.integrywmsnative.BR;
import it.integry.integrywmsnative.R; import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback; import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
import it.integry.integrywmsnative.core.expansion.OnSingleClickListener; import it.integry.integrywmsnative.core.expansion.OnSingleClickListener;
import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.databinding.BottomSheetFragmentLuContentBinding; import it.integry.integrywmsnative.databinding.BottomSheetFragmentLuContentBinding;
import it.integry.integrywmsnative.databinding.BottomSheetFragmentLuContentListItemBinding;
import it.integry.integrywmsnative.view.bottom_sheet__base.BottomSheetFragmentBaseView; import it.integry.integrywmsnative.view.bottom_sheet__base.BottomSheetFragmentBaseView;
import it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.BottomSheetMtbColrEditModalView; import it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.BottomSheetMtbColrEditModalView;
import kotlin.Unit;
public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseView implements BottomSheetMtbColrEditModalView.Listener { public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseView implements BottomSheetMtbColrEditModalView.Listener {
private BottomSheetFragmentLuContentBinding mBinding; private BottomSheetFragmentLuContentBinding mBinding;
private BottomSheetFragmentLUContentViewModel mViewModel; private BottomSheetFragmentLUContentViewModel mViewModel;
private BottomSheetFragmentLUContentListAdapter mAdapter; // private BottomSheetFragmentLUContentListAdapter mAdapter;
private Listener mListener; private Listener mListener;
@@ -62,19 +69,28 @@ public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseVie
private void initAdapter() { private void initAdapter() {
this.mBinding.mtbColrRecyclerView.setHasFixedSize(true); this.mBinding.mtbColrRecyclerView.setHasFixedSize(false);
this.mBinding.mtbColrRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); this.mBinding.mtbColrRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
this.mAdapter = new BottomSheetFragmentLUContentListAdapter(this.mContext, this.mViewModel.getObservableMtbColt().get().getMtbColr()); var itemType = new Type<MtbColr, BottomSheetFragmentLuContentListItemBinding>(R.layout.bottom_sheet_fragment__lu_content__list_item, BR.item);
this.mBinding.mtbColrRecyclerView.setAdapter(this.mAdapter);
this.mAdapter.setOnItemClickListener(clickedMtbColr -> { itemType.areItemSame((oldItem, newItem) -> Objects.equals(oldItem.getKey(), newItem.getKey()));
itemType.areContentsTheSame(MtbColr::equals);
new BottomSheetMtbColrEditModalView(clickedMtbColr) itemType.onClick(clickedItem -> {
new BottomSheetMtbColrEditModalView(clickedItem.getBinding().getItem())
.setListener(this) .setListener(this)
.show(((AppCompatActivity) mContext).getSupportFragmentManager(), "tag"); .show(((AppCompatActivity) mContext).getSupportFragmentManager(), "bottom_sheet_mtb_colr_edit");
return null;
}); });
new LiveAdapter(mViewModel.getObservableMtbColt().get().getMtbColr(), BR.item)
.map(MtbColr.class, itemType)
.onNoData(noData -> {
this.mBinding.emptyView.setVisibility(noData ? View.VISIBLE : View.GONE);
return Unit.INSTANCE;
})
.into(this.mBinding.mtbColrRecyclerView);
} }
private void initCallbacks() { private void initCallbacks() {

View File

@@ -158,7 +158,7 @@
android:id="@+id/unit_number" android:id="@+id/unit_number"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{&quot;UL #&quot; + viewModel.mtbColt.numCollo.toString()}" app:text="@{&quot;UL #&quot; + viewModel.mtbColt.numCollo.toString()}"
app:chipStrokeWidth="0dp" app:chipStrokeWidth="0dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@@ -169,7 +169,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:drawablePadding="4dp" android:drawablePadding="4dp"
android:text="@{viewModel.mtbColt.dataColloHumanLong}" app:text="@{viewModel.mtbColt.dataColloHumanLong}"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium" android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
app:layout_constraintBottom_toBottomOf="@id/unit_number" app:layout_constraintBottom_toBottomOf="@id/unit_number"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
@@ -844,14 +844,14 @@
android:paddingTop="14dp"> android:paddingTop="14dp">
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/empty_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp" android:padding="16dp">
android:visibility="@{viewModel.mtbColt == null || viewModel.mtbColt.mtbColr.size() == 0 ? View.VISIBLE : View.GONE}">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -877,6 +877,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
tools:listitem="@layout/bottom_sheet_fragment__lu_content__list_item"
app:dividerThickness="0.5dp" /> app:dividerThickness="0.5dp" />

View File

@@ -17,10 +17,12 @@
<import type="it.integry.integrywmsnative.core.utility.UtilityNumber" /> <import type="it.integry.integrywmsnative.core.utility.UtilityNumber" />
<import type="it.integry.integrywmsnative.core.utility.UntMisUtils" />
<import type="it.integry.integrywmsnative.core.settings.SettingsManager" /> <import type="it.integry.integrywmsnative.core.settings.SettingsManager" />
<variable <variable
name="mtbColr" name="item"
type="it.integry.integrywmsnative.core.model.MtbColr" /> type="it.integry.integrywmsnative.core.model.MtbColr" />
</data> </data>
@@ -45,7 +47,7 @@
style="@style/AppTheme.NewMaterial.Text.Small" style="@style/AppTheme.NewMaterial.Text.Small"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{mtbColr.codMart}" android:text="@{item.codMart}"
android:textColor="?colorPrimary" android:textColor="?colorPrimary"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold" android:textStyle="bold"
@@ -64,7 +66,7 @@
android:maxLines="2" android:maxLines="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:text="@{mtbColr.getDescrizione()}" android:text="@{item.getDescrizione()}"
android:textColor="@android:color/black" android:textColor="@android:color/black"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintEnd_toStartOf="@+id/qta_layout" app:layout_constraintEnd_toStartOf="@+id/qta_layout"
@@ -77,12 +79,12 @@
style="@style/AppTheme.NewMaterial.Text.Small" style="@style/AppTheme.NewMaterial.Text.Small"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{`Lotto: ` + mtbColr.getPartitaMag()}" android:text="@{`Lotto: ` + item.getPartitaMag()}"
android:textSize="14sp" android:textSize="14sp"
app:layout_constraintEnd_toStartOf="@+id/qta_layout" app:layout_constraintEnd_toStartOf="@+id/qta_layout"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/articolo_descrizione_textview" app:layout_constraintTop_toBottomOf="@id/articolo_descrizione_textview"
app:visibilityWhenNotNull="@{mtbColr.getPartitaMag()}" app:visibilityWhenNotNull="@{item.getPartitaMag()}"
tools:text="Lotto: ABCDE" /> tools:text="Lotto: ABCDE" />
@@ -109,11 +111,11 @@
android:paddingStart="6dp" android:paddingStart="6dp"
android:paddingEnd="6dp" android:paddingEnd="6dp"
android:paddingBottom="16dp" android:paddingBottom="16dp"
android:text="@{UtilityNumber.decimalToString(mtbColr.numCnf) + ` CNF`}" android:text="@{UtilityNumber.decimalToString(item.numCnf, 0)}"
android:textColor="?colorOnSecondaryContainer" android:textColor="?colorOnSecondaryContainer"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold" android:textStyle="bold"
app:visibility="@{SettingsManager.iDB().isFlagForceAllToColli() || (mtbColr.mtbAart != null &amp;&amp; !mtbColr.mtbAart.flagQtaCnfFissaBoolean)}" app:visibility="@{UntMisUtils.shouldBeShowInColli(item.mtbAart)}"
tools:text="NUM CNF" /> tools:text="NUM CNF" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
@@ -128,10 +130,12 @@
android:paddingTop="2dp" android:paddingTop="2dp"
android:paddingRight="6dp" android:paddingRight="6dp"
android:paddingBottom="2dp" android:paddingBottom="2dp"
android:text="@{UtilityNumber.decimalToString(item.qtaCol, item.mtbAart.firstUntMis.cifreDec.intValue()) + &quot;\n&quot; + item.mtbAart.firstUntMis.untMis}"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="?colorOnPrimaryContainer" android:textColor="?colorOnPrimaryContainer"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" android:textStyle="bold"
app:reverse_visibility="@{UntMisUtils.shouldBeShowInColli(item.mtbAart)}"
tools:text="280.45\nCONF" /> tools:text="280.45\nCONF" />
</LinearLayout> </LinearLayout>
@@ -143,7 +147,7 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:clickable="false" android:clickable="false"
android:focusable="false" android:focusable="false"
android:visibility="@{mtbColr.numColloRif != null ? View.VISIBLE : View.GONE}" android:visibility="@{item.numColloRif != null ? View.VISIBLE : View.GONE}"
app:cardElevation="0dp" app:cardElevation="0dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@@ -177,14 +181,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:text="@{&quot;#&quot; + mtbColr.numColloRif + &quot; (&quot; + mtbColr.serColloRif + &quot;)&quot;}" android:text="@{&quot;#&quot; + item.numColloRif + &quot; (&quot; + item.serColloRif + &quot;)&quot;}"
android:textAppearance="@style/TextAppearance.Material3.TitleMedium" android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
tools:text="#5230 (/)" /> tools:text="#5230 (/)" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{mtbColr.gestioneRifEnum != null ? GestioneToTextConverter.convert(mtbColr.gestioneRifEnum) : &quot;&quot;}" android:text="@{item.gestioneRifEnum != null ? GestioneToTextConverter.convert(item.gestioneRifEnum) : &quot;&quot;}"
android:textAppearance="@style/TextAppearance.Material3.BodySmall" android:textAppearance="@style/TextAppearance.Material3.BodySmall"
android:textColor="?attr/colorOutline" android:textColor="?attr/colorOutline"
tools:text="Lavorazione" /> tools:text="Lavorazione" />
@@ -196,7 +200,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:text="@{UtilityDate.formatDate(mtbColr.dataColloRifD, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)}" android:text="@{UtilityDate.formatDate(item.dataColloRifD, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)}"
android:textAppearance="@style/TextAppearance.Material3.TitleMedium" android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
tools:text="20 gennaio 2025" /> tools:text="20 gennaio 2025" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>