From 1c8cefb1e5a5fad20cf8645ecbf27c10c193d0f0 Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 22 Jan 2018 18:49:05 +0100 Subject: [PATCH] Display posts creation date --- .../client/ui/adapters/PostsAdapter.java | 14 ++++++++-- app/src/main/res/layout/post_item.xml | 28 +++++++++++++++---- app/src/main/res/values/colors.xml | 3 ++ app/src/main/res/values/styles.xml | 9 +++++- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java index 62c200c..6da6ffb 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java @@ -17,6 +17,7 @@ import org.communiquons.android.comunic.client.data.UsersInfo.UserInfo; import org.communiquons.android.comunic.client.data.posts.Post; import org.communiquons.android.comunic.client.data.posts.PostsList; import org.communiquons.android.comunic.client.data.utils.UiUtils; +import org.communiquons.android.comunic.client.data.utils.Utilities; /** * Posts adapter @@ -32,6 +33,11 @@ public class PostsAdapter extends ArrayAdapter{ */ private ArrayMap mUsersInfos; + /** + * Utilities object + */ + private Utilities utils; + /** * Create the Post Adapter * @@ -44,6 +50,9 @@ public class PostsAdapter extends ArrayAdapter{ //Save the users info object mUsersInfos = usersInfos; + + //Create utilities object + utils = new Utilities(getContext()); } @NonNull @@ -78,8 +87,9 @@ public class PostsAdapter extends ArrayAdapter{ ImageLoadManager.load(getContext(), userInfo.getAcountImageURL(), userAccountImage); } - - + //Set post creation time + ((TextView) convertView.findViewById(R.id.post_creation_time)).setText(utils. + timeToString(Utilities.time() - post.getPost_time())); return convertView; } diff --git a/app/src/main/res/layout/post_item.xml b/app/src/main/res/layout/post_item.xml index f6bd9e8..a5baecd 100644 --- a/app/src/main/res/layout/post_item.xml +++ b/app/src/main/res/layout/post_item.xml @@ -17,13 +17,31 @@ android:layout_width="@dimen/account_image_default_width" android:layout_height="@dimen/account_image_default_height" /> - + android:orientation="vertical" + android:layout_gravity="center"> + + + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 41a0a76..19f1708 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -17,4 +17,7 @@ #8c9eff + + + #23527c diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 34918ba..688a2a6 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -35,6 +35,13 @@ + + +