private void SetRecyclerViewAdapters()
        {
            try
            {
                MAdapter = new LastActivitiesAdapter(Activity)
                {
                    LastActivitiesList = new ObservableCollection <ActivitiesObject.Activity>()
                };
                MAdapter.ItemClick += MAdapterOnItemClick;
                LayoutManager       = new LinearLayoutManager(Activity);
                MRecycler.SetLayoutManager(LayoutManager);
                MRecycler.HasFixedSize = true;
                MRecycler.SetItemViewCacheSize(10);
                MRecycler.GetLayoutManager().ItemPrefetchEnabled = true;
                var sizeProvider = new FixedPreloadSizeProvider(10, 10);
                var preLoader    = new RecyclerViewPreloader <ActivitiesObject.Activity>(Activity, MAdapter, sizeProvider, 8);
                MRecycler.AddOnScrollListener(preLoader);
                MRecycler.SetAdapter(MAdapter);

                EmptyStateLayout.Visibility = ViewStates.Gone;
                MRecycler.Visibility        = ViewStates.Visible;

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager);
                MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent;
                MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #2
0
        private void SetRecyclerViewAdapters()
        {
            try
            {
                MAdapter = new LastActivitiesAdapter(this)
                {
                    LastActivitiesList = new ObservableCollection <ActivityDataObject>()
                };

                LayoutManager = new LinearLayoutManager(this);
                MRecycler.SetLayoutManager(LayoutManager);
                MRecycler.HasFixedSize = true;
                MRecycler.SetItemViewCacheSize(10);
                MRecycler.GetLayoutManager().ItemPrefetchEnabled = true;
                var sizeProvider = new FixedPreloadSizeProvider(10, 10);
                var preLoader    = new RecyclerViewPreloader <ActivityDataObject>(this, MAdapter, sizeProvider, 10);
                MRecycler.AddOnScrollListener(preLoader);
                MRecycler.SetAdapter(MAdapter);

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager);
                MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent;
                MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private void SetRecyclerViewAdapters()
        {
            try
            {
                ProUserRecyclerView.NestedScrollingEnabled = false;
                PageRecyclerView.NestedScrollingEnabled    = false;

                GlobalContext.ProUsersAdapter = new ProUsersAdapter(Activity);
                GlobalContext.ProUsersAdapter.MProUsersList = new ObservableCollection <UserDataObject>();
                GlobalContext.ProUsersAdapter.ItemClick    += ProUsersAdapterOnItemClick;
                ProUserRecyclerView.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false));
                ProUserRecyclerView.SetAdapter(GlobalContext.ProUsersAdapter);
                ProUserRecyclerView.HasFixedSize = true;
                ProUserRecyclerView.SetItemViewCacheSize(10);
                ProUserRecyclerView.GetLayoutManager().ItemPrefetchEnabled = true;

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

                //============================= Last Activities Users ==================================
                MAdapter = new LastActivitiesAdapter(Activity)
                {
                    LastActivitiesList = new ObservableCollection <ActivityDataObject>(),
                };
                MAdapter.ItemClick += LastActivitiesAdapterOnItemClick;
                LayoutManager       = new LinearLayoutManager(Activity);
                LastActivitiesRecyclerView.SetLayoutManager(LayoutManager);
                LastActivitiesRecyclerView.HasFixedSize = true;
                LastActivitiesRecyclerView.SetItemViewCacheSize(10);
                LastActivitiesRecyclerView.GetLayoutManager().ItemPrefetchEnabled = true;
                var sizeProviderLastActivities = new FixedPreloadSizeProvider(10, 10);
                var preLoaderLastActivities    = new RecyclerViewPreloader <ActivityDataObject>(Activity, MAdapter, sizeProviderLastActivities, 10);
                LastActivitiesRecyclerView.AddOnScrollListener(preLoaderLastActivities);
                LastActivitiesRecyclerView.SetAdapter(MAdapter);

                //RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager);
                //MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                //MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent;
                //LastActivitiesRecyclerView.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                //MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Exemple #4
0
        private void DestroyBasic()
        {
            try
            {
                MAdView?.Destroy();

                MAdapter           = null;
                SwipeRefreshLayout = null;
                MRecycler          = null;
                EmptyStateLayout   = null;
                Inflated           = null;
                MainScrollEvent    = null;
                MAdView            = null;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #5
0
        private void DestroyBasic()
        {
            try
            {
                MAdView?.Destroy();

                MAdapter           = null !;
                SwipeRefreshLayout = null !;
                MRecycler          = null !;
                EmptyStateLayout   = null !;
                Inflated           = null !;
                MainScrollEvent    = null !;
                MAdView            = null !;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
 //Event Click Item last Activities and Open HyberdPostViewer_Activity >> Post
 private void LastActivitiesAdapter_OnItemClick(object sender,
                                                LastActivities_AdapterClickEventArgs adapterClickEvents)
 {
     try
     {
         var position = adapterClickEvents.Position;
         if (position >= 0)
         {
             var item = LastActivitiesAdapter.GetItem(position);
             if (item != null)
             {
                 var Int = new Intent(Context, typeof(HyberdPostViewer_Activity));
                 Int.PutExtra("Id", item.PostId);
                 Int.PutExtra("Type", "Post");
                 Int.PutExtra("Title", this.Context.GetString(Resource.String.Lbl_Post));
                 StartActivity(Int);
             }
         }
     }
     catch (Exception e)
     {
         Crashes.TrackError(e);
     }
 }
        //Api latest activities
        public async void Get_Activities()
        {
            try
            {
                if (!IMethods.CheckConnectivity())
                {
                    Toast.MakeText(Context, GetString(Resource.String.Lbl_CheckYourInternetConnection),
                                   ToastLength.Short).Show();
                    LastActivitiesRecyclerView.Visibility       = ViewStates.Gone;
                    layout_SuggestionlLastactivities.Visibility = ViewStates.Gone;
                }
                else
                {
                    var(Api_status, Respond) = await Client.Global.Get_Activities();

                    if (Api_status == 200)
                    {
                        if (Respond is Activities_Object result)
                        {
                            this.Activity.RunOnUiThread(() =>
                            {
                                if (result.Activities.Count > 0)
                                {
                                    //Bring new groups
                                    var listnew = result.Activities.Where(c =>
                                                                          !LastActivitiesAdapter.mLastActivitiesList.Select(fc => fc.Id).Contains(c.Id))
                                                  .ToList();
                                    if (listnew.Count > 0)
                                    {
                                        //Results differ
                                        Classes.AddRange(LastActivitiesAdapter.mLastActivitiesList, listnew);
                                        LastActivitiesAdapter.BindEnd();
                                    }
                                    else
                                    {
                                        LastActivitiesAdapter.mLastActivitiesList =
                                            new ObservableCollection <Activities_Object.Activity>(result.Activities);
                                        LastActivitiesAdapter.BindEnd();
                                    }
                                }
                                else
                                {
                                    LastActivitiesAdapter.mLastActivitiesList =
                                        new ObservableCollection <Activities_Object.Activity>(result.Activities);
                                    LastActivitiesAdapter.BindEnd();
                                }
                            });
                        }
                    }
                    else if (Api_status == 400)
                    {
                        if (Respond is Error_Object error)
                        {
                            var errortext = error._errors.Error_text;
                            //Toast.MakeText(this.Context, errortext, ToastLength.Short).Show();

                            if (errortext.Contains("Invalid or expired access_token"))
                            {
                                API_Request.Logout(Activity);
                            }
                        }
                    }
                    else if (Api_status == 404)
                    {
                        var error = Respond.ToString();
                        //Toast.MakeText(this.Context, error, ToastLength.Short).Show();
                    }

                    this.Activity.RunOnUiThread(() =>
                    {
                        if (LastActivitiesAdapter.mLastActivitiesList.Count > 0)
                        {
                            LastActivitiesRecyclerView.Visibility       = ViewStates.Visible;
                            layout_SuggestionlLastactivities.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            LastActivitiesRecyclerView.Visibility       = ViewStates.Gone;
                            layout_SuggestionlLastactivities.Visibility = ViewStates.Gone;
                        }
                    });
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
                Get_Activities();
            }
        }