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); } }