мой код
readmassage();
seenmasseges();
private void seenmasseges() {
userRefforseen=FirebaseDatabase.getInstance().getReference("chats");
valueEventListener=userRefforseen.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot ds :dataSnapshot.getChildren()){
ModulChat chat=ds.getValue(ModulChat.class);
if(chat.getRecerve().equals(hisuide)&&chat.getSender().equals(myuid))
{
HashMap<String,Object> hashMap=new HashMap<>();
hashMap.put("isseen",true);
ds.getRef().updateChildren(hashMap);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private void readmassage() {
modulChats=new ArrayList<>();
DatabaseReference dbrf=FirebaseDatabase.getInstance().getReference().child("chats");
dbrf.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
modulChats.clear();
for(DataSnapshot ds :dataSnapshot.getChildren()){
ModulChat chat=ds.getValue(ModulChat.class);
if(chat.getRecerve().equals(myuid)&&chat.getSender().equals(hisuide)||
chat.getRecerve().equals(hisuide)&&chat.getSender().equals(myuid)){
modulChats.add(chat);
}
adapterChat=new AdapterChat(chatmassage.this,modulChats,hisimage);
adapterChat.notifyDataSetChanged();
chat_mass.setAdapter(adapterChat);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
#error #
>E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.chat, PID: 6655
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at com.example.chat.chatmassage$4.onDataChange(chatmassage.java:173)
at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@17.0.0:75)
at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@17.0.0:63)
at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@17.0.0:55)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
I/Process: Sending signal. PID: 6655 SIG: 9
Process 6655 terminated.
##how to solve this please help and thanks##