Пример #1
0
 public FeedCombiner(PostDataObject post, List <AdapterModelsClass> diffList, Context context)
 {
     MainContext       = context;
     PostFeedType      = PostFunctions.GetAdapterType(post);
     PostModelResolver = new PostModelResolver(context, PostFeedType);
     PostCollection    = post;
     PostList          = diffList;
     TextDecorator     = new WoTextDecorator();
 }
Пример #2
0
 public PostModelResolver(Context mainContext, PostModelType postFeedType)
 {
     try
     {
         MainContext  = mainContext;
         PostFeedType = postFeedType;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
Пример #3
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            try
            {
                base.OnViewCreated(view, savedInstanceState);

                DataPost = JsonConvert.DeserializeObject <PostDataObject>(Arguments?.GetString("ItemData") ?? "");
                TypePost = JsonConvert.DeserializeObject <PostModelType>(Arguments?.GetString("TypePost") ?? "");

                InitComponent(view);
                AddOrRemoveEvent(true);
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Пример #4
0
        public void AddSuggestedBoxPostView(PostModelType modelType)
        {
            if (modelType == PostModelType.SuggestedGroupsBox)
            {
                PostList.Add(new AdapterModelsClass
                {
                    TypeView = PostModelType.SuggestedGroupsBox,
                    Id       = 3216545,
                });
            }
            else
            {
                PostList.Add(new AdapterModelsClass
                {
                    TypeView = PostModelType.SuggestedUsersBox,
                    Id       = 3228546,
                });
            }

            AddPostDivider();
        }
Пример #5
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            try
            {
                Context        contextThemeWrapper = AppSettings.SetTabDarkTheme ? new ContextThemeWrapper(Activity, Resource.Style.MyTheme_Dark_Base) : new ContextThemeWrapper(Activity, Resource.Style.MyTheme_Base);
                LayoutInflater localInflater       = inflater.CloneInContext(contextThemeWrapper);
                View           view = localInflater.Inflate(Resource.Layout.NativeShareBottomDialog, container, false);

                DataPost = JsonConvert.DeserializeObject <PostDataObject>(Arguments.GetString("ItemData") ?? "");

                TypePost = JsonConvert.DeserializeObject <PostModelType>(Arguments.GetString("TypePost"));

                InitComponent(view);
                AddOrRemoveEvent(true);

                return(view);
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
                return(null !);
            }
        }
Пример #6
0
        public void AddAdsPostView(PostModelType modelType)
        {
            if (modelType == PostModelType.AdMob)
            {
                var adMobBox = new AdapterModelsClass
                {
                    TypeView = PostModelType.AdMob,
                    Id       = 2222019
                };
                PostList.Add(adMobBox);
            }
            else
            {
                var adMobBox = new AdapterModelsClass
                {
                    TypeView = PostModelType.FbAdNative,
                    Id       = 2222220
                };
                PostList.Add(adMobBox);
            }

            AddPostDivider();
        }
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            try
            {
                base.OnViewCreated(view, savedInstanceState);

                DataPost = JsonConvert.DeserializeObject <PostDataObject>(Arguments?.GetString("ItemData") ?? "");
                TypePost = JsonConvert.DeserializeObject <PostModelType>(Arguments?.GetString("TypePost") ?? "");

                Savepost        = JsonConvert.DeserializeObject <string>(Arguments?.GetString("savePost") ?? "");
                Copytext        = JsonConvert.DeserializeObject <string>(Arguments?.GetString("copyText") ?? "");
                Reportpost      = JsonConvert.DeserializeObject <string>(Arguments?.GetString("copyLink") ?? "");
                Editpost        = JsonConvert.DeserializeObject <string>(Arguments?.GetString("postType") ?? "");
                Boostpost       = JsonConvert.DeserializeObject <string>(Arguments?.GetString("boostPost") ?? "");
                Disablecomments = JsonConvert.DeserializeObject <string>(Arguments?.GetString("commentStatus") ?? "");

                InitComponent(view);
                AddOrRemoveEvent(true);
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
 public PostModelResolver(Context mainContext, PostModelType postFeedType)
 {
     MainContext  = mainContext;
     PostFeedType = postFeedType;
 }
Пример #9
0
        public bool LoadBottomDataApi(List <PostDataObject> list)
        {
            try
            {
                var countList = NativeFeedAdapter.ItemCount;
                if (list?.Count > 0)
                {
                    bool add = false;
                    foreach (var post in from post in list let check = NativeFeedAdapter.ListDiffer.FirstOrDefault(a => a?.PostData?.PostId == post.PostId && a?.TypeView == PostFunctions.GetAdapterType(post)) where check == null select post)
                    {
                        add = true;
                        var combiner = new FeedCombiner(null, NativeFeedAdapter.ListDiffer, ActivityContext);

                        if (NativeFeedAdapter.NativePostType == NativeFeedType.Global)
                        {
                            var check1 = NativeFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.SuggestedGroupsBox);
                            if (check1 == null && AppSettings.ShowSuggestedGroup && NativeFeedAdapter.ListDiffer.Count > 0 && NativeFeedAdapter.ListDiffer.Count % AppSettings.ShowSuggestedGroupCount == 0 && ListUtils.SuggestedGroupList.Count > 0)
                            {
                                combiner.AddSuggestedBoxPostView(PostModelType.SuggestedGroupsBox);
                            }

                            var check2 = NativeFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.SuggestedUsersBox);
                            if (check2 == null && AppSettings.ShowSuggestedUser && NativeFeedAdapter.ListDiffer.Count > 0 && NativeFeedAdapter.ListDiffer.Count % AppSettings.ShowSuggestedUserCount == 0 && ListUtils.SuggestedUserList.Count > 0)
                            {
                                combiner.AddSuggestedBoxPostView(PostModelType.SuggestedUsersBox);
                            }
                        }

                        if (NativeFeedAdapter.ListDiffer.Count % AppSettings.ShowAdMobNativeCount == 0 && NativeFeedAdapter.ListDiffer.Count > 0 && AppSettings.ShowAdMobNativePost)
                        {
                            switch (LastAdsType)
                            {
                            case PostModelType.AdMob1:
                                LastAdsType = PostModelType.AdMob2;
                                combiner.AddAdsPostView(PostModelType.AdMob1);
                                break;

                            case PostModelType.AdMob2:
                                LastAdsType = PostModelType.AdMob3;
                                combiner.AddAdsPostView(PostModelType.AdMob2);
                                break;

                            case PostModelType.AdMob3:
                                LastAdsType = PostModelType.AdMob1;
                                combiner.AddAdsPostView(PostModelType.AdMob3);
                                break;
                            }
                        }

                        var combine = new FeedCombiner(RegexFilterText(post), NativeFeedAdapter.ListDiffer, ActivityContext);
                        if (post.PostType == "ad")
                        {
                            combine.AddAdsPost();
                        }
                        else
                        {
                            bool isPromoted = post.IsPostBoosted == "1" || post.SharedInfo.SharedInfoClass != null && post.SharedInfo.SharedInfoClass?.IsPostBoosted == "1";
                            if (isPromoted) //Promoted
                            {
                                combine.CombineDefaultPostSections("Top");
                            }
                            else
                            {
                                combine.CombineDefaultPostSections();
                            }
                        }

                        if (NativeFeedAdapter.ListDiffer.Count % AppSettings.ShowFbNativeAdsCount == 0 && NativeFeedAdapter.ListDiffer.Count > 0 && AppSettings.ShowFbNativeAds)
                        {
                            combiner.AddAdsPostView(PostModelType.FbAdNative);
                        }
                    }

                    if (add)
                    {
                        ActivityContext.RunOnUiThread(() =>
                        {
                            try
                            {
                                NativeFeedAdapter.NotifyItemRangeInserted(countList, NativeFeedAdapter.ListDiffer.Count - countList);
                                GC.Collect();
                            }
                            catch (Exception e)
                            {
                                Methods.DisplayReportResultTrack(e);
                            }
                        });
                    }

                    PostCacheList.RemoveRange(0, list.Count - 1);
                    ActivityContext.RunOnUiThread(ShowEmptyPage);

                    return(add);
                }

                return(false);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(false);
            }
        }
Пример #10
0
        public void LoadDataApi(int apiStatus, dynamic respond, string offset, string typeRun = "Add")
        {
            try
            {
                if (apiStatus != 200 || !(respond is PostObject result) || result.Data == null)
                {
                    WRecyclerView.MainScrollEvent.IsLoading = false;
                    Methods.DisplayReportResult(ActivityContext, respond);
                }
                else
                {
                    if (WRecyclerView.SwipeRefreshLayoutView != null && WRecyclerView.SwipeRefreshLayoutView.Refreshing)
                    {
                        WRecyclerView.SwipeRefreshLayoutView.Refreshing = false;
                    }

                    var countList = NativeFeedAdapter.ItemCount;
                    if (result.Data.Count > 0)
                    {
                        result.Data.RemoveAll(a => a.Publisher == null && a.UserData == null);

                        if (offset == "0" && countList > 10 && typeRun == "Insert" && NativeFeedAdapter.NativePostType == NativeFeedType.Global)
                        {
                            result.Data.Reverse();
                            bool add = false;

                            foreach (var post in from post in result.Data let check = NativeFeedAdapter.ListDiffer.FirstOrDefault(a => a?.PostData?.PostId == post.PostId && a.TypeView == PostFunctions.GetAdapterType(post)) where check == null select post)
                            {
                                add = true;
                                NativeFeedAdapter.NewPostList.Add(post);
                            }

                            ActivityContext.RunOnUiThread(() =>
                            {
                                try
                                {
                                    if (add && WRecyclerView.PopupBubbleView != null &&
                                        WRecyclerView.PopupBubbleView.Visibility != ViewStates.Visible &&
                                        AppSettings.ShowNewPostOnNewsFeed)
                                    {
                                        WRecyclerView.PopupBubbleView.Visibility = ViewStates.Visible;
                                    }
                                }
                                catch (Exception e)
                                {
                                    Methods.DisplayReportResultTrack(e);
                                }
                            });
                        }
                        else
                        {
                            bool add = false;
                            foreach (var post in from post in result.Data let check = NativeFeedAdapter.ListDiffer.FirstOrDefault(a => a?.PostData?.PostId == post.PostId && a?.TypeView == PostFunctions.GetAdapterType(post)) where check == null select post)
                            {
                                add = true;
                                var combiner = new FeedCombiner(null, NativeFeedAdapter.ListDiffer, ActivityContext);

                                if (NativeFeedAdapter.NativePostType == NativeFeedType.Global)
                                {
                                    if (result.Data.Count < 6 && NativeFeedAdapter.ListDiffer.Count < 6)
                                    {
                                        if (!ShowFindMoreAlert)
                                        {
                                            ShowFindMoreAlert = true;

                                            combiner.AddFindMoreAlertPostView("Pages");
                                            combiner.AddFindMoreAlertPostView("Groups");
                                        }
                                    }

                                    var check1 = NativeFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.SuggestedGroupsBox);
                                    if (check1 == null && AppSettings.ShowSuggestedGroup && NativeFeedAdapter.ListDiffer.Count > 0 && NativeFeedAdapter.ListDiffer.Count % AppSettings.ShowSuggestedGroupCount == 0 && ListUtils.SuggestedGroupList.Count > 0)
                                    {
                                        combiner.AddSuggestedBoxPostView(PostModelType.SuggestedGroupsBox);
                                    }

                                    var check2 = NativeFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.SuggestedUsersBox);
                                    if (check2 == null && AppSettings.ShowSuggestedUser && NativeFeedAdapter.ListDiffer.Count > 0 && NativeFeedAdapter.ListDiffer.Count % AppSettings.ShowSuggestedUserCount == 0 && ListUtils.SuggestedUserList.Count > 0)
                                    {
                                        combiner.AddSuggestedBoxPostView(PostModelType.SuggestedUsersBox);
                                    }
                                }

                                if (NativeFeedAdapter.ListDiffer.Count % AppSettings.ShowAdMobNativeCount == 0 && NativeFeedAdapter.ListDiffer.Count > 0 && AppSettings.ShowAdMobNativePost)
                                {
                                    switch (LastAdsType)
                                    {
                                    case PostModelType.AdMob1:
                                        LastAdsType = PostModelType.AdMob2;
                                        combiner.AddAdsPostView(PostModelType.AdMob1);
                                        break;

                                    case PostModelType.AdMob2:
                                        LastAdsType = PostModelType.AdMob3;
                                        combiner.AddAdsPostView(PostModelType.AdMob2);
                                        break;

                                    case PostModelType.AdMob3:
                                        LastAdsType = PostModelType.AdMob1;
                                        combiner.AddAdsPostView(PostModelType.AdMob3);
                                        break;
                                    }
                                }

                                var combine = new FeedCombiner(RegexFilterText(post), NativeFeedAdapter.ListDiffer, ActivityContext);
                                if (post.PostType == "ad")
                                {
                                    combine.AddAdsPost();
                                }
                                else
                                {
                                    bool isPromoted = post.IsPostBoosted == "1" || post.SharedInfo.SharedInfoClass != null && post.SharedInfo.SharedInfoClass?.IsPostBoosted == "1";
                                    if (isPromoted) //Promoted
                                    {
                                        combine.CombineDefaultPostSections("Top");
                                    }
                                    else
                                    {
                                        combine.CombineDefaultPostSections();
                                    }
                                }

                                if (NativeFeedAdapter.ListDiffer.Count % AppSettings.ShowFbNativeAdsCount == 0 && NativeFeedAdapter.ListDiffer.Count > 0 && AppSettings.ShowFbNativeAds)
                                {
                                    combiner.AddAdsPostView(PostModelType.FbAdNative);
                                }
                            }

                            if (add)
                            {
                                ActivityContext.RunOnUiThread(() =>
                                {
                                    try
                                    {
                                        NativeFeedAdapter.NotifyItemRangeInserted(countList, NativeFeedAdapter.ListDiffer.Count - countList);
                                        WRecyclerView.MainScrollEvent.IsLoading = false;
                                        GC.Collect();
                                    }
                                    catch (Exception e)
                                    {
                                        Methods.DisplayReportResultTrack(e);
                                    }
                                });
                            }

                            //else
                            //{
                            //    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_NoMorePost), ToastLength.Short)?.Show();
                            //}
                        }
                    }

                    ActivityContext.RunOnUiThread(ShowEmptyPage);

                    if (NativeFeedAdapter.NativePostType == NativeFeedType.Global)
                    {
                        WRecyclerView.DataPostJson = JsonConvert.SerializeObject(result);
                    }
                }

                WRecyclerView.MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                WRecyclerView.MainScrollEvent.IsLoading = false;
            }
        }