Display comments owner.

This commit is contained in:
Pierre 2018-03-11 18:51:04 +01:00
parent 588ae5a680
commit 4f86d95240
3 changed files with 24 additions and 4 deletions

View File

@ -6,11 +6,14 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import org.communiquons.android.comunic.client.R; import org.communiquons.android.comunic.client.R;
import org.communiquons.android.comunic.client.data.ImageLoad.ImageLoadManager;
import org.communiquons.android.comunic.client.data.UsersInfo.UserInfo; import org.communiquons.android.comunic.client.data.UsersInfo.UserInfo;
import org.communiquons.android.comunic.client.data.comments.Comment; import org.communiquons.android.comunic.client.data.comments.Comment;
import org.communiquons.android.comunic.client.data.utils.UiUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -49,20 +52,35 @@ public class CommentsAdapter extends ArrayAdapter<Comment> {
View v = LayoutInflater.from(context).inflate(R.layout.comment_item, viewGroup, false); View v = LayoutInflater.from(context).inflate(R.layout.comment_item, viewGroup, false);
//Return filled view //Return filled view
return fillView(v, comment, user); return fillView(context, v, comment, user);
} }
/** /**
* Fill a view with a specified comments informations * Fill a view with a specified comments informations
* *
* @param context The context of the acivitiy / application
* @param view The view to update * @param view The view to update
* @param comment The comment to update * @param comment The comment to update
* @param user Information about the user (NULL for none) * @param user Information about the user (NULL for none)
* @return Updated view * @return Updated view
*/ */
private static View fillView(View view, Comment comment, @Nullable UserInfo user){ private static View fillView(Context context, View view, Comment comment,
@Nullable UserInfo user){
//Update user name and account image
ImageView accountImage = view.findViewById(R.id.user_account_image);
TextView accountName = view.findViewById(R.id.user_account_name);
if(user == null){
accountImage.setImageDrawable(UiUtils.getDrawable(context,
R.drawable.default_account_image));
accountName.setText("");
}
else {
ImageLoadManager.load(context, user.getAcountImageURL(), accountImage);
accountName.setText(user.getDisplayFullName());
}
//Update comment content //Update comment content
((TextView)view.findViewById(R.id.comment_text)).setText(comment.getContent()); ((TextView)view.findViewById(R.id.comment_text)).setText(comment.getContent());

View File

@ -9,8 +9,8 @@
<!-- User name and image--> <!-- User name and image-->
<ImageView <ImageView
android:id="@+id/user_account_image" android:id="@+id/user_account_image"
android:layout_width="@dimen/account_image_default_width" android:layout_width="@dimen/account_image_xsmall_width"
android:layout_height="@dimen/account_image_default_height" android:layout_height="@dimen/account_image_xsmall_height"
android:src="@drawable/default_account_image" android:src="@drawable/default_account_image"
android:contentDescription="@string/user_image_description" /> android:contentDescription="@string/user_image_description" />

View File

@ -2,6 +2,8 @@
<!-- The default size of an account image --> <!-- The default size of an account image -->
<dimen name="account_image_default_width">64dp</dimen> <dimen name="account_image_default_width">64dp</dimen>
<dimen name="account_image_default_height">64dp</dimen> <dimen name="account_image_default_height">64dp</dimen>
<dimen name="account_image_xsmall_width">16dp</dimen>
<dimen name="account_image_xsmall_height">16dp</dimen>
<!-- Dimensions for the conversation list --> <!-- Dimensions for the conversation list -->
<dimen name="fragment_conversations_list_icon_width">20dp</dimen> <dimen name="fragment_conversations_list_icon_width">20dp</dimen>