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

            UserViewHolder vh = new UserViewHolder(itemView, OnClick, OnClick);

            return(vh);
        }
Example #2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            vh = holder as UserViewHolder;
            if (user.users[position].Photo != null)
            {
                byte[] imageAsBytes = Android.Util.Base64.Decode(user.users[position].Photo, Android.Util.Base64Flags.Default);
                activity.RunOnUiThread(() =>
                {
                    Bitmap bMap = BitmapFactory.DecodeByteArray(imageAsBytes, 0, imageAsBytes.Length);
                    var d       = new CircleDrawable(bMap);
                    vh.Image.SetBackgroundDrawable(d);
                });
            }
            else
            {
                vh.Image.SetBackgroundResource(Resource.Drawable.avatar_upload);
                vh.Image.SetImageResource(Resource.Drawable.circle);
            }

            if (vh.Phone != null)
            {
                vh.Phone.Text = user.users[position].Phone;
            }

            //teste for online user
            if (user.users[position].isGroup)
            {
                vh.IconVideo.Visibility = ViewStates.Gone;
                vh.IconPhone.Visibility = ViewStates.Gone;
                //vh.IconStatusOn.Visibility = ViewStates.Gone;
            }
            else
            {
                vh.IconVideo.Visibility = ViewStates.Visible;
                vh.IconPhone.Visibility = ViewStates.Visible;
            }

            //teste for online user
            if (user.users[position].username != null)
            {
                vh.Name.Text = user.users[position].username.Replace("_", " ");
                if (vh.Name.Text.Contains('@'))
                {
                    vh.Name.Text = vh.Name.Text.Split('@')[0];
                }
            }
            else if (user.users[position].Nick != null)
            {
                vh.Name.Text = user.users[position].Nick.Replace("_", " ");
                if (vh.Name.Text.Contains('@'))
                {
                    vh.Name.Text = vh.Name.Text.Split('@')[0];
                }
            }

            //is msg no ready
            if (user.users[position].username != null || user.users[position].Nick != null)
            {
                int msgCount = appPreferences.getValueKeyMSGCount(LegionUtils.GetUserNameClear(user.users[position].username));
                if (msgCount > 0)
                {
                    vh.fragmentMsg.Visibility = ViewStates.Visible;
                    vh.countMsg.Text          = msgCount.ToString();
                }
                else
                {
                    vh.fragmentMsg.Visibility = ViewStates.Gone;
                }
                vh.fragmentMsg.RefreshDrawableState();
            }

            vh.IconVideo.RefreshDrawableState();
            vh.IconPhone.RefreshDrawableState();
            vh.Name.RefreshDrawableState();
            vh.fragmentMsg.RefreshDrawableState();
            vh.Image.RefreshDrawableState();
        }