0

I'm having trouble with this query.

MyClass

What i want to accomplish here is according to the idChatSeleccionadoAppUsuario(KYLmvSGP1…) i can have all the messages and User(Usuario) inside the list. This is what i have tried so far:

 ParseQuery<ParseObject> query = ParseQuery.getQuery("Conversaciones");
    queryChat=ParseObject.createWithoutData("Chat",idChatSeleccionadoAppUsuario);
    query.whereEqualTo("ChatId", queryChat);
    query.include("Usuario");
    query.include("ChatId");
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> objects, ParseException e) {
            for (ParseObject obj : objects) {
                mensaje = obj.getString("Mensaje");
                Log.i("UFF", "Este es el mensaje" + mensaje);

                enviaMensaje = (ParseUser) obj.get("Usuario");
                Log.i("UFF", "Este es el usuario del chat---->:" + enviaMensaje.getObjectId());

                chatId = obj.getParseObject("ChatId");
                Log.i("UFF", "Este es el id del chat---->:" + chatId);
                //idChatSeleccionado=chatId.getObjectId();
                listaDeMensajes.add(obj);


            }
            mMessageAdapter = new MessageListAdapter(getContext(), listaDeMensajes);
            mMessageRecycler.setAdapter(mMessageAdapter);
            queryFromChat();


        }
    });

}

And also have tried this one:

 ParseQuery query = ParseQuery.getQuery(“Conversaciones”);
    query.whereEqualTo(“ChatId”, idChatSeleccionadoAppUsuario);
    query.include(“Usuario”);
    query.include(“ChatId”);
    query.findInBackground(new FindCallback() {
    @Override
    public void done(List objects, ParseException e) {
    for (ParseObject obj : objects) {
    mensaje = obj.getString(“Mensaje”);
    Log.i(“UFF”, “Este es el mensaje” + mensaje);
     enviaMensaje = (ParseUser) obj.get("Usuario");
                    Log.i("UFF", "Este es el usuario del chat---->:" + enviaMensaje.getObjectId());

                chatId = obj.getParseObject("ChatId");
                Log.i("UFF", "Este es el id del chat---->:" + chatId);
                //idChatSeleccionado=chatId.getObjectId();
                listaDeMensajes.add(obj);


            }
            mMessageAdapter = new MessageListAdapter(getContext(), listaDeMensajes);
            mMessageRecycler.setAdapter(mMessageAdapter);
            queryFromChat();


        }
    });

  }

At the moment both return listaDeMensajes=0

Arbaz Pirwani
  • 935
  • 7
  • 22
Felipe Franco
  • 171
  • 3
  • 15
  • Can you please print out the vars "object", "e" and share here? – Davi Macêdo May 08 '19 at 18:48
  • @DaviMacêdo from query 1 or 2 and can you please suggest me which part you want me to print? – Felipe Franco May 08 '19 at 21:25
  • @DaviMacêdo from query 1 or 2 and can you please suggest me which part you want me to print? if you refer to List objects the method isn`t even entering done on debugg. – Felipe Franco May 08 '19 at 22:01
  • That's strange. Do you see any error in your logs? "done" callback should be always called either with something in the "objects" var or an error in the "e" var. Can you print out both vars before the for just in case? – Davi Macêdo May 09 '19 at 17:56
  • Thank you for reply @DaviMacêdo the query is working with the first one! – Felipe Franco May 10 '19 at 11:23

1 Answers1

1

Finally this is the way to retrieve the query... it was always but this post could help a lot of people...

ParseQuery<ParseObject> query = ParseQuery.getQuery("Conversaciones");
    queryChat=ParseObject.createWithoutData("Chat",idChatSeleccionadoAppUsuario);
    query.whereEqualTo("ChatId", queryChat);
    query.include("Usuario");
    query.include("ChatId");
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> objects, ParseException e) {
            for (ParseObject obj : objects) {
                mensaje = obj.getString("Mensaje");
                Log.i("UFF", "Este es el mensaje" + mensaje);

                enviaMensaje = (ParseUser) obj.get("Usuario");
                Log.i("UFF", "Este es el usuario del chat---->:" + enviaMensaje.getObjectId());

                chatId = obj.getParseObject("ChatId");
                Log.i("UFF", "Este es el id del chat---->:" + chatId);
                //idChatSeleccionado=chatId.getObjectId();
                listaDeMensajes.add(obj);


            }
            mMessageAdapter = new MessageListAdapter(getContext(), listaDeMensajes);
            mMessageRecycler.setAdapter(mMessageAdapter);
            queryFromChat();


        }
    });

}
Felipe Franco
  • 171
  • 3
  • 15