How do I use createTypedArrayList correctly from the Parcelable interface?

0

My problem is that when recovering an array list typed after using the parcelable interface there is an arraylist that only has to have 2 objects and has more than 6 million generally.

This is class BaseDeDatos . It is responsible for keeping all the information. The program works well until you want to recover the arraylist of clients, there you are thinking for a while and then you throw away that you have 7 million elements and the arrays that follow have zero size when in reality they would have to have objects too.

@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel parcel, int i) {
    parcel.writeString(TAG);
    parcel.writeString(nombrePreventista);
    parcel.writeTypedList(productoStocks);
    parcel.writeTypedList(clientes);
    parcel.writeStringList(arrayClientes);
    parcel.writeStringList(arrayProductos);
    parcel.writeTypedList(arrayELV);
}

protected BaseDeDatos(Parcel in) {
    TAG = in.readString();
    nombrePreventista = in.readString();
    productoStocks = in.createTypedArrayList(ProductoStock.CREATOR);
    clientes = in.createTypedArrayList(Cliente.CREATOR);
    arrayClientes = in.createStringArrayList();
    arrayProductos = in.createStringArrayList();
    arrayELV = in.createTypedArrayList(ChildGroup.CREATOR);
    DB = VentanaPrincipal.PasarDB();
}

public static final Creator<BaseDeDatos> CREATOR = new Creator<BaseDeDatos>() {
    @Override
    public BaseDeDatos createFromParcel(Parcel in) {
        return new BaseDeDatos(in);
    }

    @Override
    public BaseDeDatos[] newArray(int size) {
        return new BaseDeDatos[size];
    }
};

This is a photo of the step by step debugging.

This is the code for the Client class.

public class Cliente implements Parcelable {
private String nombre;
private String direccion;
private String plazosEntrega;
private String observaciones;


@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel parcel, int i) {
    parcel.writeString(nombre);
    parcel.writeString(direccion);
    parcel.writeString(plazosEntrega);
    parcel.writeString(observaciones);
}

protected Cliente(Parcel in) {
    nombre = in.readString();
    direccion = in.readString();
    plazosEntrega = in.readString();
    observaciones = in.readString();
}

public static final Parcelable.Creator<Cliente> CREATOR = new Parcelable.Creator<Cliente>() {
    @Override
    public Cliente createFromParcel(Parcel in) {
        return new Cliente(in);
    }

    @Override
    public Cliente[] newArray(int size) {
        return new Cliente[size];
    }
};
}

I do not know what else to try, the class productoStock has implemented the methods of the interfaz serializable in the same way as the class Cliente , but in it if it works.

    
asked by Nahuel 27.07.2018 в 02:17
source

0 answers