mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Conversation messages images are displayed
This commit is contained in:
parent
485f9f5f4c
commit
7f3a6eca4d
@ -100,6 +100,15 @@ public class ConversationMessage {
|
|||||||
return image_path;
|
return image_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the message has an associated image or not
|
||||||
|
*
|
||||||
|
* @return TRUE if the message has an associated image / FALSE else
|
||||||
|
*/
|
||||||
|
public boolean hasImage(){
|
||||||
|
return image_path != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the path of the image associated with the content
|
* Get the path of the image associated with the content
|
||||||
*
|
*
|
||||||
|
@ -88,8 +88,9 @@ public class ConversationMessageAdapter extends ArrayAdapter<ConversationMessage
|
|||||||
Update the general layout of the message
|
Update the general layout of the message
|
||||||
*/
|
*/
|
||||||
TextView contentView;
|
TextView contentView;
|
||||||
ImageView accountImage;
|
ImageView messageImageView;
|
||||||
TextView userName;
|
ImageView accountImageView;
|
||||||
|
TextView userNameView;
|
||||||
if(message.getUser_id() == userID){
|
if(message.getUser_id() == userID){
|
||||||
|
|
||||||
//Message appears on the right
|
//Message appears on the right
|
||||||
@ -101,10 +102,14 @@ public class ConversationMessageAdapter extends ArrayAdapter<ConversationMessage
|
|||||||
contentView = convertView.
|
contentView = convertView.
|
||||||
findViewById(R.id.fragment_conversation_message_item_content_right);
|
findViewById(R.id.fragment_conversation_message_item_content_right);
|
||||||
|
|
||||||
accountImage = convertView.
|
messageImageView = convertView.
|
||||||
|
findViewById(R.id.fragment_conversation_message_item_messageimage_right);
|
||||||
|
|
||||||
|
accountImageView = convertView.
|
||||||
findViewById(R.id.fragment_conversation_message_item_accountimage_right);
|
findViewById(R.id.fragment_conversation_message_item_accountimage_right);
|
||||||
|
|
||||||
userName = null;
|
|
||||||
|
userNameView = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -117,10 +122,13 @@ public class ConversationMessageAdapter extends ArrayAdapter<ConversationMessage
|
|||||||
contentView = convertView.
|
contentView = convertView.
|
||||||
findViewById(R.id.fragment_conversation_message_item_content);
|
findViewById(R.id.fragment_conversation_message_item_content);
|
||||||
|
|
||||||
accountImage = convertView.
|
messageImageView = convertView.
|
||||||
|
findViewById(R.id.fragment_conversation_message_item_messageimage);
|
||||||
|
|
||||||
|
accountImageView = convertView.
|
||||||
findViewById(R.id.fragment_conversation_message_item_accountimage);
|
findViewById(R.id.fragment_conversation_message_item_accountimage);
|
||||||
|
|
||||||
userName = convertView.findViewById(R.id.fragment_conversation_message_item_username);
|
userNameView = convertView.findViewById(R.id.fragment_conversation_message_item_username);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -139,22 +147,37 @@ public class ConversationMessageAdapter extends ArrayAdapter<ConversationMessage
|
|||||||
contentView.setText(message.getContent());
|
contentView.setText(message.getContent());
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Update message image
|
||||||
|
*/
|
||||||
|
if(message.hasImage()){
|
||||||
|
//Load the image
|
||||||
|
ImageLoadManager.remove(messageImageView);
|
||||||
|
ImageLoadManager.load(getContext(), message.getImage_path(), messageImageView);
|
||||||
|
|
||||||
|
//Make the image visible
|
||||||
|
messageImageView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
messageImageView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Update user name
|
Update user name
|
||||||
*/
|
*/
|
||||||
if(userName != null){
|
if(userNameView != null){
|
||||||
|
|
||||||
if(user != null){
|
if(user != null){
|
||||||
//Set the name of the user
|
//Set the name of the user
|
||||||
userName.setText(user.getFullName());
|
userNameView.setText(user.getFullName());
|
||||||
userName.setVisibility(View.VISIBLE);
|
userNameView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
userName.setVisibility(View.GONE);
|
userNameView.setVisibility(View.GONE);
|
||||||
|
|
||||||
if(previousMessage != null){
|
if(previousMessage != null){
|
||||||
if (message.getUser_id() == previousMessage.getUser_id()){
|
if (message.getUser_id() == previousMessage.getUser_id()){
|
||||||
userName.setVisibility(View.GONE);
|
userNameView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,22 +187,22 @@ public class ConversationMessageAdapter extends ArrayAdapter<ConversationMessage
|
|||||||
Update account image
|
Update account image
|
||||||
*/
|
*/
|
||||||
//Cancel any load pending operation
|
//Cancel any load pending operation
|
||||||
ImageLoadManager.remove(accountImage);
|
ImageLoadManager.remove(accountImageView);
|
||||||
|
|
||||||
//Set the default image
|
//Set the default image
|
||||||
accountImage.setImageResource(R.drawable.default_account_image);
|
accountImageView.setImageResource(R.drawable.default_account_image);
|
||||||
accountImage.setVisibility(View.VISIBLE);
|
accountImageView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
//Check if we can load a specific image
|
//Check if we can load a specific image
|
||||||
if(user != null) {
|
if(user != null) {
|
||||||
String imageURL = user.getAcountImageURL();
|
String imageURL = user.getAcountImageURL();
|
||||||
ImageLoadManager.load(getContext(), imageURL, accountImage);
|
ImageLoadManager.load(getContext(), imageURL, accountImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Hide user image if not required
|
//Hide user image if not required
|
||||||
if(previousMessage != null){
|
if(previousMessage != null){
|
||||||
if (message.getUser_id() == previousMessage.getUser_id()){
|
if (message.getUser_id() == previousMessage.getUser_id()){
|
||||||
accountImage.setVisibility(View.INVISIBLE);
|
accountImageView.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
tools:text="User name" />
|
tools:text="User name" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="1dp">
|
android:padding="1dp">
|
||||||
@ -34,22 +33,41 @@
|
|||||||
android:layout_height="26dp"
|
android:layout_height="26dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginEnd="5dp"
|
android:layout_marginEnd="5dp"
|
||||||
android:src="@drawable/default_account_image"
|
android:contentDescription="@string/user_image_description"
|
||||||
android:contentDescription="@string/user_image_description"/>
|
android:src="@drawable/default_account_image"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toEndOf="@id/fragment_conversation_message_item_accountimage"
|
||||||
|
android:background="@drawable/fragment_conversation_message_otheruser_bg"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:paddingEnd="15dp"
|
||||||
|
android:paddingStart="15dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/fragment_conversation_message_item_content"
|
android:id="@+id/fragment_conversation_message_item_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_toEndOf="@id/fragment_conversation_message_item_accountimage"
|
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:paddingEnd="15dp"
|
|
||||||
android:paddingStart="15dp"
|
|
||||||
android:textColor="@color/conversation_otheruser_messages_textColor"
|
android:textColor="@color/conversation_otheruser_messages_textColor"
|
||||||
android:background="@drawable/fragment_conversation_message_otheruser_bg"
|
|
||||||
tools:text="A message" />
|
tools:text="A message" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/fragment_conversation_message_item_messageimage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:contentDescription="@string/fragment_conversation_message_image"
|
||||||
|
tools:background="@android:color/black"
|
||||||
|
tools:layout_height="40dp"
|
||||||
|
tools:layout_width="40dp"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@ -71,19 +89,39 @@
|
|||||||
android:contentDescription="@string/user_image_description"
|
android:contentDescription="@string/user_image_description"
|
||||||
android:src="@drawable/default_account_image" />
|
android:src="@drawable/default_account_image" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toStartOf="@id/fragment_conversation_message_item_accountimage_right"
|
||||||
|
android:background="@drawable/fragment_conversation_message_currentuser_bg"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:paddingEnd="15dp"
|
||||||
|
android:paddingStart="15dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/fragment_conversation_message_item_content_right"
|
android:id="@+id/fragment_conversation_message_item_content_right"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_toStartOf="@id/fragment_conversation_message_item_accountimage_right"
|
|
||||||
android:background="@drawable/fragment_conversation_message_currentuser_bg"
|
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:paddingEnd="15dp"
|
|
||||||
android:paddingStart="15dp"
|
|
||||||
android:textColor="@color/conversation_user_messages_textColor"
|
android:textColor="@color/conversation_user_messages_textColor"
|
||||||
tools:text="A message" />
|
tools:text="A message" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/fragment_conversation_message_item_messageimage_right"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:contentDescription="@string/fragment_conversation_message_image"
|
||||||
|
tools:background="@android:color/black"
|
||||||
|
tools:layout_height="40dp"
|
||||||
|
tools:layout_width="40dp"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -52,4 +52,5 @@
|
|||||||
<string name="date_hours">date_hours</string>
|
<string name="date_hours">date_hours</string>
|
||||||
<string name="err_get_user_info">Couldn\'t get user information !</string>
|
<string name="err_get_user_info">Couldn\'t get user information !</string>
|
||||||
<string name="fragment_conversation_err_load_message">Could not load messages!</string>
|
<string name="fragment_conversation_err_load_message">Could not load messages!</string>
|
||||||
|
<string name="fragment_conversation_message_image">Conversation message image</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user