Exemplo n.º 1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View ProgressTrackerView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.progress_tracker_card, parent, false);

            ProgressTrackerViewHolder nrviewholder = new ProgressTrackerViewHolder(ProgressTrackerView);

            return(nrviewholder);
        }
Exemplo n.º 2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            ProgressTrackerViewHolder nrviewholder = holder as ProgressTrackerViewHolder;

            nrviewholder.NutrientName.Text            = _nutrientProgressRecords[position].NutrientName;
            nrviewholder.NutrientGoalAmount.Text      = "Goal: " + _nutrientProgressRecords[position].GoalAmount.ToString();
            nrviewholder.NutrientProgressAmount.Text  = "Progress: " + _nutrientProgressRecords[position].ProgressAmount.ToString();
            nrviewholder.NutrientRemainingAmount.Text = "Remaining: " + _nutrientProgressRecords[position].RemainingAmount.ToString();

            var percentComplete = (int)((_nutrientProgressRecords[position].ProgressAmount / _nutrientProgressRecords[position].GoalAmount) * 100);

            nrviewholder.ProgressBar.Progress = percentComplete <= 100 ? percentComplete : 100;

            if (_nutrientProgressRecords[position].GoalIsHigh && percentComplete >= 100 ||
                !_nutrientProgressRecords[position].GoalIsHigh && percentComplete < 100)
            {
                nrviewholder.ProgressBar.ProgressDrawable.SetColorFilter(Color.LimeGreen, PorterDuff.Mode.Multiply);
            }
            else if (_nutrientProgressRecords[position].GoalIsHigh && percentComplete < 100 ||
                     !_nutrientProgressRecords[position].GoalIsHigh && percentComplete >= 100)
            {
                nrviewholder.ProgressBar.ProgressDrawable.SetColorFilter(Color.Red, PorterDuff.Mode.Multiply);
            }
        }