Exemplo n.º 1
0
  /** Unbinds all the presenters */
  private void unbindPresenters() {

    try {

      if (emptyPresenter != null) {
        emptyPresenter.stop();
      }

      if (presenters != null) {

        for (int i = 0; i < presenters.size(); i++) {
          try {
            final Presenter presenter = presenters.get(i);
            if (presenter != null) {
              presenter.stop();
            }
          } catch (Exception e) {
            Motiver.showException(e);
          }
        }
        presenters = new ArrayList<Presenter>();
      }
    } catch (Exception e) {
      Motiver.showException(e);
    }
  }
Exemplo n.º 2
0
  /**
   * Unbinds all the presenters
   *
   * @param target : which presenters all unbinded, 0=all, 1=mymeals, 2=most popular, 3=search
   *     results
   */
  private void unbindPresenters(int target) {

    // my meals
    if (myMealPresenters != null && (target == 0 || target == 1)) {

      if (emptyPresenter != null) {
        emptyPresenter.stop();
      }
      if (showMorePresenter != null) {
        showMorePresenter.stop();
      }

      for (int i = 0; i < myMealPresenters.size(); i++) {
        final Presenter presenter = myMealPresenters.get(i);
        if (presenter != null) {
          presenter.stop();
        }
      }
      myMealPresenters.clear();
    }

    // most popular
    if (mostPopularPresenters != null && (target == 0 || target == 2)) {

      if (emptyPresenter2 != null) {
        emptyPresenter2.stop();
      }
      if (showMorePresenter2 != null) {
        showMorePresenter2.stop();
      }

      for (int i = 0; i < mostPopularPresenters.size(); i++) {
        final Presenter presenter = mostPopularPresenters.get(i);
        if (presenter != null) {
          presenter.stop();
        }
      }
      mostPopularPresenters.clear();
    }
  }
Exemplo n.º 3
0
  /**
   * Adds new presenter to view
   *
   * @param presenter
   */
  protected void addNewPresenter(Presenter presenter) {

    try {
      // remove emptypresenter if present
      if (emptyPresenter != null) {
        emptyPresenter.stop();
        emptyPresenter = null;
      }

      presenters.add(presenter);
      presenter.run(display.getBodyContainer());
    } catch (Exception e) {
      Motiver.showException(e);
    }
  }