Last active
June 4, 2019 19:24
-
-
Save AlexPrestonSB/e4b899b0f818c8ef570446d53c8f31ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Messages sent by me do not display a profile image or nickname. | |
private class SentMessageHolder extends RecyclerView.ViewHolder { | |
TextView messageText, timeText; | |
SentMessageHolder(View itemView) { | |
super(itemView); | |
messageText = (TextView) itemView.findViewById(R.id.text_message_body); | |
timeText = (TextView) itemView.findViewById(R.id.text_message_time); | |
} | |
void bind(UserMessage message) { | |
messageText.setText(message.getMessage()); | |
// Format the stored timestamp into a readable String using method. | |
timeText.setText(Utils.formatTime(message.getCreatedAt())); | |
} | |
} | |
// Messages sent by others display a profile image and nickname. | |
private class ReceivedMessageHolder extends RecyclerView.ViewHolder { | |
TextView messageText, timeText, nameText; | |
ImageView profileImage; | |
ReceivedMessageHolder(View itemView) { | |
super(itemView); | |
messageText = (TextView) itemView.findViewById(R.id.text_message_body); | |
timeText = (TextView) itemView.findViewById(R.id.text_message_time); | |
nameText = (TextView) itemView.findViewById(R.id.text_message_name); | |
profileImage = (ImageView) itemView.findViewById(R.id.image_message_profile); | |
} | |
void bind(UserMessage message) { | |
messageText.setText(message.getMessage()); | |
nameText.setText(message.getSender().getNickname()); | |
Utils.displayRoundImageFromUrl(ChatActivity.this, | |
message.getSender().getProfileUrl(), profileImage); | |
timeText.setText(Utils.formatTime(message.getCreatedAt())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment