Beispiel #1
0
        OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View itemView = LayoutInflater.From(parent.Context).
                            Inflate(Resource.Layout.viewMedCard, parent, false);

            PrescriptionViewHolder vh = new PrescriptionViewHolder(itemView, OnClick);

            return(vh);
        }
Beispiel #2
0
        OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            PrescriptionViewHolder vh = holder as PrescriptionViewHolder;

            vh.MedicationName.Text = mUser.Prescriptions[position].Medication.StrengthQty
                                     + " " + mUser.Prescriptions[position].Medication.StrengthUnit
                                     + " " + mUser.Prescriptions[position].Medication.GenericName;

            //see how many doses of this prescription should have been taken so far today
            int dosesToday = 0;


            //Add up all of the doses the user should have taken today
            for (int i = 0; i < mUser.Prescriptions[position].Direction.PreferredTimes.Count; i++)
            {
                if (mUser.Prescriptions[position].Direction.PreferredTimes[i].TimeOfDay < DateTime.Now.TimeOfDay)
                {
                    dosesToday++;
                }
            }
            int missedDoses = CheckMissedDoses(mUser.Prescriptions[position].RXID, mUser, dosesToday);

            if (missedDoses > 0)
            {
                vh.Doses.Text = "Missed " + missedDoses + " dose(s).";
                vh.Doses.SetTextColor(Android.Graphics.Color.Red);
                vh.MedicationName.SetTextColor(Android.Graphics.Color.Red);
                vh.Background.SetBackgroundColor(new Android.Graphics.Color(255, 163, 163));
            }
            else
            {
                /*
                 * if(dosesToday >= mUser.Prescriptions[position].Direction.FrequencyQty)
                 * {
                 *  vh.Doses.SetTextColor(Android.Graphics.Color.Gray);
                 *  vh.MedicationName.SetTextColor(Android.Graphics.Color.Gray);
                 *  vh.Background.SetBackgroundColor(Android.Graphics.Color.LightGray);
                 * }
                 */

                dosesToday    = LocalDataManager.Instance.GetTodaysDosesForPrescription(mUser.Prescriptions[position].RXID).Count;
                vh.Doses.Text = "Completed " + dosesToday + "/" + mUser.Prescriptions[position].Direction.FrequencyQty + " doses.";
            }
        }