protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base);

                Methods.App.FullScreenApp(this);

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

                Instance = this;

                //Get Value And Set Toolbar
                InitComponent();
                InitToolbar();
                SetRecyclerViewAdapters();

                StartApiService();

                RewardedVideo = AdsFacebook.InitRewardVideo(this);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void DestroyBasic()
        {
            try
            {
                MAdView?.Destroy();
                RewardedVideo?.Destroy();

                MAdapter           = null !;
                SwipeRefreshLayout = null !;
                MRecycler          = null !;
                EmptyStateLayout   = null !;
                Inflated           = null !;
                MainScrollEvent    = null !;
                MAdView            = null !;
                Instance           = null !;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private void DestroyBasic()
        {
            try
            {
                MAdView?.Destroy();
                RewardedVideo?.Destroy();

                MAdapter           = null;
                SwipeRefreshLayout = null;
                MRecycler          = null;
                EmptyStateLayout   = null;
                Inflated           = null;
                MainScrollEvent    = null;
                MAdView            = null;
                Instance           = null;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 4
0
        private async void TxtSaveOnClick(object sender, EventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (string.IsNullOrEmpty(TxtDiscountType.Text) || string.IsNullOrEmpty(TxtDiscountItems.Text) || string.IsNullOrEmpty(TxtCurrency.Text) ||
                        string.IsNullOrEmpty(TxtDescription.Text))
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_your_data), ToastLength.Short).Show();
                        return;
                    }

                    //Show a progress
                    AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                    OfferObject newInfoObject = new OfferObject()
                    {
                        Id              = OfferId,
                        DiscountType    = AddDiscountId,
                        Currency        = CurrencyId,
                        ExpireDate      = TxtDate.Text,
                        Time            = TxtTime.Text,
                        Description     = TxtDescription.Text,
                        DiscountedItems = TxtDiscountItems.Text,
                    };

                    var dictionary = new Dictionary <string, string>
                    {
                        { "discount_type", AddDiscountId },
                        { "currency", CurrencyId },
                        { "offer_id", OfferId },
                        { "expire_date", TxtDate.Text },
                        { "expire_time", TxtTime.Text },
                        { "description", TxtDescription.Text },
                        { "discounted_items", TxtDiscountItems.Text },
                    };

                    if (MAdapter.DiscountList.Count > 0)
                    {
                        foreach (var discount in MAdapter.DiscountList)
                        {
                            if (discount == null)
                            {
                                continue;
                            }
                            switch (discount.DiscountType)
                            {
                            case "discount_percent":
                                dictionary.Add("discount_percent", discount.DiscountFirst);

                                newInfoObject.DiscountPercent = discount.DiscountFirst;
                                break;

                            case "discount_amount":
                                dictionary.Add("discount_amount", discount.DiscountFirst);

                                newInfoObject.DiscountAmount = discount.DiscountFirst;
                                break;

                            case "buy_get_discount":
                                dictionary.Add("discount_percent", discount.DiscountFirst);
                                dictionary.Add("buy", discount.DiscountSec);
                                dictionary.Add("get", discount.DiscountThr);

                                newInfoObject.DiscountPercent = discount.DiscountFirst;
                                newInfoObject.Buy             = discount.DiscountSec;
                                newInfoObject.GetPrice        = discount.DiscountThr;
                                break;

                            case "spend_get_off":
                                dictionary.Add("spend", discount.DiscountSec);
                                dictionary.Add("amount_off", discount.DiscountThr);

                                newInfoObject.Spend     = discount.DiscountSec;
                                newInfoObject.AmountOff = discount.DiscountThr;
                                break;

                            case "free_shipping":     //Not have tag
                                break;
                            }
                        }
                    }

                    var(apiStatus, respond) = await RequestsAsync.Offers.EditOffer(dictionary);

                    if (apiStatus == 200)
                    {
                        if (respond is MessageOfferObject result)
                        {
                            Console.WriteLine(result.MessageData);
                            Toast.MakeText(this, GetString(Resource.String.Lbl_OfferSuccessfullyAdded), ToastLength.Short).Show();

                            AndHUD.Shared.Dismiss(this);

                            var data = OffersActivity.GetInstance()?.MAdapter?.OffersList?.FirstOrDefault(a => a.Id == newInfoObject.Id);
                            if (data != null)
                            {
                                data.DiscountType    = AddDiscountId;
                                data.Currency        = CurrencyId;
                                data.ExpireDate      = TxtDate.Text;
                                data.Time            = TxtTime.Text;
                                data.Description     = TxtDescription.Text;
                                data.DiscountedItems = TxtDiscountItems.Text;
                                data.Description     = TxtDescription.Text;
                                data.DiscountPercent = newInfoObject.DiscountPercent;
                                data.DiscountAmount  = newInfoObject.DiscountAmount;
                                data.DiscountPercent = newInfoObject.DiscountPercent;
                                data.Buy             = newInfoObject.Buy;
                                data.GetPrice        = newInfoObject.GetPrice;
                                data.Spend           = newInfoObject.Spend;
                                data.AmountOff       = newInfoObject.AmountOff;

                                OffersActivity.GetInstance().MAdapter.NotifyItemChanged(OffersActivity.GetInstance().MAdapter.OffersList.IndexOf(data));
                            }

                            Intent intent = new Intent();
                            intent.PutExtra("OffersItem", JsonConvert.SerializeObject(newInfoObject));
                            SetResult(Result.Ok, intent);
                            Finish();
                        }
                    }
                    else
                    {
                        Methods.DisplayAndHUDErrorResult(this, respond);
                    }
                }
                else
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                AndHUD.Shared.Dismiss(this);
            }
        }