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 GetReviews()
        {
            int mPageLimit            = 10;
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.GetReview(database, mPageLimit, mPageOffset);
            p.Reviews += (sender, obj) =>
            {
                progressBar.Visibility = ViewStates.Invisible;
                mPageOffset            = mPageOffset + mPageLimit;

                if (mAdapter != null && mAdapter.reviews.Count > 0)
                {
                    mAdapter.reviews.Clear();
                    mAdapter.AddList(obj);
                }
                else
                {
                    mAdapter = new Review_Adapter(this, obj);
                    mRecyclerView.SetAdapter(mAdapter);
                }
                LastLoad = obj.Count;
                onScrollListener.IsLoading = false;
                HideShowProgress();
            };
        }
Exemplo n.º 3
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)
                {
                }
            };
        }
Exemplo n.º 4
0
        private void UserWishList()
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.Wishlist(UserID, database);
            p.MyWishLish += (o, s) =>
            {
                myList = s;

                if (myList.Count > 0)
                {
                    LoadingSkeleton.SetDemoChildCount(myList.Count);
                    CategoryID    = myList[myList.Count - 1].CategoryID;
                    SubCategoryID = myList[myList.Count - 1].SubCategoryID;
                    ProductID     = myList[myList.Count - 1].ProductID;
                    GetWishList(CategoryID, SubCategoryID, ProductID);
                    myList.RemoveAt(myList.Count - 1);
                }
                else
                {
                    LoadingSkeleton.HideShimmerAdapter();
                    LoadingSkeleton.Visibility = ViewStates.Gone;
                }
            };
        }
Exemplo n.º 5
0
        private void GetCategories()
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.GetCategoriesAll(database);
            p.Categories += (sender, obj) =>
            {
                progressBar.Visibility = ViewStates.Invisible;

                objCategories = obj;
                Adapter       = new Category_Adapter(this, obj);
                recyclerView.SetAdapter(Adapter);
                Adapter.ItemClick += (s, o) =>
                {
                    p.Dispose();
                    database.Dispose();

                    Intent intent = new Intent(this, typeof(Activity_SubCategory));
                    ActivityOptionsCompat option = ActivityOptionsCompat.MakeSceneTransitionAnimation(this);
                    intent.PutExtra("CategoryID", Adapter.category[o].CategoryID);
                    intent.PutExtra("Category", Adapter.category[o].Category);
                    intent.PutExtra("Translation", Adapter.category[o].Translation);

                    StartActivity(intent, option.ToBundle());
                };
            };
        }
Exemplo n.º 6
0
        private void GetRecentlyPurchases(string purchasesID)
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

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

                    Adapter = new Purchases_Adapter(Activity, obj);
                    recyclerView.SetAdapter(Adapter);
                }
                else
                {
                    recyclerView.RemoveOnScrollListener(onScrollListener);
                    mLoaderContent.Visibility = ViewStates.Visible;
                    return;
                }


                onScrollListener.IsLoading = false;
                HideShowProgress();
            };
        }
Exemplo n.º 7
0
        private void GetCategories()
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;

            FirebaseCallback p = new FirebaseCallback();

            p.GetSubCategories(Selected, database);
            p.SubCategories += (sender, obj) =>
            {
                objCategories        = obj;
                mProgress.Visibility = ViewStates.Gone;
                mCatAdapter          = new SubCategory_Adapters(ApplicationContext, obj);
                recyclerView.SetAdapter(mCatAdapter);
                mCatAdapter.ItemClick += (s, o) =>
                {
                    ActivityOptionsCompat option = ActivityOptionsCompat.MakeSceneTransitionAnimation(this);
                    Intent intent = new Intent(this, typeof(ShoppingActivity));
                    intent.PutExtra("CategoryID", mCatAdapter.category[o].CategoryID);
                    intent.PutExtra("Category", mCatAdapter.category[o].SubCategory);
                    intent.PutExtra("Translation", mCatAdapter.category[o].Translation);

                    intent.PutExtra("SubCategory", mCatAdapter.category[o].SubCategoryID);
                    StartActivity(intent, option.ToBundle());
                };
            };
        }
Exemplo n.º 8
0
        private void CheckLastPurchases()
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.CheckPaiedPurchased(database, UserID);
            p.lastPurch += (o, data) =>
            {
                purchases = data;
                if (purchases.Count > 0)
                {
                    purchases.Reverse(0, purchases.Count);

                    purchasesID = purchases[0].PurchasesID;
                    GetRecentlyPurchases(data[0].PurchasesID);
                    mBtnView.Visibility = ViewStates.Visible;
                }
                else
                {
                    mBtnView.Visibility       = ViewStates.Gone;
                    progressBar.Visibility    = ViewStates.Gone;
                    mLoaderContent.Visibility = ViewStates.Visible;
                }
            };
        }
Exemplo n.º 9
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();
            };
        }
Exemplo n.º 10
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);
                }
            };
        }
Exemplo n.º 11
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;
                }
            };
        }
Exemplo n.º 12
0
        private void Update(User user)
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.UpdateUserAccount(database, user);
            SaveUserData(user);

            Snackbar.Make(FindViewById(Android.Resource.Id.Content), "Saved Completed! ",
                          Snackbar.LengthShort).Show();
        }
Exemplo n.º 13
0
        private void GetSubCategories()
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.GetAllSubCategories(database);
            p.SubCategories += (sender, obj) =>
            {
                SubCategory = obj;
                search?.Invoke(this, null);
            };
        }
Exemplo n.º 14
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;
            };
        }
Exemplo n.º 15
0
        private void PostReview()
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            var review = new Reviews
            {
                User      = Username,
                UserID    = UserID,
                Review    = mReview.Text,
                Post_Date = DateTime.Now.ToShortDateString()
            };

            p.PostAppReview(database, review);
            var text = Resources.GetString(Resource.String.snk_thanks_feedback);

            Snackbar.Make(FindViewById(Android.Resource.Id.Content), text, Snackbar.LengthShort).Show();
        }
Exemplo n.º 16
0
 public void GetListTopUpdating(string path, int count, FirebaseCallback callback)
 {
     try {
         FirebaseDatabase.DefaultInstance
         .GetReference(path).LimitToLast(count)
         .ValueChanged += (object sender2, ValueChangedEventArgs e2) => {
             if (e2.DatabaseError != null)
             {
                 Debug.LogError(e2.DatabaseError.Message);
                 callback(null);
             }
             else
             {
                 callback(e2.Snapshot);
             }
         };
     }  catch (System.Exception ex) {
         Debug.Log("Firebase: " + ex);
     }
 }
Exemplo n.º 17
0
        private void CheckLastPurchases()
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.CheckPendingPurchased(database, UserID);
            p.lastPurch += (o, data) =>
            {
                if (data.Count > 0)
                {
                    purchasesID = data[0].PurchasesID;
                    GetPending(data[0].PurchasesID);
                }
                else
                {
                    progressBar.Visibility    = ViewStates.Gone;
                    mLoaderContent.Visibility = ViewStates.Visible;
                }
            };
        }
Exemplo n.º 18
0
        private void DirectPurchasing(Products p, User S)
        {
            string           purchasesID = string.Empty;
            FirebaseDatabase database    = FirebaseDatabase.Instance;
            FirebaseCallback firebase    = new FirebaseCallback();
            var myRef = database.Reference;

            if (S == null)
            {
                purchasesID = myRef.Push().Key;
            }
            else
            {
                purchasesID = S.PurchasesID;
            }


            //Insert transaction required
            var json = JsonConvert.SerializeObject(p);

            var jsonObject2 = new Purchases();

            jsonObject2.PurchasesID = purchasesID;
            jsonObject2.UserID      = UserID;

            p.Selected_Size = selected_size;
            p.Qty           = qty;
            var json2 = JsonConvert.SerializeObject(p);
            var json1 = JsonConvert.SerializeObject(jsonObject2);

            ActivityOptionsCompat option = ActivityOptionsCompat.MakeSceneTransitionAnimation(this);
            Intent i = new Intent(this, typeof(ShippingDetails));

            i.PutExtra("products", json2);
            i.PutExtra("transaction", json1);
            //i.PutExtra("from", "cart");

            StartActivity(i, option.ToBundle());
        }
Exemplo n.º 19
0
        private void CheckLastPurchases()
        {
            progressDialog = new ProgressDialog(this);
            progressDialog.SetMessage(Resources.GetString(Resource.String.prgdlg));
            progressDialog.SetCanceledOnTouchOutside(false);
            progressDialog.SetCancelable(false);
            progressDialog.Show();

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

            p.CheckPendingPurchased(database, UserID);
            p.lastPurch += (o, data) =>
            {
                progressDialog.Hide();
                if (data.Count > 0)
                {
                    LastPurchases = data;
                    var builder = new Android.App.AlertDialog.Builder(this);
                    builder.SetTitle(Resource.String.dlg_info);
                    builder.SetMessage(Resource.String.dlg_purchases_info);
                    builder.SetPositiveButton(Resource.String.dlg_btn_continue, delegate
                    {
                        builder.Dispose();
                        DirectPurchasing(products, LastPurchases[0]);
                    });
                    builder.SetNegativeButton(Resource.String.dialog_cancel, delegate
                    {
                        builder.Dispose();
                    });

                    builder.Show();
                }
                else
                {
                    DirectPurchasing(products, null);
                }
            };
        }
Exemplo n.º 20
0
        private void LoginUser(string phoneNumber)
        {
            FirebaseDatabase database = FirebaseDatabase.Instance;
            FirebaseCallback p        = new FirebaseCallback();

            p.LoginUserAsync(database, phoneNumber);
            p._Auth += (sender, obj) =>
            {
                Progress.Hide();
                if (!string.IsNullOrEmpty(obj.UserID))
                {
                    SaveUserData(obj);
                    ActivityOptionsCompat option = ActivityOptionsCompat.MakeSceneTransitionAnimation(Activity);
                    Intent intent = new Intent(Activity, typeof(MainActivity));
                    StartActivity(intent);
                }
                else
                {
                    LoginFailAlertDialog();
                }
            };
        }
Exemplo n.º 21
0
        private void checkUsedNumber(string phone)
        {
            FirebaseDatabase fb   = FirebaseDatabase.Instance;
            FirebaseCallback call = new FirebaseCallback();

            call.CheckUsedNumber(fb, phone);
            call.IsReady += (o, s) =>
            {
                if (s)
                {
                }
                else
                {
                    var builder = new AlertDialog.Builder(Activity);
                    builder.SetTitle(Resource.String.dlg_info);
                    builder.SetMessage(Resource.String.title_used_number);
                    builder.SetPositiveButton(Resource.String.dialog_ok, delegate
                    {
                        builder.Dispose();
                    });
                    builder.Show();
                }
            };
        }
Exemplo n.º 22
0
        private void CreateAccount(User S)
        {
            var progress = new ProgressDialog(Activity);

            progress.SetMessage(Resources.GetString(Resource.String.tilte_connecting));
            progress.SetCanceledOnTouchOutside(false);
            progress.Show();

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

            u.LoginUserAsync(database, S.PhoneNumber);
            u._Auth += (o, data) =>
            {
                if (!string.IsNullOrEmpty(data.PhoneNumber))
                {
                    progress.Hide();
                    RegFailAlertDialog();
                }
                else
                {
                    p.CreateUserAsync(database, S);
                    p._Auth += (sender, obj) =>
                    {
                        progress.Hide();
                        if (!string.IsNullOrEmpty(obj.UserID))
                        {
                            SaveUserData(obj);
                            Intent I = new Intent(Context, typeof(MainActivity));
                            StartActivity(I);
                        }
                    };
                }
            };
        }
Exemplo n.º 23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _lang  = app.GetString("Language", "en");
            UserID = app.GetString("USERID", string.Empty);

            ChangeLanguage(_lang);

            base.OnCreate(savedInstanceState);
            Slide   slide   = new Slide(GravityFlags.Top);
            Explode explode = new Explode();

            Window.EnterTransition = slide;
            Window.ExitTransition  = explode;


            // Create your application here
            SetContentView(Resource.Layout.mycart);

            mToolbar     = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolBar);
            recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            btnBuy       = FindViewById <Button>(Resource.Id.btnBuy);
            mTotalAmount = FindViewById <TextView>(Resource.Id.txtTotalPrice);
            txtOff       = FindViewById <TextView>(Resource.Id.txtOff);
            txtNothing   = FindViewById <TextView>(Resource.Id.txtNothing);


            SetSupportActionBar(mToolbar);
            SupportActionBar ab = SupportActionBar;

            ab.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.Title = "";

            BindCartsToRecycler(recyclerView, GetCartSqlLite());
            if (Adapter != null && Adapter.MyCarts.Count > 0)
            {
                Calculate_Total_Amount();
            }
            btnBuy.Click += (o, e) =>
            {
                if (GetCartSqlLite().Count > 0)
                {
                    var progressDialog = new ProgressDialog(this);
                    progressDialog.SetCanceledOnTouchOutside(false);
                    progressDialog.SetMessage(Resources.GetString(Resource.String.prgdlg));
                    progressDialog.Show();

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

                    firebase.CheckIfCanBuy(database);
                    firebase.IsReady += (b, s) =>
                    {
                        progressDialog.Hide();
                        if (!s)
                        {
                            var builder = new Android.App.AlertDialog.Builder(this);
                            builder.SetTitle(Resource.String.dlg_info);
                            builder.SetMessage(Resource.String.dlg_service_not_ready);
                            builder.SetPositiveButton(Resource.String.dialog_ok, delegate
                            {
                                builder.Dispose();
                            });
                            builder.Show();
                        }
                        else
                        {
                            CheckLastPurchases();
                        }
                    };
                }
            };
        }