0
I have a method that returns values from firebase
. When received, I create a new ArrayList<Visitante
> and the saved in a Object
.
ArrayList<Visitante> visitantes = new ArrayList<>();
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
visitantes.add(snapshot.getValue(Visitante.class));
Log.e("***", snapshot.getValue(Visitante.class).getNome());
}
event.emit(new Result(visitantes));
event.emit()
wait for a guy Object
.
How do I turn this Object back into the ArrayList<Visitante>
?
in your if it shows an error in Arraylist<Visitor>: Illegal Generic type instanceof
– Rafael Silva
but the cast worked! But only one question before choosing as the right answer, If the array that was assigned in Object is modified, will the new array that receives it of object be updated? that is, it passes the reference?
– Rafael Silva
Because of type Erasure cannot be used
instanceof
that way. It would have to be like this:objecto instanceof ArrayList<?>
and then check the type of the item. I did not put it in the answer because I think that the indicated exception is to be launched. Yes is passed to "reference".– ramaral