public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { try { //Setup your layout here >> Style_HContact_view var itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.Style_LastChatView, parent, false); var vh = new LastChatAdapterViewHolder(itemView, Click, LongClick); return(vh); } catch (Exception exception) { Console.WriteLine(exception); return(null); } }
private void Initialize(LastChatAdapterViewHolder holder, DataConversation item) { try { GlideImageLoader.LoadImage(ActivityContext, item.User.Avatar, holder.ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); string name = DeepSoundTools.GetNameFinal(item.User); if (holder.TxtUsername.Text != name) { holder.TxtUsername.Text = name; } //If message contains Media files switch (item.GetLastMessage.ApiType) { case ApiType.Text: { holder.LastMessagesIcon.Visibility = ViewStates.Gone; holder.TxtLastMessages.Text = item.GetLastMessage.Text.Contains("http") ? Methods.FunString.SubStringCutOf(item.GetLastMessage.Text, 30) : Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.GetLastMessage.Text, 30)) ?? ActivityContext.GetText(Resource.String.Lbl_SendMessage); break; } case ApiType.Image: { holder.LastMessagesIcon.Visibility = ViewStates.Visible; FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.LastMessagesIcon, IonIconsFonts.Images); holder.TxtLastMessages.Text = Application.Context.GetText(Resource.String.Lbl_SendImageFile); break; } } //last seen time holder.TxtTimestamp.Text = Methods.Time.TimeAgo(Convert.ToInt32(item.GetLastMessage.Time), true); //Check read message if (item.GetLastMessage.ToId != UserDetails.UserId && item.GetLastMessage.FromId == UserDetails.UserId) { if (item.GetLastMessage.Seen == 0) { holder.ImageColor.Visibility = ViewStates.Invisible; holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal); holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal); } else { holder.ImageColor.Visibility = ViewStates.Invisible; holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal); holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal); } } else if (item.GetLastMessage.ToId == UserDetails.UserId && item.GetLastMessage.FromId != UserDetails.UserId) { if (item.GetLastMessage.Seen == 0) { holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Bold); holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Bold); if (item.GetCountSeen != 0) { var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(25).EndConfig().BuildRound(item.GetCountSeen.ToString(), Color.ParseColor(AppSettings.MainColor)); holder.ImageColor.SetImageDrawable(drawable); holder.ImageColor.Visibility = ViewStates.Visible; } else { holder.ImageColor.Visibility = ViewStates.Invisible; } } else { holder.ImageColor.Visibility = ViewStates.Invisible; holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal); holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal); } } } catch (Exception e) { Console.WriteLine(e); } }