mchat | Simple chat system that can do file transfers | Websocket library
kandi X-RAY | mchat Summary
kandi X-RAY | mchat Summary
Simple chat system that can do file transfers over websockets :) - However file transfers work only in chrome browsers :( - Made possible by Erlang, Cowboy and Web Workers with Binary WebSockets.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mchat
mchat Key Features
mchat Examples and Code Snippets
Community Discussions
Trending Discussions on mchat
QUESTION
I am using recyclerview to show all my message in my app. But it always showing the messages in the left side of the chat room.
How can I achieve this?
This is my code:
Here my adapter always goes to the else part and listing all the message in the left side of the screen(i.e) other user messages
Adapter:
...ANSWER
Answered 2021-Mar-01 at 14:22you are checking your viewType twice. you should not check it again in onCreateViewHolder.
try something like this:
QUESTION
I have checked several times the name of my layout RecyclerView as I show on other StackOverflow questions but it is correct. The error of the logcat is this:
...ANSWER
Answered 2021-Feb-07 at 16:01You call findViewById()
here:
QUESTION
public class MessageActivity extends AppCompatActivity {
TextView username;
ImageView imageView;
RecyclerView recyclerViewy;
EditText msg_editText;
ImageButton sendBtn;
FirebaseUser fuser;
DatabaseReference references;
Intent intent;
MessageAdapter messageAdapter;
Listmchat;
RecyclerView recyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message);
imageView = findViewById(R.id.imageview_profile);
username = findViewById(R.id.usernamey);
sendBtn = findViewById(R.id.btn_send);
msg_editText = findViewById(R.id.text_send);
recyclerView = findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
linearLayoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(linearLayoutManager);
intent = getIntent();
String userid = intent.getStringExtra("userid");
fuser = FirebaseAuth.getInstance().getCurrentUser();
references = FirebaseDatabase.getInstance().getReference("MyUsers").child(userid);
references.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
Users users = snapshot.getValue(Users.class);
username.setText(users.getUsername());
if (users.getImageURL().equals("default")){
imageView.setImageResource(R.mipmap.ic_launcher);
}else {
Glide.with(MessageActivity.this)
.load(users.getImageURL())
.into(imageView);
}
readMessages(fuser.getUid(),userid,users.getImageURL());
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
sendBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String msg = msg_editText.getText().toString();
if (!msg .equals("")){
sendMessage(fuser.getUid(),userid,msg);
}else {
Toast.makeText(MessageActivity.this, "please send a non empty message !", Toast.LENGTH_SHORT).show();
}
msg_editText.setText("");
}
});
}
private void sendMessage(String sender,String receiver ,String message){
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
HashMap hashMap =new HashMap<>();
hashMap.put("sender",sender);
hashMap.put("receiver",receiver);
hashMap.put("message",message);
reference.child("Chats").push().setValue(hashMap);
}
private void readMessages(String myid,String userid,String imgurl){
mchat = new ArrayList<>();
references = FirebaseDatabase.getInstance().getReference("Chats");
references.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
mchat.clear();
for (DataSnapshot dataSnapshot :snapshot.getChildren()){
Chat chat = dataSnapshot.getValue(Chat.class);
if (chat.getReceiver().equals(myid)&&chat.getSender().equals(userid)&&chat.getReceiver().equals(userid)&&chat.getSender().equals(myid)){
mchat.add(chat);
}
messageAdapter = new MessageAdapter(MessageActivity.this,mchat,imgurl);
recyclerView.setAdapter(messageAdapter);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
}
...ANSWER
Answered 2021-Jan-26 at 15:28It looks like users.getImageURL()
is returning null
for one or more of your nodes. If this is indeed a common occurrence in your database, you can easily detect by using so-called Yoda-notation for your check:
QUESTION
I am working on a chat app for android with firebase
. so i want to show the sender name above of the first message from same sender but i get the sender name on every message sent by the sender,
the logic i am using
...ANSWER
Answered 2020-Nov-11 at 09:48@mr. groot was working on a similar app and achived this on my RecyclerView onBind method
QUESTION
I am having a null pointer of, Is Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setHasFixedSize(boolean)' on a null object reference I am having problems with my recyclerView Here is my log cat Please help
...ANSWER
Answered 2020-Oct-13 at 20:17The problem is on the XML file I did not indicate the id on the recyclerview
QUESTION
So, I'm still a newbie in Firebase and I'm just switching from the Firebase Realtime Database to Firestore. This has worked out well so far. But I have a problem with the messages from my chat app. With the Firebase Realtime Database everything worked fine, but with Firestore there are some problems. I can send and display the messages, but Firestore somehow changes the order of the chat. Could someone explain this to me and suggest a solution?
Example video of the bug: https://youtu.be/KE28qK22DoQ
(Adapter) MessageAdapter: https://hastebin.com/avoluximow.java
(Model) Chat: https://hastebin.com/secuvojoyu.java
This is my code for writing and reading the data:
...ANSWER
Answered 2020-Aug-11 at 13:10Try to add new field (when sending message):
chat.put("created", Timestamp.now());
And add field to your entity Chat.java
:
QUESTION
I am a beginner and am only able to add elements via storyboard.
Now I would like to know how to add UIView code to the screen without using a storyboard.
I need to place it at the very top, full width of the screen, replacing the NavigationBar with a UIView
...ANSWER
Answered 2020-Jul-19 at 15:23Here is how you can place it over entire screen
QUESTION
So, I'm not sure about the title of this question but here it goes. I have a recyclerview for my chat room. The first time the activity started it has no problem displaying the messages but after pressing the back button back to the main activity showing all chat rooms then click the same chat room again it displays nothing. Then, after sent a message it can display all the messages again. I'm not sure what happened, help, please. Oh, I already tried a few things and browse the internet but because I'm not sure what the keyword is, so I'm quite stuck now
Okay, here is the thing
First main activity, (ignore the other 2 tabs, it's empty)
Then open a chat room
First time open chat room fine
Then press back button, back to MainActivity, then open the same room and no chat displayed
chat room not displaying anything
Then it displays messages again after sending a new messages
I have tried to place notifyDataSetChanged() on various event like onStart, onCreate etc but nothing works;
here is my chat activity
...ANSWER
Answered 2020-Jun-18 at 07:27in my case i used onResume()
QUESTION
I am trying select multiple items from recyclerview using a contextual action bar my contextual action bar inflates correctly but i am having problems while selecting multiple items at once. I want to select multiple items and perform actions collectively on them
My code
ActionModeCallback
...ANSWER
Answered 2020-May-03 at 13:20There is solution useful solution for selecting multiple items in recyclerView.
QUESTION
I want to show if a message is seen or not in my app which is using Firebase Real time Database.What i am able to till now is update it on on the database if the message is seen or not but i am not able to retrieve that value using listeners in my recyclerview Adaptor .It happens that if the last message is not seen it displays all the previous messages are not seen similarly if the last message is seen it displays all the previous messages are seen.
My Code for checking if the message is seen or not
...ANSWER
Answered 2020-Apr-28 at 17:39Do this in onBindViewHolder
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mchat
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page