Пример #1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.RecycleViewMessages, parent, false);

            MessagesHolder vh = new MessagesHolder(itemView, OnClick);

            return(vh);
        }
Пример #2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            MessagesHolder vh = holder as MessagesHolder;

            CardView.LayoutParams layoutParams = new CardView.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

            if (mDataMessages[position].UserRef == string.Empty)
            {
                vh.ReciveRead.Visibility = ViewStates.Invisible;
                vh.Direction.Visibility  = ViewStates.Invisible;
            }
            else
            {
                if (mDataMessages[position].DirectIn)
                {
                    layoutParams.SetMargins(0, 0, 50, 0);
                }
                else
                {
                    layoutParams.SetMargins(50, 0, 0, 0);
                }
                vh.CardView.LayoutParameters = layoutParams;

                if (mDataMessages[position].Read)
                {
                    vh.ReciveRead.SetImageResource(Resource.Drawable.ic_action_read);
                }
                else if (mDataMessages[position].Recive)
                {
                    vh.ReciveRead.SetImageResource(Resource.Drawable.ic_action_accept);
                }
                else
                {
                    vh.ReciveRead.Visibility = ViewStates.Invisible;
                }

                vh.Direction.SetImageResource(mDataMessages[position].DirectIn
                    ? Resource.Drawable.ic_action_expand
                    : Resource.Drawable.ic_action_collapse);
            }

            vh.Title.Text = mDataMessages[position].Title;
            vh.Text.Text  = mDataMessages[position].Text;
            vh.Date.Text  = mDataMessages[position].Date.ToShortDateString() + " " + mDataMessages[position].Date.ToShortTimeString();
            vh.User.Text  = mDataMessages[position].UserStr;
        }