use of com.example.first_responder_app.dataModels.EventsDataModel in project FirstResponse by mattpost1700.
the class FirestoreDatabase method addEvent.
// TODO: Add event correctly
public void addEvent(String location, String title, String description, Date date, int duration) {
Timestamp eventTime = new Timestamp(date);
EventsDataModel newEvent = new EventsDataModel(activeUserFireDepartmentId, "TEMP_GROUP_ID", activeUser.getDocumentId(), eventTime, title, description, location, duration);
db.collection(EVENTS_COLLECTION_DIR).add(newEvent).addOnSuccessListener(documentReference -> Log.d("new event page", "new event has been successfully created in the DB")).addOnFailureListener(e -> Log.d("new event page", "failed to create new event"));
}
use of com.example.first_responder_app.dataModels.EventsDataModel in project FirstResponse by mattpost1700.
the class EventGroupFragment method populateEventList.
private void populateEventList() {
db.collection("events").whereEqualTo(FirestoreDatabase.FIELD_FIRE_DEPARTMENT_ID, activeUser.getFire_department_id()).orderBy("event_time", Query.Direction.ASCENDING).whereGreaterThanOrEqualTo("event_time", Timestamp.now()).get().addOnCompleteListener(eventTask -> {
Log.d(TAG, "READ DATABASE - EVENT GROUP FRAGMENT");
if (eventTask.isSuccessful()) {
ArrayList<EventsDataModel> temp = new ArrayList<>();
for (QueryDocumentSnapshot eventDoc : eventTask.getResult()) {
EventsDataModel eventDataModel = eventDoc.toObject(EventsDataModel.class);
temp.add(eventDataModel);
}
Log.d(TAG, "populateEventList: " + temp.size());
listOfEvents.clear();
listOfEvents.addAll(temp);
checkEventsEmpty();
eventGroupRecyclerViewAdapter.notifyDataSetChanged();
} else {
Log.d(TAG, "db get failed in event page " + eventTask.getException());
}
});
}
use of com.example.first_responder_app.dataModels.EventsDataModel in project FirstResponse by mattpost1700.
the class EventGroupRecyclerViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
EventsDataModel events = mData.get(position);
holder.title.setText(events.getTitle());
if (events.getEvent_time() != null) {
Date date = events.getEvent_time().toDate();
String time = new SimpleDateFormat("MM/dd/yy\nh:mm aa", Locale.getDefault()).format(date);
holder.date.setText(time);
}
holder.location.setText(events.getLocation());
holder.data = events;
}
Aggregations