Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat messages do not show. #3

Open
ghost opened this issue May 5, 2018 · 7 comments
Open

Chat messages do not show. #3

ghost opened this issue May 5, 2018 · 7 comments

Comments

@ghost
Copy link

ghost commented May 5, 2018

Hi Divyanshu,
A great job on writing this code for the chatbot. Helped me a lot. I've got a little problem on my end. The chat messages do not show on the app but when I check my training log for my dialog flow agent, the training messages I put from the app appear there. I think it has something to do with the recycler adapter. Could you check and let me know?

Also, how do I fix the memory leak warning in the Async task section of the code on MainActivity.java?

NOTE: I update all the firebase libraries to the latest and update the changes in code functions as suggested in their documentation.

Below is my updated code

This is your original code
_adapter = new FirebaseRecyclerAdapter<ChatMessage, chat_rec>(ChatMessage.class,R.layout.msglist,chat_rec.class,ref.child("chat")) {
@OverRide
protected void onBindViewHolder(chat_rec viewHolder, ChatMessage model, int position) {

            if (model.getMsgUser().equals("user")) {


                viewHolder.rightText.setText(model.getMsgText());

                viewHolder.rightText.setVisibility(View.VISIBLE);
                viewHolder.leftText.setVisibility(View.GONE);
            }
            else {
                viewHolder.leftText.setText(model.getMsgText());

                viewHolder.rightText.setVisibility(View.GONE);
                viewHolder.leftText.setVisibility(View.VISIBLE);
            }
        }
    };_


    **My Update Code begins here**
    _FirebaseRecyclerOptions<ChatMessage> options =
            new FirebaseRecyclerOptions.Builder<ChatMessage>()
                    .setQuery(ref, ChatMessage.class)
                    .build();

    adapter = new FirebaseRecyclerAdapter<ChatMessage, chat_rec>(options) {

        @NonNull
        @Override
        public chat_rec onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.msglist, parent, false);
            return new chat_rec(view);
        }

        @Override
        protected void onBindViewHolder(@NonNull chat_rec holder, int position, @NonNull ChatMessage model) {
            if (model.getMsgUser().equals("user")) {
                holder.rightText.setText(model.getMsgText());
                holder.rightText.setVisibility(View.VISIBLE);
                holder.leftText.setVisibility(View.GONE);
            }
            else {
                holder.leftText.setText(model.getMsgText());
                holder.rightText.setVisibility(View.GONE);
                holder.leftText.setVisibility(View.VISIBLE);
            }
        }_
    };
@Uday2024
Copy link

Have u solved the issue Messages are displayed ???

@Uday2024
Copy link

In the update code u forget to place ref.child("chat") please check it

@divyanshub024
Copy link
Owner

divyanshub024 commented May 23, 2018

@timmy9ja @Uday2024 There is no problem in the code. The problem is occurring due to my firebase project. As it is open to everyone people try new things which usually changes the data structure. I would recommend you to make your own firebase Project. Follow the firebase guide to use adapter as there are many new changes.
PS: Sry for the delay answer.

@sureshy2k18
Copy link

I am getting app stopped responding error.App is not opening,

@Raghuram-Veeramallu
Copy link

@timmy9ja @Uday2024 There is no problem in the code. The problem is occurring due to my firebase project. As it is open to everyone people try new things which usually changes the data structure. I would recommend you to make your own firebase Project. Follow the firebase guide to use adapter as there are many new changes.
PS: Sry for the delay answer.

Bro, there's some issue with the recycler view. It does not display the chat messages. I have linked my code to my firebase, where I could obtain the chat messages.

@rohetoric
Copy link

It took me three days to resolve the errors
The code is completely obsolete according to new Android standards. It's better to code everything all together again. And if you have migrated to androidx from android, you have my blessings.

Anyways could the chat messages not being displayed work out for anyone, given it is being saved in my database but not showing anything in the layout. I have even asked a doubt regarding it here: https://stackoverflow.com/questions/56860460/not-able-to-properly-show-chat-send-by-user-and-receiver-on-screen Please help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants