Display a notice on user page when there is not any post to show.

This commit is contained in:
Pierre 2018-04-14 17:03:04 +02:00
parent f7fef9905b
commit 4aeddb3ba2
3 changed files with 22 additions and 0 deletions

View File

@ -93,6 +93,11 @@ public class UserPageFragment extends Fragment implements PostsCreateFormFragmen
*/
private ImageView user_image;
/**
* No post notice
*/
private TextView mNoPostNotice;
/**
* Posts list fragment
*/
@ -148,6 +153,10 @@ public class UserPageFragment extends Fragment implements PostsCreateFormFragmen
user_image = view.findViewById(R.id.user_account_image);
user_name = view.findViewById(R.id.user_account_name);
//Get the no post notice
mNoPostNotice = view.findViewById(R.id.no_post_notice);
mNoPostNotice.setVisibility(View.GONE);
//Get the view related to the create post form
mCreatePostButton = view.findViewById(R.id.create_post_button);
mCreatePostForm = view.findViewById(R.id.create_post_form);
@ -325,6 +334,9 @@ public class UserPageFragment extends Fragment implements PostsCreateFormFragmen
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_user_page, mPostsListFragment);
transaction.commit();
//Check if there is not any post on the page
mNoPostNotice.setVisibility(mPostsList.size() == 0 ? View.VISIBLE : View.GONE);
}
/**

View File

@ -54,6 +54,15 @@
android:id="@+id/create_post_form"
layout="@layout/post_create_form" />
<!-- No post on user page notice -->
<TextView
android:id="@+id/no_post_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/notice_no_post_user_page"
android:layout_gravity="center"
android:layout_marginTop="10dp"/>
<!-- User posts -->
<FrameLayout
android:id="@+id/user_posts"

View File

@ -174,4 +174,5 @@
<string name="err_get_friendship_status">An error occurred while retrieving friendship status!</string>
<string name="err_get_post_info">An error occurred while trying to get post information!</string>
<string name="notice_no_notification">You do not have any notification yet.</string>
<string name="notice_no_post_user_page">There is not any post on this page yet.</string>
</resources>