Display posts creation date

This commit is contained in:
Pierre 2018-01-22 18:49:05 +01:00
parent 6280541829
commit 1c8cefb1e5
4 changed files with 46 additions and 8 deletions

View File

@ -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.Post;
import org.communiquons.android.comunic.client.data.posts.PostsList; 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.UiUtils;
import org.communiquons.android.comunic.client.data.utils.Utilities;
/** /**
* Posts adapter * Posts adapter
@ -32,6 +33,11 @@ public class PostsAdapter extends ArrayAdapter<Post>{
*/ */
private ArrayMap<Integer, UserInfo> mUsersInfos; private ArrayMap<Integer, UserInfo> mUsersInfos;
/**
* Utilities object
*/
private Utilities utils;
/** /**
* Create the Post Adapter * Create the Post Adapter
* *
@ -44,6 +50,9 @@ public class PostsAdapter extends ArrayAdapter<Post>{
//Save the users info object //Save the users info object
mUsersInfos = usersInfos; mUsersInfos = usersInfos;
//Create utilities object
utils = new Utilities(getContext());
} }
@NonNull @NonNull
@ -78,8 +87,9 @@ public class PostsAdapter extends ArrayAdapter<Post>{
ImageLoadManager.load(getContext(), userInfo.getAcountImageURL(), userAccountImage); 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; return convertView;
} }

View File

@ -17,13 +17,31 @@
android:layout_width="@dimen/account_image_default_width" android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height" /> android:layout_height="@dimen/account_image_default_height" />
<TextView <LinearLayout
android:id="@+id/user_account_name"
style="@style/PostOwnerName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="User name" android:orientation="vertical"
android:layout_gravity="center"/> android:layout_gravity="center">
<!-- User name -->
<TextView
android:id="@+id/user_account_name"
style="@style/PostOwnerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:text="User name" />
<!-- Post creation time -->
<TextView
android:id="@+id/post_creation_time"
style="@style/PostDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="15 days ago"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -17,4 +17,7 @@
<!-- Conversations footer --> <!-- Conversations footer -->
<color name="conversation_footer_bg">#8c9eff</color> <color name="conversation_footer_bg">#8c9eff</color>
<!-- Specify to users name -->
<color name="user_name_link">#23527c</color>
</resources> </resources>

View File

@ -35,6 +35,13 @@
<!-- Post owner name --> <!-- Post owner name -->
<style name="PostOwnerName"> <style name="PostOwnerName">
<item name="android:paddingStart">10dp</item> <item name="android:paddingLeft">5dp</item>
<item name="android:textColor">@color/user_name_link</item>
<item name="android:textStyle">bold</item>
</style>
<!-- Post date -->
<style name="PostDate">
<item name="android:paddingLeft">10dp</item>
</style> </style>
</resources> </resources>