use of com.jexapps.bloodhub.m_Model.Appointment in project BloodHub by kazijehangir.
the class AppointmentsOrgFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = (View) inflater.inflate(R.layout.fragment_appointments_org, container, false);
db = FirebaseDatabase.getInstance().getReference().child("appointments");
appointments = new ArrayList<Appointment>();
keys = new ArrayList<String>();
fetchData();
numAppointments = (TextView) rootView.findViewById(R.id.num_appointments);
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.appointment_list_recycler_view);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new RecycleMarginDecoration(getActivity()));
mAdapter = new MyAppointmentOrgDataAdapter(appointments, keys);
mRecyclerView.setAdapter(mAdapter);
return rootView;
}
use of com.jexapps.bloodhub.m_Model.Appointment in project BloodHub by kazijehangir.
the class MyAppointmentOrgDataAdapter method onBindViewHolder.
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(final MyAppointmentOrgDataAdapter.ViewHolder holder, int position) {
final Appointment appointment = appointments.get(position);
final String key = keys.get(position);
holder.cv.setTag(keys.get(position));
if (appointment.transport) {
holder.mTransport.setText("Yes");
} else {
holder.mTransport.setText("No");
}
holder.mDate.setText(DateFormat.getDateInstance().format(new Date(appointment.date)));
holder.mTime.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(new Date(appointment.date)));
FirebaseDatabase.getInstance().getReference().child("users").child(appointment.userid).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
User usr = dataSnapshot.getValue(User.class);
holder.mName.setText(usr.username);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
holder.accept.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FirebaseDatabase.getInstance().getReference().child("appointments").child(key).child("confirmed").setValue(true);
holder.accept.setVisibility(View.GONE);
holder.decline.setVisibility(View.GONE);
}
});
}
Aggregations