예제 #1
0
  /**
   * @see IAPClientPaymentListener#productDataListReceived(int,
   *     com.nokia.mid.payment.IAPClientProductData[])
   */
  public final void productDataListReceived(int status, IAPClientProductData[] productDataList) {
    if (status == OK) {
      if (productDataList.length == 0) {
        Util.showAlert("No products", "There are no products available.");
        midlet.showGuideView();
      }

      for (int i = 0, size = productDataList.length; i < size; i++) {
        IAPClientProductData productData = productDataList[i];

        if (productData.getProductId() != null) {
          Guide guideProduct = (Guide) waitingProductData.remove(productData.getProductId());
          String title = productData.getTitle();

          if (title == null) {
            title = productData.getShortDescription();
          }

          if (title == null) {
            title = "unknown";
          }

          String price = productData.getPrice();
          if (price == null) {
            price = "unknown";
          }

          if (guideProduct != null) {
            guideProduct.setCity(title);
            guideProduct.setPrice(price);
            newGuideList.addItem(guideProduct);
            repaint();
          }

          // A guide was clicked before logging in and refreshing
          // the product list. Proceed with the purchase / restore.
          if (newGuide != null && guideProduct.getId().equals(newGuide.getId())) {
            newGuide = null;
            loadingGuides = false;
            handleClickedProduct(guideProduct);
            return;
          }
        }
      }
    } else {
      Util.showAlert("Loading failure", "Loading new guides failed: " + getPaymentError(status));
      midlet.showGuideView();
    }
    waitingProductData = null;
    loadingGuides = false;
    showLoading(false);
    repaint();
  }
예제 #2
0
 public final void productDataReceived(int status, IAPClientProductData productData) {
   newGuide.setCity(productData.getShortDescription());
   newGuide.setPrice(productData.getPrice());
   newGuide.setUrl(GUIDE_URL_PREFIX + newGuide.getId());
   manager.purchaseProduct(newGuide.getId(), IAPClientPaymentManager.FORCED_AUTOMATIC_RESTORATION);
 }