mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-12-27 22:18:58 +00:00
Display a notice on friends fragment when the user does not have any friend.
This commit is contained in:
parent
636c74bc98
commit
2074792212
@ -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) {
|
||||
|
||||
|
@ -10,6 +10,15 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<!-- No friend notice -->
|
||||
<TextView
|
||||
android:id="@+id/no_friend_notice"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/notice_no_friend"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginTop="50dp"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/fragment_friendslist_listview"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -176,4 +176,5 @@
|
||||
<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>
|
||||
<string name="notice_no_conversation">You do not have any conversation yet.</string>
|
||||
<string name="notice_no_friend">You do not have any friend yet.</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user