示例#1
0
 public void fieldChanged(Field f, int i) {
   if (f == yes) {
     doConnect(Const.savecard + card.getId());
   } else if (f == no) {
     UiApplication.getUiApplication().popScreen(this);
   }
 }
  public void fieldChanged(Field f, int i) {
    if (f == exit) {
      screen = null;
      UiApplication.getUiApplication().popScreen(this);
    } else if (f == auction && created == false) {
      if (!confirm) {
        if (valid()) {
          created = false;
          SettingsBean _instance = SettingsBean.getSettings();
          _instance.created = false;
          SettingsBean.saveSettings(_instance);
          confirm = true;

          // when i auction
          /*
           * created = true, instance.created = true
           */
          synchronized (UiApplication.getEventLock()) {
            try {

              this.delete(cardfield);
              this.delete(openingBid);
              this.delete(buyNowPrice);
              this.delete(auctionDuration);

              lblBuyNowPrice.setText("");
              lblAuctionDuration.setText("");
              int val = 0;
              int buynow = 0;
              try {
                buynow = Integer.parseInt(buyNowPrice.getText());
              } catch (Exception e) {
                buynow = 0;
              }
              int bid = 0;
              try {
                bid = Integer.parseInt(openingBid.getText());
              } catch (Exception e) {
                bid = 0;
              }
              val = bid;
              if (buynow > bid) {
                val = buynow;
              }
              val = (int) ((double) val / 10);
              if (val < 5) {
                val = 5;
              }

              lblOpeningBid.setColor(Color.RED);
              lblOpeningBid.setText(
                  "Are you sure you want to auction "
                      + card.getDesc()
                      + "? It will cost you "
                      + val
                      + " credits.");
              // lblOpeningBid.setColor(Const.FONTCOLOR);

              add(
                  new AuctionField(
                      new Auction(
                          -1,
                          card.getId(),
                          1,
                          card.getDesc(),
                          card.getThumburl(),
                          openingBid.getText(),
                          buyNowPrice.getText(),
                          "",
                          "You",
                          auctionDuration.getText() + " days left",
                          ""),
                      cardfield.getThumbnail()));

              // this.removeButton(auction);
              // addButton(new FixedButtonField(""));
            } catch (Exception e) {

            }
          }
          // doConnect(Const.createauction+"&cardid="+card.getId()+"&bid="+openingBid.getText()+"&buynow="+buyNowPrice.getText()+"&days="+auctionDuration.getText());
        }
      } else {
        if (valid()) {
          created = true;
          SettingsBean _instance = SettingsBean.getSettings();
          _instance.created = true;
          SettingsBean.saveSettings(_instance);

          synchronized (UiApplication.getEventLock()) {
            try {
              lblOpeningBid.setColor(Color.RED);
              lblOpeningBid.setText("Attempting to create auction...");

              auction.setChangeListener(null);
              auction.empty = true;
              auction.setLabel("");
              // removeButton(auction);

            } catch (Exception e) {

            }
          }
          doConnect(
              Const.createauction
                  + "&cardid="
                  + card.getId()
                  + "&bid="
                  + openingBid.getText()
                  + "&buynow="
                  + buyNowPrice.getText()
                  + "&days="
                  + auctionDuration.getText());
        }
      }
    }
  }