I'm trying to get data from Firestore and add them to a recycler view, I tried doing this:
for (DocumentChange doc : queryDocumentSnapshots.getDocumentChanges()) {
if (doc.getType() == DocumentChange.Type.ADDED) {
Users users = doc.getDocument().toObject(Users.class);
if (users.getName() != null) {
if(users.getStatus() == null){
mUsersList.add(new Users(true));
mUsersList.add(users);
}
mUsersList.add(users);
usersListAdapter.notifyDataSetChanged();
}
}
}
I have an adapter already configured in the proper way, but when I try setting the Boolean flag, that is required for showing one layout or the other this appears:
java.lang.RuntimeException: Could not deserialize object. Class com.example.gusta.client.list_model.Users does not define a no-argument constructor. If you are using ProGuard, make sure these constructors are not stripped.
This I because I need an empty constructor for this, but if I set an empty constructor on my List, I wont be able to choose between the layouts.
If you know the answer or knows a video class that could help me solving this problem I would be very glad, thanks.
public class Users {
String user,status,image,descricao;
private Boolean adcionais;
public Users(){
}
public Users(String name, String status,Boolean adcionais) {
this.user = name;
this.status = status;
this.adcionais = adcionais;
}
public String getName() {
return ;
}
public void setName(String name) {
this.user = name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public Boolean getAdcionais() {
return adcionais;
}
public void setAdcionais(Boolean adcionais) {
this.adcionais = adcionais;
}
}