use of com.example.c4q.capstone.database.publicuserdata.PublicUser in project Grupp by tmoronta1208.
the class CreateProfileFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(com.example.c4q.capstone.R.layout.fragment_create_profile, container, false);
// saveBtn = rootView.findViewById(R.id.create_profile_save_button);
ageGroup = rootView.findViewById(R.id.radio_group_age);
budgetGroup = rootView.findViewById(R.id.radio_group_budget);
radiusGroup = rootView.findViewById(R.id.radio_group_radius);
firstName = rootView.findViewById(R.id.edit_profile_firstname);
lastName = rootView.findViewById(R.id.edit_profile_lastname);
zipCode = rootView.findViewById(R.id.edit_profile_zip_code);
rootRef = FirebaseDatabase.getInstance().getReference();
publicUserReference = rootRef.child(PUBLIC_USER);
privateUserReference = rootRef.child(PRIVATE_USER);
privateUserLocationReference = rootRef.child(PRIVATE_USER);
userIconReference = rootRef.child(USER_ICON);
mAuth = FirebaseAuth.getInstance();
currentUser = mAuth.getCurrentUser();
currentUserID = currentUser.getUid();
currentUserEmail = currentUser.getEmail();
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
privateUser = dataSnapshot.child(currentUserID).getValue(PrivateUser.class);
privateUserLocation = dataSnapshot.child(currentUserID).getValue(PrivateUserLocation.class);
publicUser = dataSnapshot.child(currentUserID).getValue(PublicUser.class);
userIcon = dataSnapshot.child(currentUserID).getValue(UserIcon.class);
Log.d(TAG, "onDataChange: Added information to database: \n" + dataSnapshot.getValue());
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
};
publicUserReference.addValueEventListener(valueEventListener);
privateUserReference.addValueEventListener(valueEventListener);
privateUserLocationReference.addValueEventListener(valueEventListener);
userIconReference.addValueEventListener(valueEventListener);
saveBtn = rootView.findViewById(R.id.create_profile_save_button);
radioGroupSelection();
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
if (currentUser != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + currentUser.getUid());
// Toast.makeText(EditProfileActivity.this, "Successfully signed in with: " + currentUser.getEmail(), Toast.LENGTH_SHORT).show();
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
// Toast.makeText(EditProfileActivity.this, "Successfully signed out.", Toast.LENGTH_SHORT).show();
}
}
};
saveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveToDatabase();
}
});
return rootView;
}
use of com.example.c4q.capstone.database.publicuserdata.PublicUser in project Grupp by tmoronta1208.
the class CreateProfileFragment method saveToDatabase.
private void saveToDatabase() {
firstNameString = firstName.getText().toString().trim();
lastNameString = lastName.getText().toString().trim();
zipCodeString = zipCode.getText().toString();
if (!firstNameString.equals("") && !lastNameString.equals("") && !zipCodeString.equals("")) {
publicUser = new PublicUser(currentUserID, firstNameString, lastNameString, zipCodeString, budgetString, currentUserEmail, over18, over21, radius);
privateUser = new PrivateUser(firstNameString, lastNameString, over18, over21, radius);
privateUserLocation = new PrivateUserLocation(share_location, lat, lng);
userIcon = new UserIcon(iconUrl);
/**
* searchUserReference needs to be added at time of account creation
*/
publicUserReference.child(currentUserID).setValue(publicUser);
privateUserReference.child(currentUserID).setValue(privateUser);
userIconReference.child(currentUserID).setValue(userIcon);
privateUserLocationReference.child(currentUserID).child(PRIVATE_LOCATION).setValue(privateUserLocation);
// startActivity(new Intent(CreateProfileFragment.this.getActivity(), UserProfileActivity.class));
} else {
firstName.setError("Required");
lastName.setError("Required");
zipCode.setError("Required");
}
}
use of com.example.c4q.capstone.database.publicuserdata.PublicUser in project Grupp by tmoronta1208.
the class UserSearchActivity method searchUser.
private void searchUser(String query) {
Query userSearchQuery;
if (query.contains("@")) {
userSearchQuery = searchUserRef.orderByChild("email").startAt(query).endAt(query + "\uf8ff");
} else {
userSearchQuery = searchUserRef.orderByChild("first_name").startAt(query).endAt(query + "\uf8ff");
}
FirebaseRecyclerAdapter<PublicUser, UserSearchViewHolder> contactsListAdapter = new FirebaseRecyclerAdapter<PublicUser, UserSearchViewHolder>(PublicUser.class, R.layout.add_contact_itemview, UserSearchViewHolder.class, userSearchQuery) {
@Override
protected void populateViewHolder(final UserSearchViewHolder viewHolder, final PublicUser model, int position) {
final String contactID = getRef(position).getKey();
final String email = model.getEmail();
final String first = model.getFirst_name();
final String last = model.getLast_name();
final String icon = model.getUser_icon().getIcon_url();
final String zipCode = model.getZip_code();
// final int radius = model.getRadius();
viewHolder.setEmail(email);
viewHolder.setFullName(first, last);
viewHolder.setIcon(icon);
viewHolder.addContactButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String radiusString = "20";
addToContactList(contactID, viewHolder.addContactButton, first, last, email, icon, radiusString, zipCode);
}
});
}
};
searchContactsRecyclerView.setAdapter(contactsListAdapter);
}
use of com.example.c4q.capstone.database.publicuserdata.PublicUser in project Grupp by tmoronta1208.
the class InviteListAdapter method populateViewHolder.
@Override
protected void populateViewHolder(ContactListViewHolder viewHolder, PublicUserDetails model, int position) {
String first = model.getFirst_name();
String last = model.getLast_name();
String email = model.getEmail();
String url = model.getIcon_url();
viewHolder.setUserIcon(url);
viewHolder.setName(first, last);
viewHolder.setEmail(email);
viewHolder.itemView.setTag(model.getUid());
viewHolder.itemView.setOnClickListener(onClickListener);
List<PublicUser> invitedFriendUser = NewEventBuilder.getInstance().getInvitedFriendsUserList();
NewEventConverter eventConverter = new NewEventConverter();
PublicUser user = new PublicUser();
user = eventConverter.convertPubDetailsToPubUser(model);
if (invitedFriendUser != null) {
invitedFriendUser.add(user);
Log.d("invite adapter", "pub user list size: " + invitedFriendUser.size());
} else {
invitedFriendUser = new ArrayList<>();
invitedFriendUser.add(user);
Log.d("invite adapter", "pub user list size: " + invitedFriendUser.size());
}
NewEventBuilder.getInstance().setInvitedFriendsUserList(invitedFriendUser);
}
use of com.example.c4q.capstone.database.publicuserdata.PublicUser 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 {
}
}
Aggregations