Ejemplo n.º 1
0
        private void LoadPost()
        {
            try
            {
                var combiner = new FeedCombiner(null, PostFeedAdapter.ListDiffer, Activity);

                combiner.AddStoryPostView();
                combiner.AddPostBoxPostView("feed", -1);
                combiner.AddGreetingAlertPostView();

                if (PostFeedAdapter.ListDiffer.Count <= 5)
                {
                    StartApiService();
                }
                else
                {
                    var item = PostFeedAdapter.ListDiffer.LastOrDefault();

                    var lastItem = PostFeedAdapter.ListDiffer.IndexOf(item);

                    item = PostFeedAdapter.ListDiffer[lastItem];

                    string offset;
                    if (item.TypeView == PostModelType.Divider || item.TypeView == PostModelType.ViewProgress || item.TypeView == PostModelType.AdMob1 || item.TypeView == PostModelType.AdMob2 || item.TypeView == PostModelType.FbAdNative || item.TypeView == PostModelType.AdsPost || item.TypeView == PostModelType.SuggestedGroupsBox || item.TypeView == PostModelType.SuggestedUsersBox || item.TypeView == PostModelType.CommentSection || item.TypeView == PostModelType.AddCommentSection)
                    {
                        item   = PostFeedAdapter.ListDiffer.LastOrDefault(a => a.TypeView != PostModelType.Divider && a.TypeView != PostModelType.ViewProgress && a.TypeView != PostModelType.AdMob1 && a.TypeView != PostModelType.AdMob2 && a.TypeView != PostModelType.FbAdNative && a.TypeView != PostModelType.AdsPost && a.TypeView != PostModelType.SuggestedGroupsBox && a.TypeView != PostModelType.SuggestedUsersBox && a.TypeView != PostModelType.CommentSection && a.TypeView != PostModelType.AddCommentSection);
                        offset = item?.PostData?.Id ?? "0";
                        Console.WriteLine(offset);
                    }
                    else
                    {
                        offset = item.PostData?.Id ?? "0";
                    }

                    StartApiService(offset);
                }

                //Start Updating the news feed every few minus
                MainHandler.PostDelayed(new ApiPostUpdaterHelper(Activity, MainRecyclerView, MainHandler), 30000);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 2
0
        private void LoadPost()
        {
            try
            {
                var combiner = new FeedCombiner(null, PostFeedAdapter.ListDiffer, Activity);

                combiner.AddStoryPostView();
                combiner.AddPostBoxPostView("feed", -1);
                combiner.AddGreetingAlertPostView();

                if (PostFeedAdapter.ListDiffer.Count <= 5)
                {
                    StartApiService();
                }
                else
                {
                    var item = PostFeedAdapter.ListDiffer.LastOrDefault();

                    var lastItem = PostFeedAdapter.ListDiffer.IndexOf(item);

                    item = PostFeedAdapter.ListDiffer[lastItem];

                    string offset;
                    if (item.TypeView == PostModelType.AdMob || item.TypeView == PostModelType.FbAdNative || item.TypeView == PostModelType.AdsPost || item.TypeView == PostModelType.SuggestedGroupsBox || item.TypeView == PostModelType.SuggestedUsersBox)
                    {
                        item   = PostFeedAdapter.ListDiffer.LastOrDefault(a => a.PostData != null && a.TypeView != PostModelType.AdMob && a.TypeView != PostModelType.FbAdNative && a.TypeView != PostModelType.AdsPost && a.TypeView != PostModelType.SuggestedGroupsBox && a.TypeView != PostModelType.SuggestedUsersBox);
                        offset = item?.PostData?.Id ?? "0";
                        Console.WriteLine(offset);
                    }
                    else
                    {
                        offset = item.PostData?.Id ?? "0";
                    }

                    StartApiService(offset);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public void LoadPost(bool local)
        {
            try
            {
                var combiner = new FeedCombiner(null, PostFeedAdapter.ListDiffer, Activity);

                //combiner.AddStoryPostView();
                combiner.AddPostBoxPostView("feed", -1);

                switch (AppSettings.ShowStory)
                {
                case true:
                    combiner.AddStoryPostView("feed", -1);
                    break;
                }

                switch (local)
                {
                case true:
                    combiner.AddGreetingAlertPostView();
                    break;
                }

                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                var            json       = dbDatabase.GetDataPost();

                switch (string.IsNullOrEmpty(json))
                {
                case false when local:
                {
                    var postObject = JsonConvert.DeserializeObject <PostObject>(json);
                    switch (postObject?.Data.Count)
                    {
                    case > 0:
                        MainRecyclerView.ApiPostAsync.LoadDataApi(postObject.Status, postObject, "0");
                        MainRecyclerView.ScrollToPosition(0);
                        break;
                    }

                    //Start Updating the news feed every few minus
                    StartApiService();
                    StartHandler();
                    return;
                }
                }

                switch (PostFeedAdapter.ListDiffer.Count)
                {
                case <= 5:
                    StartApiService();
                    break;

                default:
                {
                    var item = PostFeedAdapter.ListDiffer.LastOrDefault();

                    var lastItem = PostFeedAdapter.ListDiffer.IndexOf(item);

                    item = PostFeedAdapter.ListDiffer[lastItem];

                    string offset;
                    switch (item.TypeView)
                    {
                    case PostModelType.Divider:
                    case PostModelType.ViewProgress:
                    case PostModelType.AdMob1:
                    case PostModelType.AdMob2:
                    case PostModelType.AdMob3:
                    case PostModelType.FbAdNative:
                    case PostModelType.AdsPost:
                    case PostModelType.SuggestedGroupsBox:
                    case PostModelType.SuggestedUsersBox:
                    case PostModelType.CommentSection:
                    case PostModelType.AddCommentSection:
                        item   = PostFeedAdapter.ListDiffer.LastOrDefault(a => a.TypeView != PostModelType.Divider && a.TypeView != PostModelType.ViewProgress && a.TypeView != PostModelType.AdMob1 && a.TypeView != PostModelType.AdMob2 && a.TypeView != PostModelType.AdMob3 && a.TypeView != PostModelType.FbAdNative && a.TypeView != PostModelType.AdsPost && a.TypeView != PostModelType.SuggestedGroupsBox && a.TypeView != PostModelType.SuggestedUsersBox && a.TypeView != PostModelType.CommentSection && a.TypeView != PostModelType.AddCommentSection);
                        offset = item?.PostData?.PostId ?? "0";
                        Console.WriteLine(offset);
                        break;

                    default:
                        offset = item.PostData?.PostId ?? "0";
                        break;
                    }

                    StartApiService(offset, "Insert");
                    break;
                }
                }

                //Start Updating the news feed every few minus
                StartHandler();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Ejemplo n.º 4
0
        public void LoadPost(bool local)
        {
            try
            {
                var combiner = new FeedCombiner(null, PostFeedAdapter.ListDiffer, Activity);

                combiner.AddStoryPostView();
                combiner.AddPostBoxPostView("feed", -1);
                if (local)
                {
                    combiner.AddGreetingAlertPostView();
                }

                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                var            json       = dbDatabase.GetDataPost();
                if (!string.IsNullOrEmpty(json) && local)
                {
                    var postObject = JsonConvert.DeserializeObject <PostObject>(json);
                    if (postObject?.Data.Count > 0)
                    {
                        MainRecyclerView.LoadDataApi(postObject.Status, postObject, "0");

                        StartApiService("0", "Insert");
                    }
                    dbDatabase.Dispose();
                    //Start Updating the news feed every few minus
                    StartHandler();
                    return;
                }
                else
                {
                    if (PostFeedAdapter.ListDiffer.Count <= 5)
                    {
                        StartApiService();
                    }
                    else
                    {
                        var item = PostFeedAdapter.ListDiffer.LastOrDefault();

                        var lastItem = PostFeedAdapter.ListDiffer.IndexOf(item);

                        item = PostFeedAdapter.ListDiffer[lastItem];

                        string offset;
                        if (item.TypeView == PostModelType.Divider || item.TypeView == PostModelType.ViewProgress || item.TypeView == PostModelType.AdMob1 || item.TypeView == PostModelType.AdMob2 || item.TypeView == PostModelType.FbAdNative || item.TypeView == PostModelType.AdsPost || item.TypeView == PostModelType.SuggestedGroupsBox || item.TypeView == PostModelType.SuggestedUsersBox || item.TypeView == PostModelType.CommentSection || item.TypeView == PostModelType.AddCommentSection)
                        {
                            item   = PostFeedAdapter.ListDiffer.LastOrDefault(a => a.TypeView != PostModelType.Divider && a.TypeView != PostModelType.ViewProgress && a.TypeView != PostModelType.AdMob1 && a.TypeView != PostModelType.AdMob2 && a.TypeView != PostModelType.FbAdNative && a.TypeView != PostModelType.AdsPost && a.TypeView != PostModelType.SuggestedGroupsBox && a.TypeView != PostModelType.SuggestedUsersBox && a.TypeView != PostModelType.CommentSection && a.TypeView != PostModelType.AddCommentSection);
                            offset = item?.PostData?.Id ?? "0";
                            Console.WriteLine(offset);
                        }
                        else
                        {
                            offset = item.PostData?.Id ?? "0";
                        }

                        StartApiService(offset, "Insert");
                    }
                }

                //Start Updating the news feed every few minus
                StartHandler();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }