Exemplo n.º 1
0
        private void GetPending(string purchasesID)
        {
            int mPageLimit            = 6;
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.GetPurchased(database, UserID, purchasesID);
            p.GetProduct += (sender, obj) =>
            {
                mPageOffset = mPageOffset + mPageLimit;
                if (obj.Count > 0)
                {
                    obj.RemoveAll(x => x.Paid == true);
                }
                else
                {
                    mLoaderContent.Visibility = ViewStates.Visible;
                    return;
                }

                if (Adapter != null && Adapter.Product.Count > 0)
                {
                    Adapter.AddList(obj);
                }
                else
                {
                    Adapter = new PendingAdapter(Activity, obj);
                    recyclerView.SetAdapter(Adapter);
                }

                onScrollListener.IsLoading = false;
                HideShowProgress();
            };
        }
Exemplo n.º 2
0
        private void GetProducts(string purchasesID)
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.GetPurchased(database, UserID, purchasesID);
            p.GetProduct += (sender, obj) =>
            {
                if (obj.Count > 0)
                {
                    foreach (var item in obj)
                    {
                        item.Date = purchases[CurrentIndex].Date;
                    }

                    if (Adapter != null && Adapter.Purchases.Count > 0)
                    {
                        Adapter.AddList(obj);
                    }
                    else
                    {
                        Adapter = new Purchases_Adapter(Activity, obj);
                        recyclerView.SetAdapter(Adapter);
                    }
                }
                else
                {
                    progressBar.Visibility    = ViewStates.Gone;
                    mLoaderContent.Visibility = ViewStates.Visible;
                    return;
                }

                if (Adapter.ItemCount < 5)
                {
                    onScrollListener.IsLoading = true;
                    HideShowProgress();

                    CurrentIndex++;
                    if (CurrentIndex < purchases.Count)
                    {
                        GetProducts(purchases[CurrentIndex].PurchasesID);
                    }
                }
                else
                {
                    onScrollListener.IsLoading = false;
                    HideShowProgress();
                }

                if (CurrentIndex == purchases.Count - 1)
                {
                    recyclerView.RemoveOnScrollListener(onScrollListener);
                    progressBar.Visibility = ViewStates.Gone;
                }
            };
        }