예제 #1
0
 // Create new views (invoked by the layout manager)
 public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
 {
     try
     {
         //Setup your layout here >> Last_Message_view
         var itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.Last_Message_view, parent, false);
         var holder   = new LastMessages_AdapterViewHolder(itemView, OnClick, OnLongClick);
         return(holder);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         return(null);
     }
 }
예제 #2
0
        public void Initialize(LastMessages_AdapterViewHolder holder, Classes.Get_Users_List_Object.User item)
        {
            try
            {
                ImageCacheLoader.LoadImage(item.ProfilePicture, holder.ImageAvatar, false, true);

                string name = IMethods.Fun_String.DecodeString(item.Name);
                if (holder.Txt_Username.Text != name)
                {
                    holder.Txt_Username.Text = name;
                }

                //If message contains Media files
                if (item.LastMessage.Media.Contains("image"))
                {
                    if (holder.LastMessagesIcon.Text != IonIcons_Fonts.Images)
                    {
                        holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                        IMethods.Set_TextViewIcon("1", holder.LastMessagesIcon, IonIcons_Fonts.Images);
                        holder.Txt_LastMessages.Text = this.Activity_Context.GetText(Resource.String.Lbl_SendImageFile);
                    }
                }
                else if (item.LastMessage.Media.Contains("video"))
                {
                    if (holder.LastMessagesIcon.Text != IonIcons_Fonts.Videocamera)
                    {
                        holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                        IMethods.Set_TextViewIcon("1", holder.LastMessagesIcon, IonIcons_Fonts.Videocamera);
                        holder.Txt_LastMessages.Text = this.Activity_Context.GetText(Resource.String.Lbl_SendVideoFile);
                    }
                }
                else if (item.LastMessage.Media.Contains("sticker"))
                {
                    if (holder.LastMessagesIcon.Text != IonIcons_Fonts.Happy)
                    {
                        holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                        IMethods.Set_TextViewIcon("1", holder.LastMessagesIcon, IonIcons_Fonts.Happy);
                        holder.Txt_LastMessages.Text = this.Activity_Context.GetText(Resource.String.Lbl_SendStickerFile);
                    }
                }
                else if (item.LastMessage.Media.Contains("sounds"))
                {
                    if (holder.LastMessagesIcon.Text != IonIcons_Fonts.IosMusicalNote)
                    {
                        holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                        IMethods.Set_TextViewIcon("1", holder.LastMessagesIcon, IonIcons_Fonts.IosMusicalNote);
                        holder.Txt_LastMessages.Text = this.Activity_Context.GetText(Resource.String.Lbl_SendAudioFile);
                    }
                }
                else if (item.LastMessage.Media.Contains("file"))
                {
                    if (holder.LastMessagesIcon.Text != IonIcons_Fonts.IosMusicalNote)
                    {
                        holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                        IMethods.Set_TextViewIcon("1", holder.LastMessagesIcon, IonIcons_Fonts.Document);
                        holder.Txt_LastMessages.Text = this.Activity_Context.GetText(Resource.String.Lbl_SendFile);
                    }
                }
                else if (item.LastMessage.Stickers.Contains("gif"))
                {
                    if (holder.LastMessagesIcon.Text != "\uf06b")
                    {
                        holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                        IMethods.Set_TextViewIcon("4", holder.LastMessagesIcon, "\uf06b");
                        holder.Txt_LastMessages.Text = this.Activity_Context.GetText(Resource.String.Lbl_SendGifFile);
                    }
                }
                else
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Gone;

                    if (item.LastMessage.Text.Contains("http"))
                    {
                        holder.Txt_LastMessages.Text = IMethods.Fun_String.SubStringCutOf(item.LastMessage.Text, 30);
                    }
                    else if (item.LastMessage.Text.Contains("{"Key"") || item.LastMessage.Text.Contains("{key:^qu") || item.LastMessage.Text.Contains("{^key:^qu") || item.LastMessage.Text.Contains("{key:"))
                    {
                        if (holder.LastMessagesIcon.Text != IonIcons_Fonts.IosContact)
                        {
                            holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                            IMethods.Set_TextViewIcon("1", holder.LastMessagesIcon, IonIcons_Fonts.IosContact);
                            holder.Txt_LastMessages.Text = this.Activity_Context.GetText(Resource.String.Lbl_SendContactnumber);
                        }
                    }
                    else
                    {
                        holder.Txt_LastMessages.Text = IMethods.Fun_String.DecodeString(IMethods.Fun_String.SubStringCutOf(item.LastMessage.Text, 30));
                    }
                }

                //last seen time
                holder.Txt_timestamp.Text = IMethods.ITime.ReplaceTime(item.LastseenTimeText);


                //Online Or offline
                if (item.Lastseen == "on")
                {
                    holder.Txt_timestamp.Text = this.Activity_Context.GetText(Resource.String.Lbl_Online);
                    holder.ImageLastseen.SetImageResource(Resource.Drawable.Green_Online);

                    if (AppSettings.Show_Online_Oflline_Message)
                    {
                        var data = listOnline.Contains(item.Name);
                        if (data == false)
                        {
                            listOnline.Add(item.Name);

                            Toast toast = Toast.MakeText(Activity_Context, item.Name + " " + this.Activity_Context.GetText(Resource.String.Lbl_Online), ToastLength.Short);
                            toast.SetGravity(GravityFlags.Center, 0, 0);
                            toast.Show();
                        }
                    }
                }
                else
                {
                    holder.ImageLastseen.SetImageResource(Resource.Drawable.Grey_Offline);
                }

                //Check read message
                if (item.LastMessage.ToId != UserDetails.User_id && item.LastMessage.FromId == UserDetails.User_id)
                {
                    if (item.LastMessage.Seen == "0" || item.LastMessage.Seen == "")
                    {
                        holder.checkicon.Visibility = ViewStates.Invisible;
                        holder.Txt_Username.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.Txt_LastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                    }
                    else
                    {
                        holder.checkicon.Visibility = ViewStates.Visible;
                        holder.Txt_Username.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.Txt_LastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        IMethods.Set_TextViewIcon("1", holder.checkicon, IonIcons_Fonts.AndroidDoneAll);
                    }
                }
                else
                {
                    if (item.LastMessage.Seen == "0" || item.LastMessage.Seen == "")
                    {
                        holder.checkicon.Visibility = ViewStates.Visible;
                        holder.Txt_Username.SetTypeface(Typeface.Default, TypefaceStyle.Bold);
                        holder.Txt_LastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Bold);
                        IMethods.Set_TextViewIcon("1", holder.checkicon, IonIcons_Fonts.ChatbubbleWorking);
                    }
                    else
                    {
                        holder.checkicon.Visibility = ViewStates.Invisible;
                        holder.Txt_Username.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.Txt_LastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }