Esempio n. 1
0
 private void ToggleCheckedIcon(LastChatAdapterViewHolder holder, int position)
 {
     try
     {
         if (SelectedItems.Get(position, false))
         {
             holder.LytImage.Visibility   = ViewStates.Gone;
             holder.LytChecked.Visibility = ViewStates.Visible;
             if (CurrentSelectedIdx == position)
             {
                 ResetCurrentItems();
             }
         }
         else
         {
             holder.LytChecked.Visibility = ViewStates.Gone;
             holder.LytImage.Visibility   = ViewStates.Visible;
             if (CurrentSelectedIdx == position)
             {
                 ResetCurrentItems();
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
        private void Initialize(LastChatAdapterViewHolder holder, GetConversationListObject.DataConversation item)
        {
            try
            {
                GlideImageLoader.LoadImage(ActivityContext, item.User.Avater, holder.ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                string name = QuickDateTools.GetNameFinal(item.User);
                if (holder.TxtUsername.Text != name)
                {
                    holder.TxtUsername.Text = name;
                }

                //If message contains Media files
                switch (item.MessageType)
                {
                case "text":
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Gone;
                    holder.TxtLastMessages.Text        = item.Text.Contains("http")
                            ? Methods.FunString.SubStringCutOf(item.Text, 30)
                            : Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Text, 30))
                                                         ?? ActivityContext.GetText(Resource.String.Lbl_SendMessage);
                    break;
                }

                case "media":
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.LastMessagesIcon, IonIconsFonts.Images);
                    holder.TxtLastMessages.Text = Application.Context.GetText(Resource.String.Lbl_SendImageFile);
                    break;
                }

                case "sticker" when item.Sticker.Contains(".gif"):
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, holder.LastMessagesIcon, FontAwesomeIcon.Gift);
                    holder.TxtLastMessages.Text = Application.Context.GetText(Resource.String.Lbl_SendGifFile);
                    break;
                }

                case "sticker":
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.LastMessagesIcon, IonIconsFonts.Happy);
                    holder.TxtLastMessages.Text = Application.Context.GetText(Resource.String.Lbl_SendStickerFile);
                    break;
                }
                }

                //last seen time
                holder.TxtTimestamp.Text = Methods.Time.ReplaceTime(item.Time);

                //Check read message
                if (item.FromId != null && item.ToId != null && item.ToId != UserDetails.UserId && item.FromId == UserDetails.UserId)
                {
                    if (item.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.FromId != null && item.ToId != null && item.ToId == UserDetails.UserId && item.FromId != UserDetails.UserId)
                {
                    if (item.Seen == 0)
                    {
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Bold);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Bold);

                        if (item.NewMessages != 0)
                        {
                            var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(25).EndConfig().BuildRound(item.NewMessages.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);
            }
        }