public void pointerReleased(int x, int y) {
   if (!dragStarted && !getMenuBar().contains(x, y)) {
     ((NewGuideListRenderer) newGuideList.getRenderer()).setReleased(true);
   }
   super.pointerReleased(x, y);
   dragStarted = false;
 }
  /**
   * @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();
  }
  /**
   * Called when guide is purchased. Adds the new guide to the guide list and saves it to RMS.
   *
   * @param purchaseTicket
   */
  public void guidePurchased(String purchaseTicket) {
    if (newGuide == null) {
      return;
    }

    newGuide.setPurchaseTicket(purchaseTicket);
    newGuideList.getListModel().removeItem(newGuide);
    midlet.getGuideView().getGuideList().getListModel().addItem(newGuide);
    midlet.showAttractionView(newGuide);
    midlet.saveNewGuides();
    newGuide = null;
    midlet.getAttractionView().showLoading(true);
  }
  /** Shows this view and loads IAP account and guides. */
  public void show() {
    super.show();

    if (newGuideList.getListModel().getSize() == 0) {
      loadGuides();
    }

    if (account == null && !this.contains(loginButton)) {
      addComponent(BorderLayout.NORTH, loginButton);
    } else if (account != null && this.contains(loginButton)) {
      removeComponent(loginButton);
    }
  }
  private void loadGuides() {
    if (loadingGuides) {
      return;
    }

    loadingGuides = true;
    showLoading(true);
    newGuideList.getListModel().removeAll();

    new NewGuidesOperation(
            new NewGuidesOperation.Listener() {
              public void guidesReceived(Vector newGuides) {
                if (newGuides == null) {
                  Util.showAlert("Network failure", "Connecting network failed.");
                  midlet.showGuideView();
                  loadingGuides = false;
                } else {
                  // Populate guide list
                  boolean emptyList = true;
                  waitingProductData = new Hashtable();

                  for (int i = 0, length = newGuides.size(); i < length; i++) {
                    Guide guide = (Guide) newGuides.elementAt(i);
                    Vector ownedGuides = getOwnedGuides();
                    if (!ownedGuides.contains(guide)) {
                      emptyList = false;
                      waitingProductData.put(guide.getId(), guide);
                      guide.setUrl(GUIDE_URL_PREFIX + guide.getId());
                      guide.setAccount(account);
                    }
                  }

                  if (emptyList) {
                    Util.showAlert("No products", "There are no more products available.");
                    loadingGuides = false;
                    midlet.showGuideView();
                  } else {
                    loadProductData();
                  }
                }
              }
            },
            NEW_GUIDES_URL,
            account)
        .start();
  }
 /* some custom handling added for a list item highlight after tapping */
 public void pointerPressed(int x, int y) {
   ((NewGuideListRenderer) newGuideList.getRenderer()).setReleased(false);
   super.pointerPressed(x, y);
 }