@SuppressWarnings("unchecked")
  public void appendItems(List<T> newItems) {
    items.addAll(newItems);

    RowInfo<T> rowInfo = null;
    final int lastRow = getRowCount() - 1;
    if (lastRow >= 0) rowInfo = itemsPerRow.get(lastRow);

    if (rowInfo != null) {
      final float spaceLeftInLastRow = rowInfo.getSpaceLeft();

      if (listView.isDebugging()) Log.d(TAG, "Space left in last row: " + spaceLeftInLastRow);

      // Try to add new items into the last row, if there is any space left
      if (spaceLeftInLastRow > 0) {

        for (final T i : rowInfo.getItems()) newItems.add(0, i);

        final RowInfo<T> stuffThatFit = calculateItemsForRow(newItems);
        final List<T> itemsThatFit = stuffThatFit.getItems();

        if (!itemsThatFit.isEmpty()) {
          for (T anItemsThatFit : itemsThatFit) newItems.remove(anItemsThatFit);

          itemsPerRow.put(lastRow, stuffThatFit);
          notifyDataSetChanged();
        }
      }
    }

    new ProcessRowsTask().executeSerially(newItems);
  }
 public void setAllowReordering(final boolean allowReordering) {
   this.allowReordering = allowReordering;
   if (gridAdapter != null) {
     gridAdapter.recalculateItemsPerRow();
     gridAdapter.notifyDataSetChanged();
   }
 }
 public void setItems(List<T> newItems) {
   linearLayoutPool.clear();
   viewPool.clear();
   items.clear();
   items.addAll(newItems);
   recalculateItemsPerRow();
   notifyDataSetChanged();
 }