Ejemplo n.º 1
0
  /**
   * Sets the limit.
   *
   * @param aItemLimit limit.
   */
  public void setItemLimit(int aItemLimit) {
    itemLimit = aItemLimit;

    int hidden = 0;
    for (int i = 0; i < items.size(); i++) {
      ResultItemPanel item = items.get(i);
      item.setVisibility(i < itemLimit);
      if (i >= itemLimit) hidden++;
    }

    moreItem.setCount(hidden);
  }
Ejemplo n.º 2
0
  /**
   * Sets filtering time. If the time is set to <code>-1</code> then filtering is off. Otherwise it
   * shows the time after which all items are allowed.
   *
   * @param aLimitTime the time used for limiting.
   */
  public void setLimitTime(long aLimitTime) {
    limitTime = aLimitTime;

    int shown = 0;
    int hidden = 0;
    for (ResultItemPanel item : items) {
      item.setFiltered(isFiltered(item));
      item.setVisibility(!item.isFiltered() && shown < itemLimit);

      if (item.isVisible()) shown++;
      else if (!item.isFiltered()) hidden++;
    }

    setVisible(shown > 0);
    moreItem.setCount(hidden);
  }
Ejemplo n.º 3
0
  /** Recalculates the view. */
  private void recalcView() {
    int more = 0;
    int visible = 0;
    for (ResultItemPanel itm : items) {
      if (itm.isFiltered()) {
        itm.setVisibility(false);
      } else if (visible >= itemLimit) {
        itm.setVisibility(false);
        more++;
      } else {
        itm.setVisibility(true);
        visible++;
      }
    }

    moreItem.setCount(more);
    lbCount.setText(Integer.toString(visible + more));
  }
Ejemplo n.º 4
0
  /** Invoked when the user asks for more items. */
  private void onShowMore() {
    for (ResultItemPanel item : items) item.setVisibility(true);

    moreItem.setCount(0);
  }