Creata classe custom per confrontare la chiave dell'ordine

This commit is contained in:
Giuseppe Scorrano 2019-06-27 21:30:33 +02:00
parent 836a5c186b
commit 381c67196d

View File

@ -79,7 +79,7 @@ public class MainListVenditaAdapterNew extends SectionedRecyclerViewAdapter<Main
.forEach(x -> { .forEach(x -> {
//if(!mCheckBoxes.containsKey(key)) { //if(!mCheckBoxes.containsKey(key)) {
mCheckBoxes.put((OrdineListModel)x, false); mCheckBoxes.put(OrdineListModel.fromOrdine(x), false);
//} else { //} else {
//mCheckBoxes.get(key) = false; //mCheckBoxes.get(key) = false;
//} //}
@ -141,7 +141,7 @@ public class MainListVenditaAdapterNew extends SectionedRecyclerViewAdapter<Main
holder.binding.venditaMainListGroupItemContainerCheckBox.setChecked(mCheckBoxes.get(ordine)); holder.binding.venditaMainListGroupItemContainerCheckBox.setChecked(mCheckBoxes.get(ordine));
holder.binding.venditaMainListGroupItemContainerCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> { holder.binding.venditaMainListGroupItemContainerCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
mCheckBoxes.put((OrdineListModel) ordine, isChecked); mCheckBoxes.put(OrdineListModel.fromOrdine(ordine), isChecked);
}); });
} }
@ -167,10 +167,54 @@ public class MainListVenditaAdapterNew extends SectionedRecyclerViewAdapter<Main
} }
private static class OrdineListModel extends OrdineVenditaInevasoDTO { private static class OrdineListModel {
private String data;
private Integer numero;
private String gestione;
private String dataCons;
protected OrdineListModel(Parcel in) { public static OrdineListModel fromOrdine(OrdineVenditaInevasoDTO ordine) {
super(in); return new OrdineListModel()
.setData(ordine.getDataOrdS())
.setDataCons(ordine.getDataConsS())
.setGestione(ordine.getGestione())
.setNumero(ordine.getNumOrd());
}
public String getData() {
return data;
}
public OrdineListModel setData(String data) {
this.data = data;
return this;
}
public Integer getNumero() {
return numero;
}
public OrdineListModel setNumero(Integer numero) {
this.numero = numero;
return this;
}
public String getGestione() {
return gestione;
}
public OrdineListModel setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public String getDataCons() {
return dataCons;
}
public OrdineListModel setDataCons(String dataCons) {
this.dataCons = dataCons;
return this;
} }
@Override @Override
@ -178,20 +222,20 @@ public class MainListVenditaAdapterNew extends SectionedRecyclerViewAdapter<Main
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
OrdineVenditaInevasoDTO that = (OrdineVenditaInevasoDTO) o; OrdineListModel that = (OrdineListModel) o;
if (!getDataOrdS().equals(that.getDataOrdS())) return false; if (!getData().equals(that.getData())) return false;
if (!getNumOrd().equals(that.getNumOrd())) return false; if (!getNumero().equals(that.getNumero())) return false;
if (!getGestione().equals(that.getGestione())) return false; if (!getGestione().equals(that.getGestione())) return false;
return getDataConsS().equals(that.getDataConsS()); return getDataCons() != null ? getDataCons().equals(that.getDataCons()) : that.getDataCons() == null;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = getDataOrdS().hashCode(); int result = getData().hashCode();
result = 31 * result + getNumOrd().hashCode(); result = 31 * result + getNumero().hashCode();
result = 31 * result + getGestione().hashCode(); result = 31 * result + getGestione().hashCode();
result = 31 * result + getDataConsS().hashCode(); result = 31 * result + (getDataCons() != null ? getDataCons().hashCode() : 0);
return result; return result;
} }
} }