mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 15:59:29 +00:00
First iteration of the ConversationMessageAdapter
This commit is contained in:
parent
ec7a852fc4
commit
c0545c5db5
@ -55,7 +55,7 @@
|
|||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -31,14 +31,6 @@ public class ConversationMessageAdapter extends ArrayAdapter<ConversationMessage
|
|||||||
*/
|
*/
|
||||||
private static final String TAG = "ConversationMessageAdap";
|
private static final String TAG = "ConversationMessageAdap";
|
||||||
|
|
||||||
/**
|
|
||||||
* Possible colors for the message
|
|
||||||
*/
|
|
||||||
private int usercolorText;
|
|
||||||
private int usercolorBackground;
|
|
||||||
private int otherusercolorText;
|
|
||||||
private int otherusercolorBackground;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the current user
|
* The ID of the current user
|
||||||
*/
|
*/
|
||||||
@ -58,26 +50,6 @@ public class ConversationMessageAdapter extends ArrayAdapter<ConversationMessage
|
|||||||
//Set user ID
|
//Set user ID
|
||||||
this.userID = userID;
|
this.userID = userID;
|
||||||
|
|
||||||
//Get the color codes
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
usercolorText = getContext().getResources().
|
|
||||||
getColor(R.color.conversation_user_messages_textColor, getContext().getTheme());
|
|
||||||
usercolorBackground = getContext().getResources().
|
|
||||||
getColor(R.color.conversation_user_messages_background, getContext().getTheme());
|
|
||||||
otherusercolorText = getContext().getResources().
|
|
||||||
getColor(R.color.conversation_otheruser_messages_textColor, getContext().getTheme());
|
|
||||||
otherusercolorBackground = getContext().getResources().
|
|
||||||
getColor(R.color.conversation_otheruser_messages_background, getContext().getTheme());
|
|
||||||
} else {
|
|
||||||
usercolorText = getContext().getResources().
|
|
||||||
getColor(R.color.conversation_user_messages_textColor);
|
|
||||||
usercolorBackground = getContext().getResources().
|
|
||||||
getColor(R.color.conversation_user_messages_background);
|
|
||||||
otherusercolorText = getContext().getResources().
|
|
||||||
getColor(R.color.conversation_otheruser_messages_textColor);
|
|
||||||
otherusercolorBackground = getContext().getResources().
|
|
||||||
getColor(R.color.conversation_otheruser_messages_background);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,41 +67,51 @@ public class ConversationMessageAdapter extends ArrayAdapter<ConversationMessage
|
|||||||
ConversationMessage message = getItem(position);
|
ConversationMessage message = getItem(position);
|
||||||
assert message != null;
|
assert message != null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Get the view of the messages
|
||||||
|
|
||||||
|
Update the general layout of the message
|
||||||
|
*/
|
||||||
|
TextView contentView;
|
||||||
|
ImageView accountImage;
|
||||||
|
if(message.getUser_id() == userID){
|
||||||
|
|
||||||
|
//Message appears on the right
|
||||||
|
convertView.findViewById(R.id.fragment_conversation_message_left).
|
||||||
|
setVisibility(View.GONE);
|
||||||
|
|
||||||
|
contentView = convertView.
|
||||||
|
findViewById(R.id.fragment_conversation_message_item_content_right);
|
||||||
|
|
||||||
|
accountImage = convertView.
|
||||||
|
findViewById(R.id.fragment_conversation_message_item_accountimage_right);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
//Message appears on the left
|
||||||
|
convertView.findViewById(R.id.fragment_conversation_message_right).
|
||||||
|
setVisibility(View.GONE);
|
||||||
|
|
||||||
|
contentView = convertView.
|
||||||
|
findViewById(R.id.fragment_conversation_message_item_content);
|
||||||
|
|
||||||
|
accountImage = convertView.
|
||||||
|
findViewById(R.id.fragment_conversation_message_item_accountimage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Update message content
|
Update message content
|
||||||
*/
|
*/
|
||||||
//Set the text of the message
|
//Set the text of the message
|
||||||
TextView contentView = convertView.
|
|
||||||
findViewById(R.id.fragment_conversation_message_item_content);
|
|
||||||
contentView.setText(message.getContent());
|
contentView.setText(message.getContent());
|
||||||
|
|
||||||
//Set the color of the message
|
|
||||||
Log.v(TAG, "User ID : " + message.getUser_id() + " current: " + userID);
|
|
||||||
if(message.getUser_id() == userID) {
|
|
||||||
contentView.setTextColor(usercolorText);
|
|
||||||
contentView.setBackgroundColor(usercolorBackground);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
contentView.setTextColor(otherusercolorText);
|
|
||||||
contentView.setBackgroundColor(otherusercolorBackground);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Update account image
|
Update account image
|
||||||
*/
|
*/
|
||||||
//Get the image of the message
|
|
||||||
ImageView accountImage = convertView.
|
|
||||||
findViewById(R.id.fragment_conversation_message_item_accountimage);
|
|
||||||
|
|
||||||
if(message.getUser_id() == userID){
|
|
||||||
accountImage.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
accountImage.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user