From 20747922122ab3b657551cd2741566f30f89a82f Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 14 Apr 2018 17:41:24 +0200 Subject: [PATCH] Display a notice on friends fragment when the user does not have any friend. --- .../ui/fragments/FriendsListFragment.java | 22 ++++++++++++++++++- .../main/res/layout/fragment_friendslist.xml | 9 ++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/FriendsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/FriendsListFragment.java index 3abb3b8..fd01600 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/FriendsListFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/FriendsListFragment.java @@ -16,6 +16,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ListView; +import android.widget.TextView; import android.widget.Toast; import org.communiquons.android.comunic.client.ui.activities.MainActivity; @@ -93,6 +94,11 @@ public class FriendsListFragment extends Fragment */ private FriendsAdapter fAdapter; + /** + * No friend notice + */ + private TextView mNoFriendNotice; + @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -135,6 +141,10 @@ public class FriendsListFragment extends Fragment rootView = view; + //Get the no friend notice + mNoFriendNotice = view.findViewById(R.id.no_friend_notice); + mNoFriendNotice.setVisibility(View.GONE); + //Retain the fragment //setRetainInstance(true); @@ -218,10 +228,12 @@ public class FriendsListFragment extends Fragment return; } - //Save the list of friends this.friendsList = friendsList; + //Update the visibility of the no friend notice + updateNoFriendNoticeVisibility(); + //Set the adapter fAdapter = new FriendsAdapter(this, getActivity(), friendsList); ListView listView = rootView.findViewById(R.id.fragment_friendslist_listview); @@ -384,6 +396,14 @@ public class FriendsListFragment extends Fragment } + /** + * Update the visibility of the no friend notice + */ + private void updateNoFriendNoticeVisibility(){ + if(friendsList != null) + mNoFriendNotice.setVisibility(friendsList.size() == 0 ? View.VISIBLE : View.GONE); + } + @Override public void onItemClick(AdapterView parent, View view, int position, long id) { diff --git a/app/src/main/res/layout/fragment_friendslist.xml b/app/src/main/res/layout/fragment_friendslist.xml index 957b4fb..80dad2d 100644 --- a/app/src/main/res/layout/fragment_friendslist.xml +++ b/app/src/main/res/layout/fragment_friendslist.xml @@ -10,6 +10,15 @@ android:layout_height="wrap_content" android:layout_centerHorizontal="true" /> + + + You do not have any notification yet. There is not any post on this page yet. You do not have any conversation yet. + You do not have any friend yet.