From 4f86d95240b880a059179ad1531eb3e74e575df3 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 11 Mar 2018 18:51:04 +0100 Subject: [PATCH] Display comments owner. --- .../client/ui/adapters/CommentsAdapter.java | 22 +++++++++++++++++-- app/src/main/res/layout/comment_item.xml | 4 ++-- app/src/main/res/values/dimens.xml | 2 ++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/CommentsAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/CommentsAdapter.java index 984271b..311b99e 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/CommentsAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/CommentsAdapter.java @@ -6,11 +6,14 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageView; import android.widget.TextView; 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.comments.Comment; +import org.communiquons.android.comunic.client.data.utils.UiUtils; import java.util.ArrayList; @@ -49,20 +52,35 @@ public class CommentsAdapter extends ArrayAdapter { View v = LayoutInflater.from(context).inflate(R.layout.comment_item, viewGroup, false); //Return filled view - return fillView(v, comment, user); + return fillView(context, v, comment, user); } /** * Fill a view with a specified comments informations * + * @param context The context of the acivitiy / application * @param view The view to update * @param comment The comment to update * @param user Information about the user (NULL for none) * @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 ((TextView)view.findViewById(R.id.comment_text)).setText(comment.getContent()); diff --git a/app/src/main/res/layout/comment_item.xml b/app/src/main/res/layout/comment_item.xml index c15cfde..4c06a0a 100644 --- a/app/src/main/res/layout/comment_item.xml +++ b/app/src/main/res/layout/comment_item.xml @@ -9,8 +9,8 @@ diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 3ae54e2..237ee17 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -2,6 +2,8 @@ 64dp 64dp + 16dp + 16dp 20dp