mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Added support for conversation images.
This commit is contained in:
parent
2a202f1308
commit
6252cfaf2f
@ -4,7 +4,6 @@ import android.content.Context;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -12,12 +11,11 @@ import android.widget.TextView;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.arrays.ConversationMessagesList;
|
||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||
import org.communiquons.android.comunic.client.data.models.ConversationMessage;
|
||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||
import org.communiquons.android.comunic.client.ui.views.EnlargeableWebImageView;
|
||||
import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Conversation messages adapter
|
||||
*
|
||||
@ -121,11 +119,13 @@ public class ConversationMessageAdapter extends RecyclerView.Adapter {
|
||||
private class BaseMessageHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView mMessage;
|
||||
private EnlargeableWebImageView mImage;
|
||||
|
||||
BaseMessageHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
mMessage = itemView.findViewById(R.id.message_body);
|
||||
mImage = itemView.findViewById(R.id.messageImage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +135,16 @@ public class ConversationMessageAdapter extends RecyclerView.Adapter {
|
||||
*/
|
||||
@CallSuper
|
||||
void bind(int pos){
|
||||
mMessage.setText(mList.get(pos).getContent());
|
||||
ConversationMessage message = mList.get(pos);
|
||||
|
||||
mMessage.setText(message.getContent());
|
||||
mMessage.setVisibility(mMessage.getText().length() > 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
mImage.setVisibility(message.hasImage() ? View.VISIBLE : View.GONE);
|
||||
if(message.hasImage())
|
||||
mImage.loadURL(message.getImage_path());
|
||||
else
|
||||
mImage.removeImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,41 +6,69 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp">
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:id="@+id/constraintLayout2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
|
||||
android:id="@+id/account_image"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:src="@drawable/default_account_image"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginStart="8dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
android:src="@drawable/default_account_image"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_name"
|
||||
tools:text="John Doe"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/account_image"
|
||||
android:layout_marginStart="8dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="4dp" />
|
||||
app:layout_constraintTop_toTopOf="@id/account_image"
|
||||
tools:text="John Doe" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message_body"
|
||||
tools:text="Hello man, how are you?"
|
||||
android:background="@drawable/conversation_message_otheruser_bg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:background="@drawable/conversation_message_otheruser_bg"
|
||||
android:maxWidth="240dp"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/conversation_otheruser_messages_textColor"
|
||||
android:layout_marginTop="4dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/user_name"
|
||||
app:layout_constraintLeft_toRightOf="@+id/account_image"
|
||||
android:layout_marginStart="8dp" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/user_name"
|
||||
tools:text="Hello man, how are you?" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
|
||||
<org.communiquons.android.comunic.client.ui.views.EnlargeableWebImageView
|
||||
android:id="@+id/messageImage"
|
||||
android:layout_width="157dp"
|
||||
android:layout_height="98dp"
|
||||
android:layout_marginStart="60dp"
|
||||
android:layout_marginTop="2dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/constraintLayout2"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
app:srcCompat="@drawable/img_placeholder"
|
||||
android:scaleType="fitStart"/>
|
||||
|
||||
|
||||
|
||||
<!---<TextView
|
||||
android:id="@+id/text_message_time"
|
||||
|
@ -6,7 +6,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp">
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message_body"
|
||||
@ -21,6 +21,23 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<org.communiquons.android.comunic.client.ui.views.EnlargeableWebImageView
|
||||
android:id="@+id/messageImage"
|
||||
android:layout_width="157dp"
|
||||
android:layout_height="98dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:scaleType="fitEnd"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/message_body"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/message_body"
|
||||
app:layout_constraintTop_toBottomOf="@+id/message_body"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
app:srcCompat="@drawable/img_placeholder" />
|
||||
|
||||
<!--<TextView
|
||||
android:id="@+id/text_message_time"
|
||||
android:text="11:40"
|
||||
|
Loading…
Reference in New Issue
Block a user