예제 #1
0
  /**
   * Collapses / expands the group.
   *
   * @param col <code>TRUE</code> to collapse.
   */
  public void setCollapsed(boolean col) {
    collapsed = col;

    for (ResultItemPanel item : items) item.setCollapsed(col);

    moreItem.updateVisibility();
  }
예제 #2
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);
  }
예제 #3
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);
  }
예제 #4
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));
  }
예제 #5
0
  /** Invoked when the user asks for more items. */
  private void onShowMore() {
    for (ResultItemPanel item : items) item.setVisibility(true);

    moreItem.setCount(0);
  }