Esempio n. 1
0
 private void SetTotalScoreTextBox(ScoreViewHolder vh)
 {
     if (vh.TvTotalScore != null)
     {
         vh.TvTotalScore.Text = _mUserScore.scores.Sum(s => s).ToString();
     }
 }
Esempio n. 2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (_isInitialLoad < _mUserScore.scores.Count)
            {
                _isInitialLoad++;
            }
            ScoreViewHolder vh = holder as ScoreViewHolder;

            if (vh == null)
            {
                return;
            }

            vh.EtScore.Text = _mUserScore.scores[position]?.ToString();
            SetTotalScoreTextBox(vh);
            vh.EtScore.AfterTextChanged += (sender, args) =>
            {
                if (_mUserScore.scores[position] == CommonUtils.NullIfEmpty(vh.EtScore.Text))
                {
                    return;
                }

                _mUserScore.scores[position] = CommonUtils.NullIfEmpty(vh.EtScore.Text);

                if (_isInitialLoad == _mUserScore.scores.Count)
                {
                    if (isNotLastScoreTextField(position))
                    {
                        NotifyItemChanged(_mUserScore.scores.Count - 1, TotalValueChanged);
                    }
                    _mContext.OnScoreChanged(_mUserScore);
                }

                //if (position == _mUserScore.scores.Count - 1)
                //{
                //    vh.TvTotalScore.Text = _mUserScore.scores.Sum(s => s).ToString();
                //    if (_mUserScore.scores[position] != null)
                //    {
                //        _mContext.OnScoreChanged(_mUserScore);
                //    }
                //}
                //else
                //{
                //    if (_isInitialLoad == _mUserScore.scores.Count)
                //    {
                //        NotifyItemChanged(_mUserScore.scores.Count - 1, TotalValueChanged);
                //        _mContext.OnScoreChanged(_mUserScore);
                //    }
                //}
            };
        }