Ejemplo n.º 1
0
        public void ShowInfo(AvailableTrapApiResult availableTrap)
        {
            //string msgDistance = Resources.GetString(MyTrap.Droid.Resource.String.trap_buy_info_distance);

            //msgDistance = string.Format(msgDistance, availableTrap.Meters);

            //new AlertDialog.Builder(Activity)
            //    .SetIcon(Android.Resource.Drawable.IcDialogInfo)
            //    .SetMessage(msgDistance)
            //    .Show();
        }
        public override View GetView(int position, View view, ViewGroup parent)
        {
            try
            {
                if (view == null)
                {
                    view = mInflater.Inflate(Resource.Layout.trap_to_buy_list_item, null);
                }

                AvailableTrapApiResult item = itens[position];

                TextView txt_qty_item_buy   = view.FindViewById <TextView>(Resource.Id.txt_qty_item_buy);
                TextView txt_value_item_buy = view.FindViewById <TextView>(Resource.Id.txt_value_item_buy);

                Button btn_trap_item_buy = view.FindViewById <Button>(Resource.Id.btn_trap_item_buy);

                ImageView img_trap_item_buy = view.FindViewById <ImageView>(Resource.Id.img_trap_item_buy);

                if (item.NameKey.Equals(ETrap.BEAR))
                {
                    img_trap_item_buy.SetImageDrawable(view.Context.Resources.GetDrawable(Resource.Drawable.trap_bear_trap_selected_icon));
                }
                else if (item.NameKey.Equals(ETrap.MINE))
                {
                    img_trap_item_buy.SetImageDrawable(view.Context.Resources.GetDrawable(Resource.Drawable.trap_mine_trap_selected_icon));
                }
                else if (item.NameKey.Equals(ETrap.PIT))
                {
                    img_trap_item_buy.SetImageDrawable(view.Context.Resources.GetDrawable(Resource.Drawable.trap_pit_trap_selected_icon));
                }
                else if (item.NameKey.Equals(ETrap.DOGS))
                {
                    img_trap_item_buy.SetImageDrawable(view.Context.Resources.GetDrawable(Resource.Drawable.trap_dogs_trap_selected_icon));
                }
                else
                {
                    return(null);
                }

                btn_trap_item_buy.SetOnClickListener(new MyImageBuyClickListener(item, shopFragment));

                txt_qty_item_buy.Text   = item.Amount.ToString() + "x";
                txt_value_item_buy.Text = item.Price;
            }
            catch (Exception exception)
            {
                InsightsUtils.LogException(exception);
            }

            return(view);
        }
Ejemplo n.º 3
0
        public async void TryBuy(AvailableTrapApiResult availableTrap)
        {
            progressDialog = ProgressDialog.Show(Activity, Resources.GetString(MyTrap.Droid.Resource.String.loading), Resources.GetString(MyTrap.Droid.Resource.String.registering_purchase));

            try
            {
                BuyIntentApiRequest intent = new BuyIntentApiRequest()
                {
                    AvailableTrapId = availableTrap.Id, StoreKey = availableTrap.KeyGoogle
                };

                await PurchaseApiService.InsertBuyIntent(intent);

                pendingBuyIntent = intent;

                Product product = null;

                foreach (var itemGoogle in products)
                {
                    if (itemGoogle.ProductId == availableTrap.KeyGoogle)
                    {
                        product = itemGoogle;
                        break;
                    }
                }

                if (product != null)
                {
                    //product.ProductId = "android.test.purchased";
                    //product.ProductId = "android.test.canceled";
                    //product.ProductId = "android.test.refunded";

                    //await RegisterPurchase(intent);

                    _serviceConnection.BillingHandler.BuyProduct(product);
                }
            }
            catch (Exception exception)
            {
                InsightsUtils.LogException(exception);
            }

            progressDialog.Cancel();
        }
        public async Task <IHttpActionResult> AvailableTraps()
        {
            List <AvailableTrapResult> availableTraps = await AppBusiness.Purchase.ListAvailableTraps();

            List <AvailableTrapApiResult> response = new List <AvailableTrapApiResult>();

            if (availableTraps != null)
            {
                foreach (AvailableTrapResult availableTrap in availableTraps)
                {
                    AvailableTrapApiResult availableTrapResponse = Mapper.Map <AvailableTrapApiResult>(availableTrap);

                    response.Add(availableTrapResponse);
                }
            }

            BaseListApiResult <AvailableTrapApiResult> listResult = new BaseListApiResult <AvailableTrapApiResult>();

            listResult.AddRange(response);

            return(Ok(listResult));
        }
 public MyImageBuyClickListener(AvailableTrapApiResult availableTrap, ShopFragment shopFragment)
 {
     this.availableTrap = availableTrap;
     this.shopFragment  = shopFragment;
 }