use of com.example.first_responder_app.dataModels.UsersDataModel in project FirstResponse by mattpost1700.
the class RespondingFragment method refreshData.
private void refreshData() {
db.collection("users").whereEqualTo(FirestoreDatabase.FIELD_FIRE_DEPARTMENT_ID, activeUser.getFire_department_id()).whereGreaterThanOrEqualTo("responding_time", AppUtil.earliestTime(requireContext())).get().addOnCompleteListener(userTask -> {
Log.d(TAG, "READ DATABASE - RESPONDING FRAGMENT");
if (userTask.isSuccessful()) {
ArrayList<UsersDataModel> temp = new ArrayList<>();
for (QueryDocumentSnapshot userDoc : userTask.getResult()) {
UsersDataModel user = userDoc.toObject(UsersDataModel.class);
List<String> responses = user.getResponses();
Log.d(TAG, "refreshData: " + isActive(responses.get(responses.size() - 1)));
if (responses != null && responses.size() > 0 && isActive(responses.get(responses.size() - 1)))
temp.add(user);
}
Log.d(TAG, "refreshData: " + AppUtil.earliestTime(requireContext()).toDate());
listOfRespondingDataModel.clear();
listOfRespondingDataModel.addAll(temp);
checkRespondersEmpty();
respondingRecyclerViewAdapter.notifyDataSetChanged();
Log.d("TAG", "populateResponders: ");
} else {
Log.w(TAG, "refreshData: Could not refresh", userTask.getException());
}
});
}
use of com.example.first_responder_app.dataModels.UsersDataModel in project FirstResponse by mattpost1700.
the class NewChatRecyclerViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
UsersDataModel u = mData.get(position);
holder.newUser.setText("Remove " + u.getFull_name());
holder.data = u;
}
use of com.example.first_responder_app.dataModels.UsersDataModel in project FirstResponse by mattpost1700.
the class RespondersGroupRecyclerViewAdapter method onBindViewHolder.
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
UsersDataModel responder = responderList.get(position);
holder.responderNameTextView.setText(responder.getFirst_name() + " " + responder.getLast_name());
setResponseLocation(holder, responder);
setEta(holder, responder);
}
use of com.example.first_responder_app.dataModels.UsersDataModel in project FirstResponse by mattpost1700.
the class ChatGroupRecyclerViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Chat chat = mData.get(position);
Context context = holder.itemView.getContext();
String userId = "";
ActiveUser activeUser = (ActiveUser) context;
if (activeUser != null) {
UsersDataModel user = activeUser.getActive();
if (user != null) {
userId = user.getDocumentId();
}
}
ArrayList<String> members = chat.getMembers();
String a = holder.name.getText().toString();
String chatName = "";
// If it is direct message, set chat name to user's name, otherwise set chat name to the name stored in db
if (members.size() == 2) {
String[] memberAndId0 = members.get(0).split("/");
String[] memberAndId1 = members.get(1).split("/");
if (memberAndId0[1].equals(userId)) {
holder.name.setText(memberAndId1[0]);
} else {
holder.name.setText(memberAndId0[0]);
}
} else {
holder.name.setText(chat.getChatName());
a = holder.name.getText().toString();
}
holder.recentMsg.setText(chat.getMostRecentMessage());
holder.data = chat;
}
use of com.example.first_responder_app.dataModels.UsersDataModel in project FirstResponse by mattpost1700.
the class RespondersRecyclerViewAdapterTest method setUp.
@BeforeEach
void setUp() {
adapter = new RespondersRecyclerViewAdapter(mockFragment.getContext(), listOfResponders);
mockView = mock(View.class);
mockFragment = mock(Fragment.class);
user1 = new UsersDataModel("address1", "first_name1", "last_name1", "password1", 1234567890L, "rank1", "username1", Timestamp.now(), "remote_path_to_profile_picture1");
user2 = new UsersDataModel("address2", "first_name2", "last_name2", "password2", 1234567890L, "rank2", "username2", Timestamp.now(), "remote_path_to_profile_picture2");
}
Aggregations