1
In my Asynctask I urge 4 new objects, only I have to stay in it until all objects are brought in. Follow the code:
@Override
protected Void doInBackground(Void... voids) {
new CrtlComentario(contexto).trazer(post.getCodigo(), new CallbackTrazer() {
@Override
public void resultadoTrazer(Object obj) {
c = (Comentario) obj;
flag[3] = false;
}
@Override
public void falha() {
flag[3] = false;
}
});
new CrtlUsuario(contexto).trazer(c.getUsuarioPost(), new CallbackTrazer() {
@Override
public void resultadoTrazer(Object obj) {
u = (Usuario) obj;
flag[0] = false;
}
@Override
public void falha() {
flag[0] = false;
}
});
new CrtlComentarioPost(contexto).listar(new CallbackListar() {
@Override
public void resultadoListar(List<Object> lista) {
for (Object obj : lista)
cp.add((ComentarioPost) obj);
flag[1] = false;
}
@Override
public void falha() {
flag[1] = false;
}
});
new CrtlCurtidaComentario(contexto).listar(new CallbackListar() {
@Override
public void resultadoListar(List<Object> lista) {
for (Object obj : lista)
cc.add((CurtidaComentario) obj);
flag[2] = false;
}
@Override
public void falha() {
flag[2] = false;
}
});
return null;
}
The only objects that can never be null are "c" and "u" the other two can.
I need "c" to be loaded so I can load the other three, because I need your code.
I tried to do a while to stay until they end up using the flag variable[], but it doesn’t work and sometimes doesn’t even run the task.