I have an error to save the validity of my package, I am passing the position of the array. What could be wrong?
int position = 0;
for (Pacote pacote: pacoteList) {
Vigencia vigencia = new Vigencia();
if (pacote.getVigencias().size() != 0) {
Log.d("Vigencia", pacote.getVigencias().get(position).getMeses());
vigencia.setMeses( pacote.getVigencias().get(pacoteList.indexOf(pacote)).getMeses());
vigencia.setValorDescontoPromocional( pacote.getVigencias().get(pacoteList.indexOf(pacote)).getValorDescontoPromocional());
vigenciaDao.inserirVigencia(db, vigencia, pacote.getCodigo());
}
position++;
}
Json
"Pacotes": [
{
"Codigo": "1",
"Descricao": "Pacote teste",
"SimboloMoeda": "US$",
"Adesao": "18.00",
"ValorContrato": "150.00",
"DescontoPacote": "-100.00",
"ValorDescontoPromocional": "0.00",
"Vigencias": [
{
"meses": "12",
"ValorDescontoPromocional": "5.00"
},
{
"meses": "24",
"ValorDescontoPromocional": "5.00"
}
]
},
{
"Codigo": "2",
"Descricao": "teste webservice",
"SimboloMoeda": "R$",
"Adesao": "130.00",
"ValorContrato": "170.00",
"DescontoPacote": "50.00",
"ValorDescontoPromocional": "0.00",
"Vigencias": []
},
{
"Codigo": "3",
"Descricao": "Pacote Salesforce WS",
"SimboloMoeda": "R$",
"Adesao": "0.00",
"ValorContrato": "499.90",
"DescontoPacote": "5.00",
"ValorDescontoPromocional": "0.00",
"Vigencias": [
{
"meses": "12",
"ValorDescontoPromocional": "15.00"
},
{
"meses": "24",
"ValorDescontoPromocional": "35.00"
}
]
},
{
"Codigo": "4",
"Descricao": "SalesForce 002",
"SimboloMoeda": "R$",
"Adesao": "0.00",
"ValorContrato": "180.00",
"DescontoPacote": "0.00",
"ValorDescontoPromocional": "0.00",
"Vigencias": []
}
]
}