Exemplo n.º 1
0
  /**
   * 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);
  }
Exemplo n.º 2
0
  /** 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);
    }
  }
Exemplo n.º 3
0
  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();
  }