Ejemplo n.º 1
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is ManageSessionsAdapterViewHolder holder)
                {
                    var item = SessionsList[position];
                    if (item != null)
                    {
                        holder.Platform.Text = item.Os;
                        holder.Browser.Text  = ActivityContext.GetText(Resource.String.Lbl_Browser) + " : " + item.Platform;
                        holder.Seen.Text     = ActivityContext.GetText(Resource.String.Lbl_Last_seen) + " : " + item.Time;

                        if (item.Platform != null)
                        {
                            var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(35).EndConfig().BuildRound(item.Platform.Substring(0, 1), Color.ParseColor(AppSettings.MainColor));
                            holder.Image.SetImageDrawable(drawable);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 2
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is ManageSessionsAdapterViewHolder holder)
                {
                    var item = SessionsList[position];
                    if (item != null)
                    {
                        holder.Platform.Text = item.Platform;
                        holder.Browser.Text  = ActivityContext.GetText(Resource.String.Lbl_Browser) + " : " + item.Browser;
                        holder.Seen.Text     = ActivityContext.GetText(Resource.String.Lbl_Last_seen) + " : " + item.Time;

                        if (!string.IsNullOrEmpty(item.IpAddress))
                        {
                            holder.Address.Text = ActivityContext.GetText(Resource.String.Lbl_IpAddress) + " : " + item.IpAddress;
                        }
                        else
                        {
                            holder.Address.Visibility = ViewStates.Gone;
                        }

                        if (item.Browser != null)
                        {
                            var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(35).EndConfig().BuildRound(item.Browser.Substring(0, 1), Color.ParseColor(AppSettings.MainColor));
                            holder.Image.SetImageDrawable(drawable);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is MoreSectionAdapterViewHolder holder)
                {
                    if (AppSettings.FlowDirectionRightToLeft)
                    {
                        holder.LinearLayoutImage.LayoutDirection = LayoutDirection.Rtl;
                        holder.LinearLayoutMain.LayoutDirection  = LayoutDirection.Rtl;
                        holder.Name.LayoutDirection = LayoutDirection.Rtl;
                    }

                    var item = SectionList[position];
                    if (item != null)
                    {
                        FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.Icon, item.Icon);
                        holder.Icon.SetTextColor(item.IconColor);
                        holder.Name.Text = item.SectionName;

                        if (item.BadgeCount != 0)
                        {
                            var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(30).EndConfig().BuildRound(item.BadgeCount.ToString(), Color.ParseColor(AppSettings.MainColor));
                            holder.Badge.SetImageDrawable(drawable);
                        }

                        holder.Badge.Visibility = item.Badgevisibilty ? ViewStates.Visible : ViewStates.Invisible;
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        private void Initialize(NotificationsAdapterViewHolder holder, Notification notify)
        {
            try
            {
                if (notify.Type == "memory")
                {
                    Glide.With(ActivityContext).Load(Resource.Mipmap.icon).Apply(new RequestOptions().CircleCrop()).Into(holder.ImageUser);
                    holder.UserNameNotfy.Text = AppSettings.ApplicationName;
                }
                else
                {
                    GlideImageLoader.LoadImage(ActivityContext, notify.Notifier?.Avatar, holder.ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                    holder.UserNameNotfy.Text = WoWonderTools.GetNameFinal(notify.Notifier);
                }

                AddIconFonts(holder, notify.Type, notify.Icon);

                var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(30).EndConfig().BuildRound("", Color.ParseColor(GetColorFonts(notify.Type, notify.Icon)));
                holder.Image.SetImageDrawable(drawable);

                if (notify.Type == "share_post" || notify.Type == "shared_your_post")
                {
                    holder.TextNotfy.Text = ActivityContext.GetText(Resource.String.Lbl_sharedYourPost);
                }
                else
                {
                    holder.TextNotfy.Text = notify.TypeText;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                switch (viewHolder)
                {
                case PlacesAdapterViewHolder holder:
                {
                    var item = PlacesList[position];
                    if (item != null)
                    {
                        var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(35).EndConfig().BuildRound(item.Name.Substring(0, 1), Color.ParseColor(AppSettings.MainColor));
                        holder.Image.SetImageDrawable(drawable);

                        holder.Title.Text       = item.Name;
                        holder.Description.Text = item.Address;
                    }

                    break;
                }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
        private void Initialize(NotificationsAdapterViewHolder holder, NotificationObject notify)
        {
            try
            {
                switch (notify.Type)
                {
                case "memory":
                    Glide.With(ActivityContext).Load(Resource.Mipmap.icon).Apply(new RequestOptions().CircleCrop()).Into(holder.ImageUser);
                    holder.UserNameNotfy.Text = AppSettings.ApplicationName;
                    break;

                default:
                {
                    GlideImageLoader.LoadImage(ActivityContext, notify.Notifier?.Avatar, holder.ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                    var name = WoWonderTools.GetNameFinal(notify.Notifier);

                    string tempString = notify.Type == "share_post" || notify.Type == "shared_your_post"
                            ? name + " " + ActivityContext.GetText(Resource.String.Lbl_sharedYourPost)
                            : name + " " + notify.TypeText;
                    try
                    {
                        SpannableString spanString = new SpannableString(tempString);
                        spanString.SetSpan(new StyleSpan(TypefaceStyle.Bold), 0, name.Length, 0);

                        holder.UserNameNotfy.SetText(spanString, TextView.BufferType.Spannable);
                    }
                    catch
                    {
                        holder.UserNameNotfy.Text = tempString;
                    }

                    break;
                }
                }

                holder.TextNotfy.Text = Methods.Time.TimeAgo(Convert.ToInt32(notify.Time), false);

                AddIconFonts(holder, notify.Type, notify.Icon);

                var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(30).EndConfig().BuildRound("", Color.ParseColor(GetColorFonts(notify.Type, notify.Icon)));
                holder.Image.SetImageDrawable(drawable);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Ejemplo n.º 7
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is ColorPickerAdapterViewHolder holder)
                {
                    var item = MColorPickerList[position];
                    if (item != null)
                    {//wael
                        TextDrawable drawable;

                        if (StyleShapeColor)
                        {
                            drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(30)
                                       .EndConfig().BuildRound("", Color.ParseColor(item.ColorFirst));
                            holder.ColorPickerView.SetImageDrawable(drawable);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(item.ColorSecond))
                            {
                                var   width  = 150;
                                var   height = 150;
                                int[] color  = { Color.ParseColor(item.ColorFirst), Color.ParseColor(item.ColorSecond) };

                                var(gradient, bitmap) = ColorUtil.GetGradientDrawable(ActivityContext, color, width, height, false, true);
                                holder.ColorPickerView.SetImageDrawable(gradient);
                            }
                            else
                            {
                                drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(30)
                                           .EndConfig().BuildRoundRect("", Color.ParseColor(item.ColorFirst), 10);
                                holder.ColorPickerView.SetImageDrawable(drawable);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 8
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is PlacesAdapterViewHolder holder)
                {
                    var item = PlacesList[position];
                    if (item != null)
                    {
                        var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(36).EndConfig().BuildRound(item.Name.Substring(0, 2), Color.ParseColor(AppSettings.MainColor));
                        holder.Image.SetImageDrawable(drawable);

                        holder.Title.Text       = item.Name;
                        holder.Description.Text = item.Address;
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 9
0
        public void Initialize(LastChatAdapterViewHolder holder, GetChatsObject.Data item)
        {
            try
            {
                GlideImageLoader.LoadImage(ActivityContext, item.User.Avatar, holder.ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                string name = Methods.FunString.DecodeString(item.User.Name);
                if (holder.TxtUsername.Text != name)
                {
                    holder.TxtUsername.Text = name;
                }

                string lastMessage = Methods.FunString.DecodeString(item.GetLastMessage.Text);
                if (holder.TxtLastMessages.Text != lastMessage)
                {
                    holder.TxtLastMessages.Text = lastMessage;
                }

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

                if (Convert.ToInt32(item.GetCountSeen) <= 0)
                {
                    holder.ImageColor.Visibility = ViewStates.Invisible;
                }
                else
                {
                    var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(25).EndConfig().BuildRound(item.GetCountSeen, Color.ParseColor(AppSettings.MainColor));
                    holder.ImageColor.SetImageDrawable(drawable);
                    holder.ImageColor.Visibility = ViewStates.Visible;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                switch (viewHolder)
                {
                case MoreSectionAdapterViewHolderTheme2 holder:
                {
                    switch (AppSettings.FlowDirectionRightToLeft)
                    {
                    case true:
                        holder.LinearLayoutImage.LayoutDirection = LayoutDirection.Rtl;
                        holder.LinearLayoutMain.LayoutDirection  = LayoutDirection.Rtl;
                        holder.Name.LayoutDirection = LayoutDirection.Rtl;
                        break;
                    }


                    var item = SectionList[position];
                    if (item != null)
                    {
                        //FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.Icon, item.Icon);
                        //holder.Icon.SetTextColor(item.IconColor);
                        holder.Name.Text = item.SectionName;
                        holder.BackIcon.Background.SetTint(item.BackIcon);

                        if (item.IconAsImage != 0)
                        {
                            holder.Icon.SetImageResource(item.IconAsImage);
                        }

                        if (item.BadgeCount != 0 && item.Id == 2 && item.Badgevisibilty)
                        {
                            ShowOrHideBadgeViewIcon(holder, item.BadgeCount, true);
                            holder.Name.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        }
                        else
                        {
                            switch (item.Id)
                            {
                            case 2:
                                ShowOrHideBadgeViewIcon(holder);
                                break;
                            }
                        }
                    }

                    break;
                }

                case MoreSectionAdapterViewHolder holder2:
                {
                    switch (AppSettings.FlowDirectionRightToLeft)
                    {
                    case true:
                        holder2.LinearLayoutImage.LayoutDirection = LayoutDirection.Rtl;
                        holder2.LinearLayoutMain.LayoutDirection  = LayoutDirection.Rtl;
                        holder2.Name.LayoutDirection = LayoutDirection.Rtl;
                        break;
                    }

                    var item = SectionList[position];
                    if (item != null)
                    {
                        FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder2.Icon, item.Icon);
                        holder2.Icon.SetTextColor(item.IconColor);
                        holder2.Name.Text = item.SectionName;

                        if (item.BadgeCount != 0 && item.Id == 2)
                        {
                            var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(30).EndConfig().BuildRound(item.BadgeCount.ToString(), Color.ParseColor(AppSettings.MainColor));
                            holder2.Badge.SetImageDrawable(drawable);
                        }

                        holder2.Badge.Visibility = item.Badgevisibilty ? ViewStates.Visible : ViewStates.Invisible;
                    }

                    break;
                }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is Holders.LastMessagesViewHolder holder)
                {
                    var item = ChatList[position];
                    if (item != null)
                    {
                        var image = item.Avatar;
                        if (!string.IsNullOrEmpty(image))
                        {
                            var avatarSplit    = image.Split('/').Last();
                            var getImageAvatar = Methods.MultiMedia.GetMediaFrom_Disk(Methods.Path.FolderDiskImage, avatarSplit);
                            if (getImageAvatar != "File Dont Exists")
                            {
                                var file = Uri.FromFile(new File(getImageAvatar));
                                Glide.With(ActivityContext).Load(file.Path).Apply(Options).Into(holder.ImageAvatar);
                            }
                            else
                            {
                                Methods.MultiMedia.DownloadMediaTo_DiskAsync(Methods.Path.FolderDiskImage, image);
                                GlideImageLoader.LoadImage(ActivityContext, image, holder.ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                            }
                        }

                        //last seen time
                        holder.TxtTimestamp.Text = Methods.Time.TimeAgo(int.Parse(item.ChatTime ?? item.Time), true);

                        if (item.LastMessage.LastMessageClass != null)
                        {
                            item.LastMessage.LastMessageClass.Stickers = item.LastMessage.LastMessageClass.Stickers?.Replace(".mp4", ".gif") ?? "";

                            //If message contains Media files
                            if (item.LastMessage.LastMessageClass?.Media != null && item.LastMessage.LastMessageClass.Media.Contains("image"))
                            {
                                holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                                Glide.With(ActivityContext).Load(Resource.Drawable.ic_image_vector).Into(holder.LastMessagesIcon);
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendImageFile);
                            }
                            else if (item.LastMessage.LastMessageClass?.Media != null && item.LastMessage.LastMessageClass.Media.Contains("video"))
                            {
                                holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                                Glide.With(ActivityContext).Load(Resource.Drawable.ic_video_player_vector).Into(holder.LastMessagesIcon);
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendVideoFile);
                            }
                            else if (item.LastMessage.LastMessageClass?.Media != null && item.LastMessage.LastMessageClass.Media.Contains("sticker"))
                            {
                                holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                                Glide.With(ActivityContext).Load(Resource.Drawable.ic_sticker_vector).Into(holder.LastMessagesIcon);
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendStickerFile);
                            }
                            else if (item.LastMessage.LastMessageClass?.Media != null && item.LastMessage.LastMessageClass.Media.Contains("sounds"))
                            {
                                holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                                Glide.With(ActivityContext).Load(Resource.Drawable.ic_radios_vector).Into(holder.LastMessagesIcon);
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendAudioFile);
                            }
                            else if (item.LastMessage.LastMessageClass?.Media != null && item.LastMessage.LastMessageClass.Media.Contains("file"))
                            {
                                holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                                Glide.With(ActivityContext).Load(Resource.Drawable.ic_document_vector).Into(holder.LastMessagesIcon);
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendFile);
                            }
                            else if (item.LastMessage.LastMessageClass?.Stickers != null && item.LastMessage.LastMessageClass.Stickers.Contains(".gif"))
                            {
                                holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                                Glide.With(ActivityContext).Load(Resource.Drawable.ic_gif_vector).Into(holder.LastMessagesIcon);
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendGifFile);
                            }
                            else if (!string.IsNullOrEmpty(item.LastMessage.LastMessageClass.ProductId) && item.LastMessage.LastMessageClass.ProductId != "0")
                            {
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendProductFile);
                            }
                            else if (!string.IsNullOrEmpty(item.LastMessage.LastMessageClass.Lat) && !string.IsNullOrEmpty(item.LastMessage.LastMessageClass.Lng) && item.LastMessage.LastMessageClass.Lat != "0" && item.LastMessage.LastMessageClass.Lng != "0")
                            {
                                holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                                Glide.With(ActivityContext).Load(Resource.Drawable.icon_search_location_vector).Into(holder.LastMessagesIcon);
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendLocationFile);
                            }
                            else
                            {
                                // holder.LastMessagesIcon.Visibility = ViewStates.Gone;

                                //if (!string.IsNullOrEmpty(item.LastMessage.LastMessageClass.Text) && item.LastMessage.LastMessageClass.Text.Contains("http"))
                                //{
                                //    holder.TxtLastMessages.Text = Methods.FunString.SubStringCutOf(item.LastMessage.LastMessageClass.Text, 30);
                                //}
                                //else
                                if (!string.IsNullOrEmpty(item.LastMessage.LastMessageClass.Text) && item.LastMessage.LastMessageClass.Text.Contains("{&quot;Key&quot;") || item.LastMessage.LastMessageClass.Text.Contains("{key:^qu") || item.LastMessage.LastMessageClass.Text.Contains("{^key:^qu") || item.LastMessage.LastMessageClass.Text.Contains("{key:"))
                                {
                                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendContactnumber);
                                }
                                else if (!string.IsNullOrEmpty(item.LastMessage.LastMessageClass.Text))
                                {
                                    holder.TxtLastMessages.Text = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.LastMessage.LastMessageClass.Text, 30));
                                }
                            }

                            //Check read message
                            if (item.LastMessage.LastMessageClass.FromId != null && (item.LastMessage.LastMessageClass.ToId != null && (item.LastMessage.LastMessageClass.ToId != UserDetails.UserId && item.LastMessage.LastMessageClass.FromId == UserDetails.UserId)))
                            {
                                if (item.LastMessage.LastMessageClass.Seen == "0")
                                {
                                    holder.IconCheckCountMessages.Visibility = ViewStates.Invisible;
                                    holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                    holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                }
                                else
                                {
                                    holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                                    holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                    holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                    Glide.With(ActivityContext).Load(Resource.Drawable.ic_tick_vector).Into(holder.IconCheckCountMessages);
                                }
                            }
                            else if (item.LastMessage.LastMessageClass.FromId != null && (item.LastMessage.LastMessageClass.ToId != null && (item.LastMessage.LastMessageClass.ToId == UserDetails.UserId && item.LastMessage.LastMessageClass.FromId != UserDetails.UserId)))
                            {
                                if (item.LastMessage.LastMessageClass.Seen == "0")
                                {
                                    holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Bold);
                                    holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Bold);

                                    holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                                    if (item.ChatType == "user")
                                    {
                                        if (!string.IsNullOrEmpty(item.MessageCount))
                                        {
                                            var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(25).EndConfig().BuildRound(item.MessageCount, Color.ParseColor(AppSettings.MainColor));
                                            holder.IconCheckCountMessages.SetImageDrawable(drawable);
                                            holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                                        }
                                        else
                                        {
                                            var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(25).EndConfig().BuildRound("N", Color.ParseColor(AppSettings.MainColor));
                                            holder.IconCheckCountMessages.SetImageDrawable(drawable);
                                            holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                                        }
                                    }
                                }
                                else
                                {
                                    holder.IconCheckCountMessages.Visibility = ViewStates.Invisible;
                                    holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                    holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                }
                            }
                        }

                        switch (item.ChatType)
                        {
                        case "user":
                            InitializeUser(holder, item);
                            break;

                        case "page":
                            InitializePage(holder, item);
                            break;

                        case "group":
                            InitializeGroup(holder, item);
                            break;
                        }

                        holder.RelativeLayoutMain.Visibility = item.Swiped ? ViewStates.Gone : ViewStates.Visible;
                        holder.MainSwipe.Visibility          = item.Swiped ? ViewStates.Visible : ViewStates.Gone;
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        //Get General Data Using Api >> notifications , pro_users , promoted_pages , trending_hashTag
        public async Task <(string, string, string, string)> LoadGeneralData(bool seenNotifications, string offset = "")
        {
            try
            {
                if (MainScrollEvent.IsLoading)
                {
                    return("", "", "", "");
                }

                if (Methods.CheckConnectivity())
                {
                    MainScrollEvent.IsLoading = true;

                    var countNotificationsList = MAdapter.NotificationsList?.Count ?? 0;
                    var countPromotedPagesList = GlobalContext.ProPagesAdapter?.MProPagesList.Count ?? 0;

                    (int apiStatus, var respond) = await RequestsAsync.Global.Get_General_Data(seenNotifications, TabbedMainActivity.OnlineUsers, UserDetails.DeviceId, offset);

                    if (apiStatus == 200)
                    {
                        if (respond is GetGeneralDataObject result)
                        {
                            Activity.RunOnUiThread(() =>
                            {
                                try
                                {
                                    // Notifications
                                    var respondList = result.Notifications.Count;
                                    if (respondList > 0)
                                    {
                                        if (countNotificationsList > 0)
                                        {
                                            var listNew = result.Notifications?.Where(c => !MAdapter.NotificationsList.Select(fc => fc.Id).Contains(c.Id)).ToList();
                                            if (listNew.Count > 0)
                                            {
                                                foreach (var notification in listNew)
                                                {
                                                    MAdapter.NotificationsList.Insert(0, notification);
                                                }

                                                MAdapter.NotifyItemRangeInserted(countNotificationsList - 1, MAdapter.NotificationsList.Count - countNotificationsList);
                                            }
                                        }
                                        else
                                        {
                                            MAdapter.NotificationsList = new ObservableCollection <Notification>(result.Notifications);
                                            MAdapter.NotifyDataSetChanged();
                                        }
                                    }
                                    else
                                    {
                                        if (MAdapter.NotificationsList.Count > 10 && !MRecycler.CanScrollVertically(1))
                                        {
                                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreNotifications), ToastLength.Short)?.Show();
                                        }
                                    }

                                    if (AppSettings.ShowTrendingPage && GlobalContext.TrendingTab != null)
                                    {
                                        // Friend Requests
                                        if (result.FriendRequests.Count > 0)
                                        {
                                            GlobalContext.FriendRequestsList = new ObservableCollection <UserDataObject>(result.FriendRequests);

                                            GlobalContext.TrendingTab.LayoutFriendRequest.Visibility = ViewStates.Visible;
                                            try
                                            {
                                                for (var i = 0; i < 4; i++)
                                                {
                                                    switch (i)
                                                    {
                                                    case 0:
                                                        if (GlobalContext.FriendRequestsList.Count > 0)
                                                        {
                                                            GlideImageLoader.LoadImage(Activity, GlobalContext.FriendRequestsList[i]?.Avatar, GlobalContext.TrendingTab.FriendRequestImage3, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                                                        }
                                                        break;

                                                    case 1:
                                                        if (GlobalContext.FriendRequestsList.Count > 1)
                                                        {
                                                            GlideImageLoader.LoadImage(Activity, GlobalContext.FriendRequestsList[i]?.Avatar, GlobalContext.TrendingTab.FriendRequestImage2, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                                                        }
                                                        break;

                                                    case 2:
                                                        if (GlobalContext.FriendRequestsList.Count > 2)
                                                        {
                                                            GlideImageLoader.LoadImage(Activity, GlobalContext.FriendRequestsList[i]?.Avatar, GlobalContext.TrendingTab.FriendRequestImage1, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                                                        }
                                                        break;
                                                    }
                                                }

                                                if (!string.IsNullOrEmpty(result.NewFriendRequestsCount) && result.NewFriendRequestsCount != "0")
                                                {
                                                    var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(30).EndConfig().BuildRound(result.NewFriendRequestsCount, Color.ParseColor(AppSettings.MainColor));
                                                    GlobalContext.TrendingTab.FriendRequestCount.SetImageDrawable(drawable);
                                                    GlobalContext.TrendingTab.FriendRequestCount.Visibility = ViewStates.Visible;
                                                }
                                                else
                                                {
                                                    GlobalContext.TrendingTab.FriendRequestCount.Visibility = ViewStates.Gone;
                                                }
                                            }
                                            catch (Exception e)
                                            {
                                                Methods.DisplayReportResultTrack(e);
                                            }
                                        }
                                        else if (GlobalContext.TrendingTab != null)
                                        {
                                            GlobalContext.TrendingTab.LayoutFriendRequest.Visibility = ViewStates.Gone;
                                        }

                                        if (GlobalContext.TrendingTab != null && AppSettings.ShowProUsersMembers)
                                        {
                                            var isPro = ListUtils.MyProfileList?.FirstOrDefault()?.IsPro ?? "0";
                                            if (isPro == "0" && ListUtils.SettingsSiteList?.Pro == "1" && AppSettings.ShowGoPro)
                                            {
                                                var dataOwner = GlobalContext.ProUsersAdapter.MProUsersList.FirstOrDefault(a => a.Type == "Your");
                                                if (dataOwner == null)
                                                {
                                                    GlobalContext.ProUsersAdapter.MProUsersList.Insert(0, new UserDataObject
                                                    {
                                                        Avatar   = UserDetails.Avatar,
                                                        Type     = "Your",
                                                        Username = Context.GetText(Resource.String.Lbl_AddMe),
                                                    });

                                                    GlobalContext.ProUsersAdapter.NotifyDataSetChanged();

                                                    if (GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility != ViewStates.Visible)
                                                    {
                                                        GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility = ViewStates.Visible;
                                                    }
                                                }
                                            }

                                            // Pro Users
                                            var countProUsersList   = GlobalContext.ProUsersAdapter.MProUsersList.Count;
                                            var respondListProUsers = result.ProUsers.Count;
                                            if (respondListProUsers > 0)
                                            {
                                                foreach (var item in from item in result.ProUsers let check = GlobalContext.ProUsersAdapter.MProUsersList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item)
                                                {
                                                    GlobalContext.ProUsersAdapter.MProUsersList.Add(item);
                                                }

                                                if (countProUsersList > 0)
                                                {
                                                    GlobalContext.ProUsersAdapter.NotifyItemRangeInserted(countProUsersList - 1, GlobalContext.ProUsersAdapter.MProUsersList.Count - countProUsersList);
                                                }
                                                else
                                                {
                                                    GlobalContext.ProUsersAdapter.NotifyDataSetChanged();
                                                }

                                                //Scroll Down >>
                                                GlobalContext.TrendingTab.ProUserRecyclerView.ScrollToPosition(0);

                                                if (GlobalContext.ProUsersAdapter.MProUsersList.Count > 0 && GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility != ViewStates.Visible)
                                                {
                                                    GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility = ViewStates.Visible;
                                                }
                                            }
                                            else
                                            {
                                                if (GlobalContext.ProUsersAdapter.MProUsersList.Count == 0 && GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility != ViewStates.Gone)
                                                {
                                                    GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility = ViewStates.Gone;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (GlobalContext.TrendingTab != null && GlobalContext.ProUsersAdapter.MProUsersList.Count == 0 && GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility != ViewStates.Gone)
                                            {
                                                GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility = ViewStates.Gone;
                                            }
                                        }

                                        if (GlobalContext.TrendingTab != null && AppSettings.ShowPromotedPages)
                                        {
                                            // Pro Pages
                                            var respondListPromotedPages = result.PromotedPages.Count;
                                            if (respondListPromotedPages > 0)
                                            {
                                                if (countPromotedPagesList > 0)
                                                {
                                                    foreach (var item in from item in result.PromotedPages let check = GlobalContext.ProPagesAdapter.MProPagesList.FirstOrDefault(a => a.PageId == item.PageId) where check == null select item)
                                                    {
                                                        GlobalContext.ProPagesAdapter.MProPagesList.Add(item);
                                                    }

                                                    GlobalContext.ProPagesAdapter.NotifyItemRangeInserted(countPromotedPagesList - 1, GlobalContext.ProPagesAdapter.MProPagesList.Count - countPromotedPagesList);
                                                }
                                                else
                                                {
                                                    GlobalContext.ProPagesAdapter.MProPagesList = new ObservableCollection <PageClass>(result.PromotedPages);
                                                    GlobalContext.ProPagesAdapter.NotifyDataSetChanged();
                                                }

                                                GlobalContext.TrendingTab.LayoutSuggestionPromotedPage.Visibility = ViewStates.Visible;
                                            }
                                            else
                                            {
                                                GlobalContext.TrendingTab.LayoutSuggestionPromotedPage.Visibility = ViewStates.Gone;
                                            }
                                        }
                                        else
                                        {
                                            GlobalContext.TrendingTab.LayoutSuggestionPromotedPage.Visibility = ViewStates.Gone;
                                        }
                                    }

                                    if (AppSettings.ShowTrendingHashTags)
                                    {
                                        if (result.TrendingHashtag.Count > 0)
                                        {
                                            GlobalContext.HashTagUserAdapter.MHashtagList = new ObservableCollection <TrendingHashtag>(result.TrendingHashtag);
                                        }
                                    }

                                    MainScrollEvent.IsLoading = false;
                                    ShowEmptyPage();
                                }
                                catch (Exception e)
                                {
                                    Methods.DisplayReportResultTrack(e);
                                }
                            });
                            return(result.NewNotificationsCount, result.NewFriendRequestsCount, result.CountNewMessages, result.Announcement?.AnnouncementClass?.TextDecode);
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(Activity, respond);
                    }

                    Activity.RunOnUiThread(ShowEmptyPage);
                    MainScrollEvent.IsLoading = false;

                    return("", "", "", "");
                }
                else
                {
                    Inflated = EmptyStateLayout.Inflate();
                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                    if (!x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click += null !;
                        x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                    }

                    Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                }
            }
            catch (Exception e)
            {
                MainScrollEvent.IsLoading = false;
                Methods.DisplayReportResultTrack(e);
            }
            MainScrollEvent.IsLoading = false;
            return("", "", "", "");
        }
Ejemplo n.º 14
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);
            }
        }