Beispiel #1
0
        public void EventClickNotification(Activity activity, NotificationObject item)
        {
            try
            {
                switch (item.Type)
                {
                case "following":
                case "visited_profile":
                case "accepted_request":
                    WoWonderTools.OpenProfile(Activity, item.Notifier.UserId, item.Notifier);
                    break;

                case "liked_page":
                case "invited_page":
                case "accepted_invite":
                {
                    var intent = new Intent(Activity, typeof(PageProfileActivity));
                    //intent.PutExtra("PageObject", JsonConvert.SerializeObject(item));
                    intent.PutExtra("PageId", item.PageId);
                    activity.StartActivity(intent);
                    break;
                }

                case "joined_group":
                case "accepted_join_request":
                case "added_you_to_group":
                {
                    var intent = new Intent(activity, typeof(GroupProfileActivity));
                    //intent.PutExtra("GroupObject", JsonConvert.SerializeObject(item));
                    intent.PutExtra("GroupId", item.GroupId);
                    activity.StartActivity(intent);
                    break;
                }

                case "comment":
                case "wondered_post":
                case "wondered_comment":
                case "reaction":
                case "wondered_reply_comment":
                case "comment_mention":
                case "comment_reply_mention":
                case "liked_post":
                case "liked_comment":
                case "liked_reply_comment":
                case "post_mention":
                case "share_post":
                case "shared_your_post":
                case "comment_reply":
                case "also_replied":
                case "profile_wall_post":
                {
                    var intent = new Intent(activity, typeof(ViewFullPostActivity));
                    intent.PutExtra("Id", item.PostId);
                    // intent.PutExtra("DataItem", JsonConvert.SerializeObject(item));
                    activity.StartActivity(intent);
                    break;
                }

                case "going_event":
                {
                    var intent = new Intent(activity, typeof(EventViewActivity));
                    intent.PutExtra("EventId", item.EventId);
                    if (item.Event != null)
                    {
                        intent.PutExtra("EventView", JsonConvert.SerializeObject(item.Event));
                    }
                    activity.StartActivity(intent);
                    break;
                }

                case "viewed_story":
                {
                    //"url": "https:\/\/demo.wowonder.com\/timeline&u=Matan&story=true&story_id=1946",
                    //var id = item.Url.Split("/").Last().Split("&story_id=").Last();

                    StoryDataObject dataMyStory = GlobalContext?.NewsFeedTab?.PostFeedAdapter?.HolderStory?.StoryAdapter?.StoryList?.FirstOrDefault(o => o.UserId == UserDetails.UserId);
                    if (dataMyStory != null)
                    {
                        Intent intent = new Intent(activity, typeof(ViewStoryActivity));
                        intent.PutExtra("UserId", dataMyStory.UserId);
                        intent.PutExtra("DataItem", JsonConvert.SerializeObject(dataMyStory));
                        activity.StartActivity(intent);
                    }

                    break;
                }

                case "requested_to_join_group":
                {
                    var intent = new Intent(activity, typeof(JoinRequestActivity));
                    intent.PutExtra("GroupId", item.GroupId);
                    activity.StartActivity(intent);
                    break;
                }

                case "memory":
                {
                    var intent = new Intent(activity, typeof(MemoriesActivity));
                    activity.StartActivity(intent);
                    break;
                }

                case "gift":
                {
                    var ajaxUrl  = item.AjaxUrl.Split(new[] { "&", "gift_img=" }, StringSplitOptions.None);
                    var urlImage = WoWonderTools.GetTheFinalLink(ajaxUrl?[3]?.Replace("%2F", "/"));

                    var intent = new Intent(Activity, typeof(UserProfileActivity));
                    intent.PutExtra("UserObject", JsonConvert.SerializeObject(item.Notifier));
                    intent.PutExtra("UserId", item.Notifier.UserId);
                    intent.PutExtra("GifLink", urlImage);
                    Activity.StartActivity(intent);
                    break;
                }

                default:
                    WoWonderTools.OpenProfile(Activity, item.Notifier.UserId, item.Notifier);
                    break;
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
        public void PrepareJob(PostDataObject item)
        {
            try
            {
                if (item.Job != null)
                {
                    if (!item.Job.Value.JobInfoClass.Image.Contains(Client.WebsiteUrl))
                    {
                        item.Job.Value.JobInfoClass.Image = WoWonderTools.GetTheFinalLink(item.Job.Value.JobInfoClass.Image);
                    }

                    item.Job.Value.JobInfoClass.IsOwner = item.Job.Value.JobInfoClass.UserId == UserDetails.UserId;

                    if (!string.IsNullOrEmpty(item.Job.Value.JobInfoClass.Title))
                    {
                        var prepareTitle = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Job.Value.JobInfoClass.Title, 100));
                        item.Job.Value.JobInfoClass.Title = prepareTitle;
                    }
                    if (!string.IsNullOrEmpty(item.Job?.JobInfoClass.Description))
                    {
                        var prepareDescription = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Job?.JobInfoClass.Description, 200));
                        item.Job.Value.JobInfoClass.Description = prepareDescription;
                    }

                    if (item.Job.Value.JobInfoClass.Page != null)
                    {
                        var prepareName = "@" + Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Job.Value.JobInfoClass.Page.PageName, 100));
                        item.Job.Value.JobInfoClass.Page.PageName = prepareName;

                        if (item.Job.Value.JobInfoClass.Page.IsPageOnwer != null && item.Job.Value.JobInfoClass.Page.IsPageOnwer.Value)
                        {
                            item.Job.Value.JobInfoClass.ButtonText = MainContext.GetString(Resource.String.Lbl_show_applies) + " (" + item.Job.Value.JobInfoClass.ApplyCount + ")";
                        }
                    }

                    if (item.Job.Value.JobInfoClass.Apply == "true")
                    {
                        var prepare = MainContext.GetString(Resource.String.Lbl_already_applied);
                        item.Job.Value.JobInfoClass.ButtonText = prepare;
                    }
                    else if (item.Job.Value.JobInfoClass.Apply != "true" && item.Job.Value.JobInfoClass.Page.IsPageOnwer != null && !item.Job.Value.JobInfoClass.Page.IsPageOnwer.Value)
                    {
                        var prepare = MainContext.GetString(Resource.String.Lbl_apply_now);
                        item.Job.Value.JobInfoClass.ButtonText = prepare;
                    }

                    if (!string.IsNullOrEmpty(item.Job.Value.JobInfoClass.Time))
                    {
                        var prepareTime = Methods.Time.TimeAgo(Convert.ToInt32(item.Job.Value.JobInfoClass.Time), false);
                        item.Job.Value.JobInfoClass.Time = prepareTime;
                    }

                    if (!string.IsNullOrEmpty(item.Job.Value.JobInfoClass.Location))
                    {
                        item.Job.Value.JobInfoClass.LocationDecodedText = item.Product?.ProductClass?.Location;
                        var prepareLocation = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Product?.ProductClass?.Location, 100));
                        item.Job.Value.JobInfoClass.LocationDecodedText = prepareLocation;
                    }

                    //Set Salary Date
                    if (!string.IsNullOrEmpty(item.Job.Value.JobInfoClass.SalaryDate))
                    {
                        var salaryDate = item.Job.Value.JobInfoClass.SalaryDate switch
                        {
                            "per_hour" => MainContext.GetString(Resource.String.Lbl_per_hour),
                            "per_day" => MainContext.GetString(Resource.String.Lbl_per_day),
                            "per_week" => MainContext.GetString(Resource.String.Lbl_per_week),
                            "per_month" => MainContext.GetString(Resource.String.Lbl_per_month),
                            "per_year" => MainContext.GetString(Resource.String.Lbl_per_year),
                            _ => MainContext.GetString(Resource.String.Lbl_Unknown)
                        };

                        item.Job.Value.JobInfoClass.SalaryDate = salaryDate;
                    }

                    if (!string.IsNullOrEmpty(item.Job.Value.JobInfoClass.JobType))
                    {
                        var jobInfo = item.Job.Value.JobInfoClass.JobType switch
                        {
                            //Set job type
                            "full_time" => IonIconsFonts.IosBriefcase + " " + MainContext.GetString(Resource.String.Lbl_full_time),
                            "part_time" => IonIconsFonts.IosBriefcase + " " + MainContext.GetString(Resource.String.Lbl_part_time),
                            "internship" => IonIconsFonts.IosBriefcase + " " + MainContext.GetString(Resource.String.Lbl_internship),
                            "volunteer" => IonIconsFonts.IosBriefcase + " " + MainContext.GetString(Resource.String.Lbl_volunteer),
                            "contract" => IonIconsFonts.IosBriefcase + " " + MainContext.GetString(Resource.String.Lbl_contract),
                            _ => IonIconsFonts.IosBriefcase + " " + MainContext.GetString(Resource.String.Lbl_Unknown)
                        };

                        item.Job.Value.JobInfoClass.JobType = jobInfo;
                    }


                    var categoryName = CategoriesController.ListCategoriesJob.FirstOrDefault(categories => categories.CategoriesId == item.Job.Value.JobInfoClass.Category)?.CategoriesName;
                    item.Job.Value.JobInfoClass.Category += " " + " " + IonIconsFonts.Pricetag + " " + categoryName;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Beispiel #3
0
        public void LoadCommentData(CommentObjectExtra item, CommentAdapterViewHolder holder)
        {
            try
            {
                if (!string.IsNullOrEmpty(item.Orginaltext) || !string.IsNullOrWhiteSpace(item.Orginaltext))
                {
                    var text = Methods.FunString.DecodeString(item.Orginaltext);
                    ReadMoreOption.AddReadMoreTo(holder.CommentText, new Java.Lang.String(text));
                }
                else
                {
                    holder.CommentText.Visibility = ViewStates.Gone;
                }

                holder.TimeTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(item.Time), false);
                holder.UserName.Text     = item.Publisher.Name;

                GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                var textHighLighter = item.Publisher.Name;
                var textIsPro       = string.Empty;

                if (item.Publisher.Verified == "1")
                {
                    textHighLighter += " " + IonIconsFonts.CheckmarkCircle;
                }

                if (item.Publisher.IsPro == "1")
                {
                    textIsPro        = " " + IonIconsFonts.Flash;
                    textHighLighter += textIsPro;
                }

                var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter).SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length);

                if (item.Publisher.Verified == "1")
                {
                    decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircle);
                }

                if (item.Publisher.IsPro == "1")
                {
                    decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro);
                }

                decorator.Build();

                //Image
                if (holder.ItemViewType == 1 || holder.CommentImage != null)
                {
                    if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/")))
                    {
                        File file2    = new File(item.CFile);
                        var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                        Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage);

                        //GlideImageLoader.LoadImage(ActivityContext,item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                    else
                    {
                        if (!item.CFile.Contains(Client.WebsiteUrl))
                        {
                            item.CFile = WoWonderTools.GetTheFinalLink(item.CFile);
                        }

                        GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                        item.CFile = WoWonderTools.GetFile("", Methods.Path.FolderDiskImage, item.CFile.Split('/').Last(), item.CFile);
                    }
                }

                //Voice
                if (holder.VoiceLayout != null && !string.IsNullOrEmpty(item.Record))
                {
                    LoadAudioItem(holder, item);
                }

                var repliesCount = !string.IsNullOrEmpty(item.RepliesCount) ? item.RepliesCount : item.Replies ?? "";
                if (repliesCount != "0" && !string.IsNullOrEmpty(repliesCount))
                {
                    holder.ReplyTextView.Text = ActivityContext.GetText(Resource.String.Lbl_Reply) + " " + "(" + repliesCount + ")";
                }

                if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                {
                    item.Reaction ??= new Reaction();

                    holder.CountRating.Text = item.Reaction.Count + " " + ActivityContext.GetString(Resource.String.Lbl_Reactions);
                    holder.RatingBar.Rating = (float)Convert.ToDouble(item.Reaction.Type);
                    if (holder.RatingBar.Rating > 0)
                    {
                        holder.RatingText.Text = item.Reaction.Type;
                    }
                    else
                    {
                        holder.RatingText.Text = "0.0";
                    }

                    //if (item.Reaction.Count > 0)
                    //{
                    //    holder.CountLikeSection.Visibility = ViewStates.Visible;
                    //    holder.CountLike.Text = Methods.FunString.FormatPriceValue(item.Reaction.Count);
                    //}
                    //else
                    //{
                    //    holder.CountLikeSection.Visibility = ViewStates.Gone;
                    //}

                    if (item.Reaction.IsReacted != null && item.Reaction.IsReacted.Value)
                    {
                        if (!string.IsNullOrEmpty(item.Reaction.Type))
                        {
                            var react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Id == item.Reaction.Type).Value?.Id ?? "";
                            switch (react)
                            {
                            case "1":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Like);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                                break;

                            case "2":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Love);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_love);
                                break;

                            case "3":
                                ReactionComment.SetReactionPack(holder, ReactConstants.HaHa);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_haha);
                                break;

                            case "4":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Wow);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_wow);
                                break;

                            case "5":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Sad);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_sad);
                                break;

                            case "6":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Angry);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_angry);
                                break;

                            default:
                                holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                                holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                                holder.LikeTextView.Tag = "Like";

                                if (item.Reaction.Count > 0)
                                {
                                    holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                                }

                                break;
                            }
                        }
                    }
                    else
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                        holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.LikeTextView.Tag = "Like";
                        if (item.Reaction.Count > 0)
                        {
                            holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                        }
                    }
                }
                else if (AppSettings.PostButton == PostButtonSystem.Wonder || AppSettings.PostButton == PostButtonSystem.DisLike)
                {
                    if (item.Reaction?.IsReacted != null && !item.Reaction.IsReacted.Value)
                    {
                        ReactionComment.SetReactionPack(holder, ReactConstants.Default);
                    }

                    if (item.IsCommentLiked)
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                        holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.LikeTextView.Tag = "Liked";
                    }

                    switch (AppSettings.PostButton)
                    {
                    case PostButtonSystem.Wonder when item.IsCommentWondered:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_wondered);
                        holder.DislikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.DislikeTextView.Tag = "Disliked";
                        break;
                    }

                    case PostButtonSystem.Wonder:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Wonder);
                        holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.DislikeTextView.Tag = "Dislike";
                        break;
                    }

                    case PostButtonSystem.DisLike when item.IsCommentWondered:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_disliked);
                        holder.DislikeTextView.SetTextColor(Color.ParseColor("#f89823"));
                        holder.DislikeTextView.Tag = "Disliked";
                        break;
                    }

                    case PostButtonSystem.DisLike:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Dislike);
                        holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.DislikeTextView.Tag = "Dislike";
                        break;
                    }
                    }
                }
                else
                {
                    if (item.IsCommentLiked)
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                        holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.LikeTextView.Tag = "Liked";
                    }
                    else
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                        holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.LikeTextView.Tag = "Like";
                    }
                }

                holder.TimeTextView.Tag = "true";
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        //Open user profile
        private void MAdapterOnItemClick(object sender, NotificationsAdapterClickEventArgs e)
        {
            try
            {
                if (e.Position > -1)
                {
                    var item = MAdapter.GetItem(e.Position);
                    if (item != null)
                    {
                        if (item.Type == "following" || item.Type == "visited_profile" || item.Type == "accepted_request")
                        {
                            WoWonderTools.OpenProfile(Activity, item.Notifier.UserId, item.Notifier);
                        }
                        else if (item.Type == "liked_page" || item.Type == "invited_page" || item.Type == "accepted_invite")
                        {
                            var intent = new Intent(Context, typeof(PageProfileActivity));
                            //intent.PutExtra("PageObject", JsonConvert.SerializeObject(item));
                            intent.PutExtra("PageId", item.PageId);
                            Context.StartActivity(intent);
                        }
                        else if (item.Type == "joined_group" || item.Type == "accepted_join_request" || item.Type == "added_you_to_group")
                        {
                            var intent = new Intent(Context, typeof(GroupProfileActivity));
                            //intent.PutExtra("GroupObject", JsonConvert.SerializeObject(item));
                            intent.PutExtra("GroupId", item.GroupId);
                            Context.StartActivity(intent);
                        }
                        else if (item.Type == "comment" || item.Type == "wondered_post" ||
                                 item.Type == "wondered_comment" || item.Type == "reaction" ||
                                 item.Type == "wondered_reply_comment" || item.Type == "comment_mention" ||
                                 item.Type == "comment_reply_mention" ||
                                 item.Type == "liked_post" || item.Type == "liked_comment" ||
                                 item.Type == "liked_reply_comment" || item.Type == "post_mention" ||
                                 item.Type == "share_post" || item.Type == "shared_your_post" || item.Type == "comment_reply" ||
                                 item.Type == "also_replied" || item.Type == "profile_wall_post")
                        {
                            var intent = new Intent(Context, typeof(ViewFullPostActivity));
                            intent.PutExtra("Id", item.PostId);
                            // intent.PutExtra("DataItem", JsonConvert.SerializeObject(item));
                            Context.StartActivity(intent);
                        }
                        else if (item.Type == "going_event")
                        {
                            var intent = new Intent(Context, typeof(EventViewActivity));
                            intent.PutExtra("EventView", JsonConvert.SerializeObject(item.Event));
                            intent.PutExtra("Id", item.EventId);
                            Context.StartActivity(intent);
                        }
                        else if (item.Type == "viewed_story")
                        {
                            //"url": "https:\/\/demo.wowonder.com\/timeline&u=Matan&story=true&story_id=1946",
                            //var id = item.Url.Split("/").Last().Split("&story_id=").Last();

                            GetUserStoriesObject.StoryObject dataMyStory = GlobalContext?.NewsFeedTab?.PostFeedAdapter?.HolderStory?.StoryAdapter?.StoryList?.FirstOrDefault(o => o.UserId == UserDetails.UserId);
                            if (dataMyStory != null)
                            {
                                Intent intent = new Intent(Context, typeof(ViewStoryActivity));
                                intent.PutExtra("UserId", dataMyStory.UserId);
                                intent.PutExtra("DataItem", JsonConvert.SerializeObject(dataMyStory));
                                Context.StartActivity(intent);
                            }
                        }
                        else if (item.Type == "requested_to_join_group")
                        {
                            var intent = new Intent(Context, typeof(JoinRequestActivity));
                            intent.PutExtra("GroupId", item.GroupId);
                            Context.StartActivity(intent);
                        }
                        else if (item.Type == "memory")
                        {
                            var intent = new Intent(Context, typeof(MemoriesActivity));
                            Context.StartActivity(intent);
                        }
                        else if (item.Type == "gift")
                        {
                            var ajaxUrl  = item.AjaxUrl.Split(new[] { "&", "gift_img=" }, StringSplitOptions.None);
                            var urlImage = WoWonderTools.GetTheFinalLink(ajaxUrl?[3]?.Replace("%2F", "/"));

                            var intent = new Intent(Activity, typeof(UserProfileActivity));
                            intent.PutExtra("UserObject", JsonConvert.SerializeObject(item.Notifier));
                            intent.PutExtra("UserId", item.Notifier.UserId);
                            intent.PutExtra("GifLink", urlImage);
                            Activity.StartActivity(intent);
                        }
                        else
                        {
                            WoWonderTools.OpenProfile(Activity, item.Notifier.UserId, item.Notifier);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Beispiel #5
0
        public void LoadCommentData(CommentObjectExtra item, CommentAdapterViewHolder holder, int position = 0, bool hasClickEvents = true)
        {
            try
            {
                if (!string.IsNullOrEmpty(item.Text) || !string.IsNullOrWhiteSpace(item.Text))
                {
                    var changer = new TextSanitizer(holder.CommentText, ActivityContext);
                    changer.Load(Methods.FunString.DecodeString(item.Text));
                }
                else
                {
                    holder.CommentText.Visibility = ViewStates.Gone;
                }

                holder.TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(item.Time));
                holder.UserName.Text     = item.Publisher.Name;

                GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                var textHighLighter = item.Publisher.Name;
                var textIsPro       = string.Empty;

                if (item.Publisher.Verified == "1")
                {
                    textHighLighter += " " + IonIconsFonts.CheckmarkCircled;
                }

                if (item.Publisher.IsPro == "1")
                {
                    textIsPro        = " " + IonIconsFonts.Flash;
                    textHighLighter += textIsPro;
                }

                var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter).SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length);

                if (item.Publisher.Verified == "1")
                {
                    decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled);
                }

                if (item.Publisher.IsPro == "1")
                {
                    decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro);
                }

                decorator.Build();

                //Image
                if (holder.ItemViewType == 1 || holder.CommentImage != null)
                {
                    if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/")))
                    {
                        File file2    = new File(item.CFile);
                        var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                        Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage);

                        //GlideImageLoader.LoadImage(ActivityContext,item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                    else
                    {
                        if (!item.CFile.Contains(Client.WebsiteUrl))
                        {
                            item.CFile = WoWonderTools.GetTheFinalLink(item.CFile);
                        }

                        GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                }

                //Voice
                if (holder.VoiceLayout != null && !string.IsNullOrEmpty(item.Record))
                {
                    LoadAudioItem(holder, position, item);
                }

                if (item.Replies != "0" && item.Replies != null)
                {
                    holder.ReplyTextView.Text = ActivityContext.GetText(Resource.String.Lbl_Reply) + " " + "(" + item.Replies + ")";
                }

                if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                {
                    item.Reaction ??= new WoWonderClient.Classes.Posts.Reaction();

                    if ((bool)(item.Reaction != null & item.Reaction?.IsReacted))
                    {
                        if (!string.IsNullOrEmpty(item.Reaction.Type))
                        {
                            switch (item.Reaction.Type)
                            {
                            case "1":
                            case "Like":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Like);
                                holder.LikeTextView.Tag = "Liked";
                                break;

                            case "2":
                            case "Love":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Love);
                                holder.LikeTextView.Tag = "Liked";
                                break;

                            case "3":
                            case "HaHa":
                                ReactionComment.SetReactionPack(holder, ReactConstants.HaHa);
                                holder.LikeTextView.Tag = "Liked";
                                break;

                            case "4":
                            case "Wow":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Wow);
                                holder.LikeTextView.Tag = "Liked";
                                break;

                            case "5":
                            case "Sad":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Sad);
                                holder.LikeTextView.Tag = "Liked";
                                break;

                            case "6":
                            case "Angry":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Angry);
                                holder.LikeTextView.Tag = "Liked";
                                break;

                            default:
                                holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                                holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                                holder.LikeTextView.Tag = "Like";
                                break;
                            }
                        }
                    }
                    else
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                        holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.LikeTextView.Tag = "Like";
                    }
                }
                else if (AppSettings.PostButton == PostButtonSystem.Wonder || AppSettings.PostButton == PostButtonSystem.DisLike)
                {
                    if ((bool)(item.Reaction != null & !item.Reaction?.IsReacted))
                    {
                        ReactionComment.SetReactionPack(holder, ReactConstants.Default);
                    }

                    if (item.IsCommentLiked)
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                        holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.LikeTextView.Tag = "Liked";
                    }

                    switch (AppSettings.PostButton)
                    {
                    case PostButtonSystem.Wonder when item.IsCommentWondered:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_wondered);
                        holder.DislikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.DislikeTextView.Tag = "Disliked";
                        break;
                    }

                    case PostButtonSystem.Wonder:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Wonder);
                        holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.DislikeTextView.Tag = "Dislike";
                        break;
                    }

                    case PostButtonSystem.DisLike when item.IsCommentWondered:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_disliked);
                        holder.DislikeTextView.SetTextColor(Color.ParseColor("#f89823"));
                        holder.DislikeTextView.Tag = "Disliked";
                        break;
                    }

                    case PostButtonSystem.DisLike:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Dislike);
                        holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.DislikeTextView.Tag = "Dislike";
                        break;
                    }
                    }
                }
                else
                {
                    if (item.IsCommentLiked)
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                        holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.LikeTextView.Tag = "Liked";
                    }
                    else
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                        holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.LikeTextView.Tag = "Like";
                    }
                }

                holder.TimeTextView.Tag = "true";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #6
0
        public void OpenImageLightBox(CommentObjectExtra item)
        {
            try
            {
                if (item == null)
                {
                    return;
                }
                string imageUrl;

                if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/")))
                {
                    imageUrl = item.CFile;
                }
                else
                {
                    if (!item.CFile.Contains(Client.WebsiteUrl))
                    {
                        item.CFile = WoWonderTools.GetTheFinalLink(item.CFile);
                    }

                    imageUrl = item.CFile;
                }

                MainContext.RunOnUiThread(() =>
                {
                    var media = WoWonderTools.GetFile("", Methods.Path.FolderDiskImage, imageUrl.Split('/').Last(), imageUrl);
                    if (media.Contains("http"))
                    {
                        Intent intent = new Intent(Intent.ActionView, Uri.Parse(media));
                        MainContext.StartActivity(intent);
                    }
                    else
                    {
                        Java.IO.File file2 = new Java.IO.File(media);
                        var photoUri       = FileProvider.GetUriForFile(MainContext, MainContext.PackageName + ".fileprovider", file2);

                        Intent intent = new Intent(Intent.ActionPick);
                        intent.SetAction(Intent.ActionView);
                        intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                        intent.SetDataAndType(photoUri, "image/*");
                        MainContext.StartActivity(intent);
                    }

                    //var getImage = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimImage, fileName);
                    //if (getImage != "File Dont Exists")
                    //{
                    //    Java.IO.File file2 = new Java.IO.File(getImage);
                    //    var photoUri = FileProvider.GetUriForFile(MainContext, MainContext.PackageName + ".fileprovider", file2);

                    //    Intent intent = new Intent(Intent.ActionPick);
                    //    intent.SetAction(Intent.ActionView);
                    //    intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                    //    intent.SetDataAndType(photoUri, "image/*");
                    //    MainContext.StartActivity(intent);
                    //}
                    //else
                    //{
                    //    string filename = imageUrl.Split('/').Last();
                    //    string filePath = Path.Combine(Methods.Path.FolderDcimImage);
                    //    string mediaFile = filePath + "/" + filename;

                    //    if (!Directory.Exists(filePath))
                    //        Directory.CreateDirectory(filePath);

                    //    if (!File.Exists(mediaFile))
                    //    {
                    //        WebClient webClient = new WebClient();
                    //        AndHUD.Shared.Show(MainContext, MainContext.GetText(Resource.String.Lbl_Loading));

                    //        webClient.DownloadDataAsync(new Uri(imageUrl));
                    //        webClient.DownloadProgressChanged += (sender, args) =>
                    //        {
                    //            //var progress = args.ProgressPercentage;
                    //            // holder.loadingProgressview.Progress = progress;
                    //            //Show a progress
                    //            AndHUD.Shared.Show(MainContext, MainContext.GetText(Resource.String.Lbl_Loading));
                    //        };
                    //        webClient.DownloadDataCompleted += (s, e) =>
                    //        {
                    //            try
                    //            {
                    //                File.WriteAllBytes(mediaFile, e.Result);

                    //                getImage = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimImage, fileName);
                    //                if (getImage != "File Dont Exists")
                    //                {
                    //                    Java.IO.File file2 = new Java.IO.File(getImage);

                    //                    Android.Net.Uri photoUri = FileProvider.GetUriForFile(MainContext, MainContext.PackageName + ".fileprovider", file2);

                    //                    Intent intent = new Intent(Intent.ActionPick);
                    //                    intent.SetAction(Intent.ActionView);
                    //                    intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                    //                    intent.SetDataAndType(photoUri, "image/*");
                    //                    MainContext.StartActivity(intent);
                    //                }
                    //                else
                    //                {
                    //                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_something_went_wrong), ToastLength.Long)?.Show();
                    //                }
                    //            }
                    //            catch (Exception exception)
                    //            {
                    //                Methods.DisplayReportResultTrack(exception);
                    //            }

                    //            //var mediaScanIntent = new Intent(Intent?.ActionMediaScannerScanFile);
                    //            //mediaScanIntent?.SetData(Uri.FromFile(new File(mediaFile)));
                    //            //Application.Context.SendBroadcast(mediaScanIntent);

                    //            // Tell the media scanner about the new file so that it is
                    //            // immediately available to the user.
                    //            MediaScannerConnection.ScanFile(Application.Context, new[] { mediaFile }, null, null);

                    //            AndHUD.Shared.Dismiss(MainContext);
                    //        };
                    //    }
                    //}
                });
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Beispiel #7
0
        public void LoadCommentData(CommentObjectExtra item, RecyclerView.ViewHolder viewHolder, int position = 0, bool hasClickEvents = true)
        {
            try
            {
                if (!(viewHolder is CommentAdapterViewHolder holder))
                {
                    return;
                }

                if (AppSettings.FlowDirectionRightToLeft)
                {
                    holder.BubbleLayout.LayoutDirection = LayoutDirection.Rtl;
                }

                if (!string.IsNullOrEmpty(item.Text) || !string.IsNullOrWhiteSpace(item.Text))
                {
                    var changer = new TextSanitizer(holder.CommentText, ActivityContext);
                    changer.Load(Methods.FunString.DecodeString(item.Text));
                }
                else
                {
                    holder.CommentText.Visibility = ViewStates.Gone;
                }

                holder.TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(item.Time));
                holder.UserName.Text     = item.Publisher.Name;

                GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                var textHighLighter = item.Publisher.Name;
                var textIsPro       = string.Empty;

                if (item.Publisher.Verified == "1")
                {
                    textHighLighter += " " + IonIconsFonts.CheckmarkCircled;
                }

                if (item.Publisher.IsPro == "1")
                {
                    textIsPro        = " " + IonIconsFonts.Flash;
                    textHighLighter += textIsPro;
                }

                var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter).SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length);

                if (item.Publisher.Verified == "1")
                {
                    decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled);
                }

                if (item.Publisher.IsPro == "1")
                {
                    decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro);
                }

                decorator.Build();

                //Image
                if (holder.ItemViewType == 1 || holder.CommentImage != null)
                {
                    if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/")))
                    {
                        File file2    = new File(item.CFile);
                        var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                        Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage);

                        //GlideImageLoader.LoadImage(ActivityContext,item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                    else
                    {
                        if (!item.CFile.Contains(Client.WebsiteUrl))
                        {
                            item.CFile = WoWonderTools.GetTheFinalLink(item.CFile);
                        }

                        GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                }

                //Voice
                if (holder.VoiceLayout != null && !string.IsNullOrEmpty(item.Record))
                {
                    LoadAudioItem(holder, position, item);
                }

                if (item.Replies != "0" && item.Replies != null)
                {
                    holder.ReplyTextView.Text = ActivityContext.GetText(Resource.String.Lbl_Reply) + " " + "(" + item.Replies + ")";
                }

                if (item.IsCommentLiked)
                {
                    holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                    holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                    holder.LikeTextView.Tag = "Liked";
                }
                else
                {
                    holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);

                    if (AppSettings.SetTabDarkTheme || ThemeColor == "Dark")
                    {
                        holder.ReplyTextView.SetTextColor(Color.White);
                        holder.LikeTextView.SetTextColor(Color.White);
                    }
                    else
                    {
                        holder.ReplyTextView.SetTextColor(Color.Black);
                        holder.LikeTextView.SetTextColor(Color.Black);
                    }

                    holder.LikeTextView.Tag = "Like";
                }

                holder.TimeTextView.Tag = "true";

                if (holder.Image.HasOnClickListeners)
                {
                    return;
                }

                var postEventListener = new CommentClickListener(ActivityContext, "Comment");

                //Create an Event
                holder.MainView.LongClick += (sender, e) => postEventListener.MoreCommentReplyPostClick(new CommentReplyClickEventArgs {
                    CommentObject = item, Position = position, View = holder.MainView
                });

                holder.Image.Click += (sender, args) => postEventListener.ProfilePostClick(new ProfileClickEventArgs {
                    Holder = holder, CommentClass = item, Position = position, View = holder.MainView
                });

                if (hasClickEvents)
                {
                    holder.ReplyTextView.Click += (sender, args) => postEventListener.CommentReplyPostClick(new CommentReplyClickEventArgs {
                        CommentObject = item, Position = position, View = holder.MainView
                    });
                }

                holder.LikeTextView.Click += delegate
                {
                    try
                    {
                        if (holder.LikeTextView.Tag.ToString() == "Liked")
                        {
                            item.IsCommentLiked = false;

                            holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                            if (AppSettings.SetTabDarkTheme || ThemeColor == "Dark")
                            {
                                holder.LikeTextView.SetTextColor(Color.White);
                            }
                            else
                            {
                                holder.LikeTextView.SetTextColor(Color.Black);
                            }

                            holder.LikeTextView.Tag = "Like";

                            //sent api Dislike comment
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comment.LikeUnLikeCommentAsync(item.Id, false)
                            });
                        }
                        else
                        {
                            item.IsCommentLiked = true;

                            holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                            holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                            holder.LikeTextView.Tag = "Liked";

                            //sent api like comment
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comment.LikeUnLikeCommentAsync(item.Id, true)
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                };

                if (holder.CommentImage != null)
                {
                    holder.CommentImage.Click += (sender, args) => postEventListener.OpenImageLightBox(item);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #8
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 NearbyBusinessAdapterViewHolder holder:
                {
                    var item = NearbyBusinessList[position];
                    if (item.Job?.JobInfoClass != null)
                    {
                        item.Job.Value.JobInfoClass.Image =
                            item.Job.Value.JobInfoClass.Image.Contains(Client.WebsiteUrl) switch
                        {
                            false => WoWonderTools.GetTheFinalLink(item.Job?.JobInfoClass.Image),
                            _ => item.Job.Value.JobInfoClass.Image
                        };

                        item.Job.Value.JobInfoClass.IsOwner = item.Job?.JobInfoClass.UserId == UserDetails.UserId;

                        if (item.Job.Value.JobInfoClass.Image.Contains("http"))
                        {
                            GlideImageLoader.LoadImage(ActivityContext, item.Job.Value.JobInfoClass.Image, holder.Image, ImageStyle.FitCenter, ImagePlaceholders.Drawable);
                        }
                        else
                        {
                            File file2    = new File(item.Job.Value.JobInfoClass.Image);
                            var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                            Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.Image);
                        }

                        holder.Title.Text = Methods.FunString.DecodeString(item.Job.Value.JobInfoClass.Title);

                        var(currency, currencyIcon) = WoWonderTools.GetCurrency(item.Job.Value.JobInfoClass.Currency);
                        var categoryName = CategoriesController.ListCategoriesJob.FirstOrDefault(categories => categories.CategoriesId == item.Job.Value.JobInfoClass.Category)?.CategoriesName;
                        Console.WriteLine(currency);
                        if (string.IsNullOrEmpty(categoryName))
                        {
                            categoryName = Application.Context.GetText(Resource.String.Lbl_Unknown);
                        }

                        holder.Salary.Text = item.Job.Value.JobInfoClass.Minimum + " " + currencyIcon + " - " + item.Job.Value.JobInfoClass.Maximum + " " + currencyIcon + " . " + categoryName;

                        holder.Description.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.Job.Value.JobInfoClass.Description), 100);

                        if (item.Job.Value.JobInfoClass.IsOwner != null && item.Job.Value.JobInfoClass.IsOwner.Value)
                        {
                            holder.IconMore.Visibility = ViewStates.Visible;
                            holder.Button.Text         = ActivityContext.GetString(Resource.String.Lbl_show_applies) + " (" + item.Job.Value.JobInfoClass.ApplyCount + ")";
                            holder.Button.Tag          = "ShowApply";
                        }
                        else
                        {
                            holder.IconMore.Visibility = ViewStates.Gone;
                        }

                        switch (item.Job.Value.JobInfoClass.Apply)
                        {
                        //Set Button if its applied
                        case "true":
                            holder.Button.Text    = ActivityContext.GetString(Resource.String.Lbl_already_applied);
                            holder.Button.Enabled = false;
                            break;
                        }
                    }

                    break;
                }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }