Search in sources :

Example 6 with Appointment

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;
}
Also used : Appointment(com.jexapps.bloodhub.m_Model.Appointment) MyAppointmentOrgDataAdapter(com.jexapps.bloodhub.m_UI.MyAppointmentOrgDataAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 7 with Appointment

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);
        }
    });
}
Also used : Appointment(com.jexapps.bloodhub.m_Model.Appointment) User(com.jexapps.bloodhub.m_Model.User) DatabaseError(com.google.firebase.database.DatabaseError) ValueEventListener(com.google.firebase.database.ValueEventListener) DataSnapshot(com.google.firebase.database.DataSnapshot) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) Date(java.util.Date)

Aggregations

Appointment (com.jexapps.bloodhub.m_Model.Appointment)7 DataSnapshot (com.google.firebase.database.DataSnapshot)5 DatabaseError (com.google.firebase.database.DatabaseError)5 ValueEventListener (com.google.firebase.database.ValueEventListener)5 View (android.view.View)4 RecyclerView (android.support.v7.widget.RecyclerView)3 TextView (android.widget.TextView)3 FirebaseUser (com.google.firebase.auth.FirebaseUser)3 User (com.jexapps.bloodhub.m_Model.User)3 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 FirebaseAuth (com.google.firebase.auth.FirebaseAuth)2 Date (java.util.Date)2 Dialog (android.app.Dialog)1 Intent (android.content.Intent)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 CardView (android.support.v7.widget.CardView)1 ArrayAdapter (android.widget.ArrayAdapter)1 Button (android.widget.Button)1 DatePicker (android.widget.DatePicker)1