Closed yhdesai closed 5 years ago
Hi @yhdesai, I tried to solve this issue. But I observed that some DeveloperMessage
object having uid
null
. I tested them on Log and saw they are having null uid
.
2019-04-18 15:25:48.646 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---xxxxxxxxxxxxxxxxx
2019-04-18 15:25:48.662 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---null
2019-04-18 15:25:48.677 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---null
2019-04-18 15:25:57.016 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---xxxxxxxxxxxxxxxxx
2019-04-18 15:25:57.027 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---xxxxxxxxxxxxxxxxx
2019-04-18 15:25:57.038 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---xxxxxxxxxxxxxxxxx
2019-04-18 15:25:57.048 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---xxxxxxxxxxxxxxxxx
2019-04-18 15:25:57.057 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---null
2019-04-18 15:25:57.066 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---null
2019-04-18 15:25:57.211 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---xxxxxxxxxxxxxxxxx
2019-04-18 15:25:57.213 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---xxxxxxxxxxxxxxxxx
2019-04-18 15:25:57.217 5553-5553/tech.shipr.socialdev I/System.out: MSG-UID---xxxxxxxxxxxxxxxxx
.......and so on
That's why app was crashing earlier. Then I updated the code as below...
if (convertView == null) {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
assert user != null;
String uid = user.getUid();
if (message.getUid() != null) {
if (message.getUid().equals(uid)) {
convertView = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.item_message_right, parent, false);
} else {
convertView = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.item_message, parent, false);
}
} else {
convertView = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.item_message, parent, false);
}
}
After doing this, finally, I run the app and see...
This was just a temporary adjustment to avoid NullPointerException
. But later, you will have to clean up the Database.
Another Change:
Here, I have replaced ImageView
with CircleImageView
(created new class) to display a profile image in Circle Shape
I think this issue is solved now!
It should use the item_message_right.xml if the message is sent by the same user as in the device