Beispiel #1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View itemView = LayoutInflater.From(parent.Context).
                            Inflate(Resource.Layout.ChatCardView, parent, false);
            ChateCardViewHolder vh = new ChateCardViewHolder(itemView);

            return(vh);
        }
Beispiel #2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            ChateCardViewHolder vh = holder as ChateCardViewHolder;
            String imgName         = "";

            vh.imgFPhoto.Click  += (s, e) => ImgPhoto_Click(imgName);
            vh.imgMyPhoto.Click += (s, e) => ImgPhoto_Click(imgName);

            if (msgs[position].isMe)
            {
                if (msgs[position].isImage)
                {
                    imgName = msgs[position].imgName;
                    Bitmap   bit = LegionUtils.BitmapByName(msgs[position].imgName);
                    Drawable dr  = new BitmapDrawable(bit);
                    vh.imgMyPhoto.SetBackgroundDrawable(dr);
                    vh.imgMyPhoto.Visibility   = ViewStates.Visible;
                    vh.txvMyMessage.Visibility = ViewStates.Gone;
                }
                else
                {
                    vh.txvMyMessage.Text       = msgs[position].Msg;
                    vh.txvMyMessage.Visibility = ViewStates.Visible;
                }

                vh.cardMessage.Visibility          = ViewStates.Gone;
                vh.cardFreandMessage.Visibility    = ViewStates.Visible;
                vh.txvFriendMessageHour.Visibility = ViewStates.Gone;
                vh.txvMyMessagehour.Text           = msgs[position].Msgdate.ToString("t");
                vh.txvMyMessagehour.Visibility     = ViewStates.Visible;
                vh.imgFPhoto.Visibility            = ViewStates.Gone;
            }
            else
            {
                if (msgs[position].isImage)
                {
                    imgName = msgs[position].imgName;
                    Bitmap   bit = LegionUtils.BitmapByName(msgs[position].imgName);
                    Drawable dr  = new BitmapDrawable(bit);
                    vh.imgFPhoto.SetBackgroundDrawable(dr);
                    vh.imgFPhoto.Visibility        = ViewStates.Visible;
                    vh.txvFriendMessage.Visibility = ViewStates.Gone;
                }
                else
                {
                    vh.txvFriendMessage.Text       = msgs[position].Msg;
                    vh.txvFriendMessage.Visibility = ViewStates.Visible;
                }

                vh.cardMessage.Visibility          = ViewStates.Visible;
                vh.cardFreandMessage.Visibility    = ViewStates.Gone;
                vh.txvMyMessagehour.Visibility     = ViewStates.Gone;
                vh.txvFriendMessageHour.Text       = msgs[position].Msgdate.ToString("t");
                vh.txvFriendMessageHour.Visibility = ViewStates.Visible;
                vh.imgMyPhoto.Visibility           = ViewStates.Gone;
                vh.txvMyMessage.Visibility         = ViewStates.Gone;
            }

            vh.txvFriendMessage.RefreshDrawableState();
            vh.cardFreandMessage.RefreshDrawableState();
            vh.txvMyMessage.RefreshDrawableState();
            vh.cardMessage.RefreshDrawableState();
            vh.txvFriendMessageHour.RefreshDrawableState();
            vh.txvMyMessagehour.RefreshDrawableState();
            vh.imgMyPhoto.RefreshDrawableState();
            vh.imgFPhoto.RefreshDrawableState();
        }