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

5
  • Can you please print out the vars "object", "e" and share here? Commented May 8, 2019 at 18:48
  • @DaviMacêdo from query 1 or 2 and can you please suggest me which part you want me to print? Commented May 8, 2019 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<ParseObject> objects the method isn`t even entering done on debugg. Commented May 8, 2019 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? Commented May 9, 2019 at 17:56
  • Thank you for reply @DaviMacêdo the query is working with the first one! Commented May 10, 2019 at 11:23

1 Answer 1

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();


        }
    });

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.