use of com.example.first_responder_app.interfaces.ActiveUser in project FirstResponse by mattpost1700.
the class ChatGroupRecyclerViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Chat chat = mData.get(position);
Context context = holder.itemView.getContext();
String userId = "";
ActiveUser activeUser = (ActiveUser) context;
if (activeUser != null) {
UsersDataModel user = activeUser.getActive();
if (user != null) {
userId = user.getDocumentId();
}
}
ArrayList<String> members = chat.getMembers();
String a = holder.name.getText().toString();
String chatName = "";
// If it is direct message, set chat name to user's name, otherwise set chat name to the name stored in db
if (members.size() == 2) {
String[] memberAndId0 = members.get(0).split("/");
String[] memberAndId1 = members.get(1).split("/");
if (memberAndId0[1].equals(userId)) {
holder.name.setText(memberAndId1[0]);
} else {
holder.name.setText(memberAndId0[0]);
}
} else {
holder.name.setText(chat.getChatName());
a = holder.name.getText().toString();
}
holder.recentMsg.setText(chat.getMostRecentMessage());
holder.data = chat;
}
Aggregations