Search in sources :

Example 1 with ContactListAdapter

use of com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofilecontroller.ContactListAdapter in project Grupp by tmoronta1208.

the class InvitedFriendsFragment method convertIdsToUsers.

public void convertIdsToUsers(ArrayList<String> invitedList) {
    friendsUserIDList = new ArrayList<>();
    friendsUserIDList.addAll(invitedList);
    Log.d("UserFriends Fragment", "convertIdsTousers");
    if (friendsUserIDList != null) {
        if (friendsUserIDList.size() != 0) {
            for (String s : friendsUserIDList) {
                userDataUtility.getPublicUser(s, new FBUserDataListener() {

                    @Override
                    public void getUid(String userID) {
                    }

                    @Override
                    public void getPublicUser(PublicUser publicUser) {
                        friendsUserList.add(publicUser);
                    }
                });
            }
            if (friendsUserList != null) {
                if (getActivity() != null) {
                    contactListAdapter = new ContactListAdapter(PublicUserDetails.class, R.layout.contact_item_view, ContactListViewHolder.class, contactsRef);
                    linearLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
                    recyclerView.setAdapter(contactListAdapter);
                    recyclerView.setLayoutManager(linearLayoutManager);
                    recyclerView.addItemDecoration(new SimpleDividerItemDecoration(getContext()));
                }
            }
        }
    } else {
    }
}
Also used : SimpleDividerItemDecoration(com.example.c4q.capstone.utils.SimpleDividerItemDecoration) PublicUser(com.example.c4q.capstone.database.publicuserdata.PublicUser) ContactListAdapter(com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofilecontroller.ContactListAdapter) FBUserDataListener(com.example.c4q.capstone.utils.FBUserDataListener) PublicUserDetails(com.example.c4q.capstone.database.publicuserdata.PublicUserDetails) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ContactListViewHolder(com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofileviews.ContactListViewHolder)

Example 2 with ContactListAdapter

use of com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofilecontroller.ContactListAdapter in project Grupp by tmoronta1208.

the class ContactListFragment method onCreateView.

/* public static ContactListFragment newInstance(String title) {
        ContactListFragment fragment = new ContactListFragment();
        Bundle args = new Bundle();
        args.putString("title", title);
        fragment.setArguments(args);
        return fragment;
    }*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_contactlist, container, false);
    searchView = view.findViewById(R.id.search_bar_cl);
    searchView.setHint("Name, #Grupptag, Email");
    searchView.setHintTextColor(getActivity().getResources().getColor(R.color.hintcolor));
    String currentUserId = CurrentUser.getInstance().getUserID();
    DatabaseReference contactsRef = FirebaseDatabase.getInstance().getReference().child(USER_CONTACTS).child(currentUserId);
    recyclerView = view.findViewById(R.id.contact_list_rec);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayout = new LinearLayoutManager(view.getContext());
    contactListAdapter = new ContactListAdapter(PublicUserDetails.class, R.layout.contact_item_view, ContactListViewHolder.class, contactsRef);
    /**
     *ajoxe:
     * after modifying the adapter, set the list as friendsUserList
     * contactListAdapter = new ContactListAdapter(friendsUserList, getContext());
     */
    recyclerView.setAdapter(contactListAdapter);
    recyclerView.addItemDecoration(new SimpleDividerItemDecoration(getContext()));
    recyclerView.setLayoutManager(linearLayout);
    return view;
}
Also used : SimpleDividerItemDecoration(com.example.c4q.capstone.utils.SimpleDividerItemDecoration) ContactListAdapter(com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofilecontroller.ContactListAdapter) DatabaseReference(com.google.firebase.database.DatabaseReference) PublicUserDetails(com.example.c4q.capstone.database.publicuserdata.PublicUserDetails) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ContactListViewHolder(com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofileviews.ContactListViewHolder)

Example 3 with ContactListAdapter

use of com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofilecontroller.ContactListAdapter in project Grupp by tmoronta1208.

the class InvitedFriendsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String currentUserId = CurrentUser.getInstance().getUserID();
    contactsRef = FirebaseDatabase.getInstance().getReference().child(USER_CONTACTS).child(currentUserId).child("contacts");
    contactListAdapter = new ContactListAdapter(PublicUserDetails.class, R.layout.contact_item_view, ContactListViewHolder.class, contactsRef);
    args = getArguments();
    if (args != null) {
        if (args.getStringArrayList("invitedFriends") != null) {
            ArrayList<String> invitedFriends = args.getStringArrayList("invitedFriends");
            Log.d("UserFriends Fragment", "on create: invited list array size:" + invitedFriends.size());
            friendsUserIDList = invitedFriends;
            convertIdsToUsers(invitedFriends);
        }
    }
    if (friendsUserIDList == null || friendsUserIDList.size() == 0) {
        Log.d("UserFriends Fragment", "on createview: invited list array is null");
    } else {
        convertIdsToUsers(friendsUserIDList);
        if (friendsUserList != null) {
            if (getActivity() != null) {
                contactListAdapter = new ContactListAdapter(PublicUserDetails.class, R.layout.contact_item_view, ContactListViewHolder.class, contactsRef);
                linearLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
                recyclerView.setAdapter(contactListAdapter);
                recyclerView.setLayoutManager(linearLayoutManager);
            }
        }
    }
}
Also used : ContactListAdapter(com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofilecontroller.ContactListAdapter) PublicUserDetails(com.example.c4q.capstone.database.publicuserdata.PublicUserDetails) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ContactListViewHolder(com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofileviews.ContactListViewHolder)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 PublicUserDetails (com.example.c4q.capstone.database.publicuserdata.PublicUserDetails)3 ContactListAdapter (com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofilecontroller.ContactListAdapter)3 ContactListViewHolder (com.example.c4q.capstone.userinterface.user.userprofilefragments.userprofileviews.ContactListViewHolder)3 SimpleDividerItemDecoration (com.example.c4q.capstone.utils.SimpleDividerItemDecoration)2 PublicUser (com.example.c4q.capstone.database.publicuserdata.PublicUser)1 FBUserDataListener (com.example.c4q.capstone.utils.FBUserDataListener)1 DatabaseReference (com.google.firebase.database.DatabaseReference)1