Пример #1
0
        private void GetProducts()
        {
            Category    = items[items.Count - 1].CategoryID;
            SubCategory = items[items.Count - 1].SubCategoryID;
            ProductID   = items[items.Count - 1].ProductID;

            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.GetSingleItem(Category, SubCategory, ProductID, database);
            p.GetProduct += (sender, obj) =>
            {
                if (mAdapter != null && mAdapter.Product.Count > 0)
                {
                    mAdapter.AddList(obj);
                }
                else
                {
                    mAdapter = new Product_Adapter(this, obj, this);
                    mRecyclerView.SetAdapter(mAdapter);
                }

                items.RemoveAt(items.Count - 1);

                GetProducts();

                if (items.Count == 0)
                {
                }
            };
        }
Пример #2
0
        private void GetProducts()
        {
            var mPageLimit            = 10;
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            if (sorted)
            {
                p.GetProducts(Category, SubCategory, mPageOffset, mPageLimit, sortByAsc, database);
            }
            else
            {
                p.GetProducts(Category, SubCategory, mPageOffset, mPageLimit, database);
            }

            p.GetProduct += (sender, obj) =>
            {
                mPageOffset = mPageOffset + mPageLimit;
                mLoaderEffect.Visibility = ViewStates.Gone;
                mLoaderEffect.HideShimmerAdapter();
                if (Adapter != null && Adapter.Product.Count > 0)
                {
                    Adapter.AddList(obj);
                }
                else
                {
                    Adapter = new Product_Adapter(this, obj, this);
                    recyclerView.SetAdapter(Adapter);
                }
                LastLoad = obj.Count;
                onScrollListener.IsLoading = false;
                HideShowProgress();
            };
        }
Пример #3
0
        private void SeachProducts(string query, string category, string subcategory, string offset)
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.SearchProducts(query.ToLower(), category, subcategory, offset, database);
            p.GetProduct += (sender, obj) =>
            {
                LastCount = obj.Count;
                if (obj.Count > 0)
                {
                    SearchOffset = obj[obj.Count - 1].sort_name;
                    if (Adapter != null && Adapter.Product.Count > 0)
                    {
                        Adapter.AddList(obj);
                    }
                    else
                    {
                        Adapter = new Product_Adapter(this, obj, this);
                        recyclerView.SetAdapter(Adapter);
                    }

                    onScrollListener.IsLoading = false;
                    HideShowProgress();
                    SearchOffset = obj[obj.Count - 1].sort_name;
                }
                else if (LastCount < 10 && !IsSearchCompleted)
                {
                    maxIndex++;
                    search?.Invoke(this, null);
                }
            };
        }
Пример #4
0
 public override void OnBackPressed()
 {
     if (CurrentMode == APIMode.Search)
     {
         Adapter.Clear();
         Adapter = null;
         GetProducts();
         SupportActionBar.Title = CategoryTitle;
         CurrentMode            = APIMode.Direct;
     }
     else
     {
         base.OnBackPressed();
     }
 }
Пример #5
0
        private void SeachProducts(string query, string offset)
        {
            //Clear adapter
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.SearchProducts(query.ToLower(), Category, SubCategory, offset, database);
            p.GetProduct += (sender, obj) =>
            {
                if (obj.Count > 0)
                {
                    if (Adapter != null && Adapter.Product.Count > 0)
                    {
                        Adapter.AddList(obj);
                    }
                    else
                    {
                        Adapter = new Product_Adapter(this, obj, this);
                        recyclerView.SetAdapter(Adapter);
                    }
                    onScrollListener.IsLoading = false;
                    HideShowProgress();
                    SearchOffset = obj[obj.Count - 1].sort_name;
                }
                else if (Adapter.Product.Count == 0)
                {
                    onScrollListener.IsLoading = false;
                    HideShowProgress();
                    var builder = new Android.App.AlertDialog.Builder(this);
                    builder.SetTitle(Resource.String.dlg_info);
                    builder.SetMessage(Resource.String.info_nomatch_result);
                    builder.SetPositiveButton(Resource.String.dialog_ok, delegate
                    {
                        builder.Dispose();
                    });
                    builder.Show();
                }
                else
                {
                    onScrollListener.IsLoading = false;
                    HideShowProgress();
                }
                LastLoad = obj.Count;
            };
        }
Пример #6
0
        private void ChangeLayout(RecyclerView _recyclerView)
        {
            if (Adapter != null && Adapter.ItemCount > 0)
            {
                int scrollPosition = 0;
                LinearLayoutManager mLayoutManager;
                // If a layout manager has already been set, get current scroll position.
                if (_recyclerView.GetLayoutManager() != null)
                {
                    scrollPosition = ((LinearLayoutManager)_recyclerView.GetLayoutManager())
                                     .FindFirstCompletelyVisibleItemPosition();
                }

                switch (mCurrentLayoutManagerType)
                {
                case MyEnum.ListView:
                    mLayoutManager            = new LinearLayoutManager(this);
                    mCurrentLayoutManagerType = MyEnum.Thumbnail;
                    ChangeMenuIconToThumbnail();
                    _recyclerView.SetLayoutManager(mLayoutManager);
                    onScrollListener = new XamarinRecyclerViewOnScrollListener(mLayoutManager);
                    break;

                case MyEnum.Thumbnail:
                    var mGridLayoutManager = new GridLayoutManager(this, 2, GridLayoutManager.Vertical, false);
                    mCurrentLayoutManagerType = MyEnum.GridView;
                    ChangeMenuIconToList();
                    _recyclerView.SetLayoutManager(mGridLayoutManager);
                    onScrollListener = new XamarinRecyclerViewOnScrollListener(mGridLayoutManager);
                    break;

                case MyEnum.GridView:
                    mLayoutManager            = new LinearLayoutManager(this);
                    mCurrentLayoutManagerType = MyEnum.ListView;
                    ChangeMenuIconToList();
                    _recyclerView.SetLayoutManager(mLayoutManager);
                    onScrollListener = new XamarinRecyclerViewOnScrollListener(mLayoutManager);
                    break;

                default:
                    mLayoutManager            = new LinearLayoutManager(this);
                    mCurrentLayoutManagerType = MyEnum.ListView;
                    ChangeMenuIconToList();
                    _recyclerView.SetLayoutManager(mLayoutManager);
                    onScrollListener = new XamarinRecyclerViewOnScrollListener(mLayoutManager);
                    break;
                }

                Adapter = new Product_Adapter(this, Adapter.Product, this);
                Adapter.SetLayoutManager(mCurrentLayoutManagerType);

                _recyclerView.SetAdapter(Adapter);
                _recyclerView.ScrollToPosition(scrollPosition);
                recyclerView.RemoveOnScrollListener(onScrollListener);


                onScrollListener.LoadMoreEvent += OnScrollListener_LoadMoreEventAsync;
                onScrollListener.OnHide        += OnScrollListener_OnHide;
                onScrollListener.OnShow        += OnScrollListener_OnShow;
                recyclerView.AddOnScrollListener(onScrollListener);

                //Decorate Recyclerview
                if (mCurrentLayoutManagerType == MyEnum.GridView)
                {
                    _recyclerView.AddItemDecoration(verticalDecoration);
                }
                else
                {
                    _recyclerView.AddItemDecoration(verticalDecoration);
                }
            }
        }